# Inverted pendulum LQR controller using motor

In my lab, I am trying to balance an inverted pendulum using simple LQR. To balance the arm I am using a DC motor. Now I have the A, B, C, D matrices. Using those I am able to find the feedback gain 'K' using MATLAB 'lqr' command. There are several parameters needed to find A, B, C, D. Among these are 3 parameters related to electrical characteristics of the DC motor:

1. motor torque constant;
2. motor back-emf constant;
3. motor armature resistance.

There are two DC motors that I am using:

• one is 24 V, 3600 RPM, and;
• the other is rated 12 V but lesser RPM (exact RPM not known).

I have the three electrical characteristics mentioned above for the 12 V rated motor, and using that motor I have successfully balanced the pendulum by a lots of tuning of Q, R matrices.

My problem here is that for the 24 V rated motor I don't have those 3 parameters. And hence my A, B, C, D matrices cannot be found for system using 24 V motor.

My question is will those three parameters really affect the system matrices that much? Or since every other parameter in system remains same except those 3 when I change motor, so even if I use the 12 V motor's electrical characteristics for 24 V motor also, meaning the same A, B, C, D matrices, I should still be able to balance the system?

The reason I am asking this is, because LQR 'K' depends on A, B matrices of system, so if I use the wrong A, B matrices then the resulting 'K' can never actually balance it.

Note: I will use 24 V motor at 12 V supply only since the objective requires to keep 12 V as max control effort.

• You should ask how you can find your 24V motor's constants from a datasheet or a few simple measurements. May 20 at 3:28
• @TimWescott i was able to find motor's armature resistance using multimeter. As for Torque and back emf constants i found this link: seas.upenn.edu/~jiyuehe/rotary-inverted-pendulum/…, but to measure motor's angualr velocity i dont have tachometer and the encoders are not working right now and it might take a few days to get new ones. Is there any other way given my situation May 20 at 9:37
• My apologies. I forgot to mention that this is Stackexchange, which is a question and answer site, not a traditional forum. You should create a separate question. As for not having a tachometer -- try starting with the motor's rated speed at its rated voltage. That should get you an approximate answer. May 20 at 17:34
• @TimWescott so I can use motors rated 24v RPM mentioned to find(approximate) the torque, back emf constants? So as per the link it I provided in my earlier reply, it must be approx: 24/(3600*2π/60)? May 21 at 19:57

My question is will those three parameters really affect the system matrices that much? Or since every other parameter in system remains same except those 3 when I change motor, so even if I use the 12 V motor's electrical characteristics for 24 V motor also, meaning the same A, B, C, D matrices, I should still be able to balance the system?

My first comment is that it's a lab - try it! See what happens. You can write lab reports (or entire research papers) on experiments that went wrong if you can explain why intuition would lead you to think one outcome would happen and the phenomena that's occurring that causes the unexpected outcome to happen.

Second comment is also that it's a lab, so if your question is:

My problem here is that for the 24 V rated motor I don't have those 3 parameters

1. motor torque constant;
2. motor back-emf constant;
3. motor armature resistance.

I'd encourage you to run the tests you need to run to calculate those parameters.

I've also spent about 10 years working professionally in simulation and would strongly encourage you to simulate your system. Matlab will give you a controller for your system, so try applying that controller to the same system, then vary the motor parameters (25% different, 50% different, etc.) but apply the same controller. See what the simulated/predicted impact is on performance. Try the experiment with the 12V motor and see how that compares with simulation. Try the 24V motor and see if you can estimate parameters by comparing actual performance to your simulated parameter variations. Measure the motor parameters and see how your estimates compare.

Labs are your chance to apply what you've learned to a real system. Sometimes those "frictionless" assumptions hold, sometimes they bite you. The motor speeds you can perfectly calculate are now noisy encoder readings. Your continuous systems are now discrete.

Go try it. See if you can use your knowledge to predict the outcomes before they happen, and if you find the experiment is surprising then think critically about the differences between reality and theory and explain why the results are surprising.