Control algorithm for self balancing robot - Page 1
Forum section: electronics / projects

author: sagnikbasu
author_rank: Contributor
timestamp: February 05, 2017, 02:42:51 pm
content: Hi , I have designed a two wheeled self balancing robot. The problem is that I have tried both PID and LQR algorithm and none of them is unable to stabilise the bot if the angular deviation is more than like 10-15 degrees.Is there any approach for solving this problem ? What would be the best controller for a two wheeled self balancing bot?

author: snarkysparky
author_rank: Frequent Contributor
timestamp: February 05, 2017, 03:21:33 pm
content: Is it because the drive doesn't have the power required to right the robot at those extreme angles.

author: retrolefty
author_rank: Super Contributor
timestamp: February 05, 2017, 03:35:47 pm
content: Quote from: sagnikbasu on February 05, 2017, 02:42:51 pmThis is normally a good and proper domain for PID control. Are you sure you 'tuned' the PID constants it their best values? Tuning a PID controller, other then very general rules, is more an art then a science.

author: m98
author_rank: Frequent Contributor
timestamp: February 05, 2017, 04:05:32 pm
content: In which way is it unable to stabilize at 15 degrees? Does it oscillate, drop straight down, or simply mechanically struggle to get back up due to the motor being too weak or the wheels slipping?Could you maybe post a video?

author: rstofer
author_rank: Super Contributor
timestamp: February 05, 2017, 06:10:39 pm
content: Try to balance a pencil on the palm of your hand. It won't stay upright very long! Now make the pencil more unstable by adding clay to the tip. It will be much easier to balance. There might be a corollary with your robot. Or not...Google for "self balancing robot pid" and you will find hundreds of replies.You can also Google for "inverted pendulum".You might also try to calculate how much torque is required for various angles of inclination. Compare that with the capability of the motor and the traction of the tires. There will be some angle for which there is no recovery. I would expect it to be a pretty small angle, certainly nothing like 45 degrees.

author: H.O
author_rank: Frequent Contributor
timestamp: February 06, 2017, 06:28:11 am
content: How are you measuring the actual tilt angle?Is it possible that the acceleration applied to the platform by the drive system, in order to stabilize it, produces an error in the measured tilt angle?

author: Kohanbash
author_rank: Regular Contributor
timestamp: February 07, 2017, 09:29:51 pm
content: Are your sensors updating fast enough? How about your controllers? How about motor torque?PID should work (maybe just PI). You can try gain scheduling so as the tilt angle perpendicular (normal) to the ground increases, the gains change (probably more P, less D).For safety, you will probably need to have some cutoff angle that if it gets exceeded, the wheels stop.

author: coppice
author_rank: Super Contributor
timestamp: February 08, 2017, 08:02:52 am
content: Quote from: retrolefty on February 05, 2017, 03:35:47 pmIf you think art plays a part in PID control design, you haven't understood the science. In most cases the science of the plant.

author: tatus1969
author_rank: Super Contributor
timestamp: February 08, 2017, 11:05:14 am
content: check how well the actuator can follow its commands. If not: add more torque and dynamic response!

author: retrolefty
author_rank: Super Contributor
timestamp: February 08, 2017, 11:22:11 am
content: Quote from: coppice on February 08, 2017, 08:02:52 amYou might be correct or not. I only base that on nearly 30 years of tuning and observing others tuning PID controllers in a large oil refinery. I never observed anyone successfully tuning PID loop variables with just a calculator, because there was never a accurate model of the plant's processes. Making step changes and observing results then repeating until results meet objective was/is the common method I saw used.Designing a PID controller and tuning such are two different activities. My original comment wasn't to imply that only an artist can successfully tune PID controllers, but that it can be a very difficult and time consuming effort.

author: tatus1969
author_rank: Super Contributor
timestamp: February 08, 2017, 11:37:09 pm
content: Quote from: retrolefty on February 08, 2017, 11:22:11 amassuming that most processes in a refinery should be linear, i would guess that the engineers there didnt bother doing the math. i had control theory lectures during my study back in the 90s, it was well understood already back then. whenever i have a linear control problem and have the option to measure the step response, i stick to the theory. works out in most cases. it is most important to put enough effort in understanding and modelling the controlled system well. no need for try and error.

author: Brumby
author_rank: Unknown
timestamp: February 09, 2017, 05:35:12 am
content: Quote from: tatus1969 on February 08, 2017, 11:37:09 pmThat's a very dangerous place to be starting from.QuoteWhy would they?I know nothing about refinery processes - but I can think of a very simple process that is not linear: Heat input to a system controlled by temperature measured. Use it for water, say, and it kinda gets non-linear when the water boils.QuoteNot exactly a compelling approach.QuoteI think the engineers probably did do a lot of math - just to get the system to a safe, stable, controllable state. Getting the tweaking right might have necessitated a significant effort in getting one (or more) of those terms that are "so small that they can effectively be ignored" properly modelled so that their minimal influence on the control algorithm can be included.QuoteToo much to comment on here - so I just underlined some of the more notable reservations I have about some of that.The bottom line is this - sometimes the real world is not as friendly as theory would like. If it were, we would never have to include trimming potentiometers, capacitors, inductors, etc. into any electronic equipment. We would be able to use exact values for the circuit to operate precisely as required straight out of the board assembly line.

author: Marco
author_rank: Super Contributor
timestamp: February 09, 2017, 05:49:07 am
content: I think the usual approach for simple balancing bots is slightly ad hoc fuzzy logic, it's not a linear problem.

author: Jeroen3
author_rank: Super Contributor
timestamp: February 09, 2017, 06:41:41 am
content: You need to give more details on your implementation for use to determine what fails.From what I read is that you have to drive the bottom forward or backward to change the pendulum angle. There will be an angle where it can't accelerate enough to compensate.Like this right?:http://www.kerrywong.com/2012/03/21/a-self-balancing-robot-iii/