Electronics > Projects, Designs, and Technical Stuff

Inverted Pendulum robot won't balance! (MPU-6050, STM32, PID etc)

<< < (3/5) > >>

ogden:
PID tuning may seem like art or magic, but usually it is not - *when* you understand basic principles. My usual "go to" article I suggest to "PID beginners": https://www.wescottdesign.com/articles/pid/pidWithoutAPhd.pdf. Obviously there are more digital control articles & books around.

SiliconWizard:

--- Quote from: MattHollands on January 05, 2020, 07:30:16 pm ---
--- Quote from: SiliconWizard on January 05, 2020, 05:15:47 pm ---I haven't looked at it in great details, but first thing I would question is your final estimation of the pendulum angle. Are you sure it's correct?


--- End quote ---

What I have done is have the STM32 report it's measured angle over USB and it looks pretty correct. However, I can only check this in the static case because it needs the USB plugged in. While the robot is moving I need to remove the USB cable which means I cannot easily track the calculated angle in a dynamic state.

--- End quote ---

OK. Well, it would be interesting to see how the calculated angle turns out once the thing is moving. When it's not, all dynamic accelerations will be zero, the only thing you'll get are the static acceleration (gravity basically)... in which case it's not surprising that the result is correct. I'm not saying there's a fault in what you did, but that's just what I would suspect first. (Method! Check your inputs first... ;) )

Mr. Scram:

--- Quote from: ogden on January 06, 2020, 12:55:37 am ---PID tuning may seem like art or magic, but usually it is not - *when* you understand basic principles. My usual "go to" article I suggest to "PID beginners": https://www.wescottdesign.com/articles/pid/pidWithoutAPhd.pdf. Obviously there are more digital control articles & books around.

--- End quote ---
Various tuning methods existing but I don't think I've ever seen one work without some practical experimenting and they tend to tune the system quite aggressively. Knowing the basic principles helps but that's where some of the art comes in. It seems rare to boot a system up and have it work first go.

ogden:

--- Quote from: Mr. Scram on January 06, 2020, 06:50:31 am ---
--- Quote from: ogden on January 06, 2020, 12:55:37 am ---PID tuning may seem like art or magic, but usually it is not - *when* you understand basic principles. My usual "go to" article I suggest to "PID beginners": https://www.wescottdesign.com/articles/pid/pidWithoutAPhd.pdf. Obviously there are more digital control articles & books around.

--- End quote ---
Various tuning methods existing but I don't think I've ever seen one work without some practical experimenting and they tend to tune the system quite aggressively. Knowing the basic principles helps but that's where some of the art comes in. It seems rare to boot a system up and have it work first go.

--- End quote ---
By practical experimenting you mean tuning PID variables using trial and error approach, other name for it is "PID tuning magic"? :D Yes, why not - as long as it works for you. Thou there are other ways. Further reading: https://www.mathworks.com/company/newsletters/articles/tuning-a-pid-controller-when-a-plant-model-is-not-available.html

mikerj:
The very sluggish response suggests the PID gains are way too low.  Typically these simple PID based balancing systems tend to have gains high enough that they are slightly jittery around the balance point.

To manually tune a system I usually start with the Ziegler-Nichols tuning method to get proportional gain in the ball park, i.e. start with P only gain (I and D set to zero) and wind it up until the system starts oscillating, then reduce it to about 0.6 of this value.  The actual Ziegler-Nichols derives the other gains from period of oscillation, but one I have P somewhere close I usually just add integral gain until the step response is reasonable then tweak all three gains.  Once you get a feel for the impact that each term has on the response you can home in on suitable values fairly quickly.

If it's not currently included I'd advise adding some method of logging the outputs from your sensors (e.g. serial link) so change to the control loop performance from modifying PID gains can be easily visualised in e.g. a spreadsheet. 

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod