Help with cascade PID for self balancing bike
Help with cascade PID for self balancing bike
I have had a crazy idea to build a self balancing bike. See work so far https://www.youtube.com/watch?v=qjyuvFq ... e=youtu.be
It is built with the Mackblock platform and have a Mega2560 at it's heart and also has an onboard MPU6050 as well as a number of other builtin sensors. It can be programmed in Ardunio IDE or it has scratch blocks to program it.
Now what I need help on (maybe even just a little brain storming) is understanding the design of the needed cascade PID (a PID inside a PID) and also understand how to tune a cascade PID.
The design that I was thinking was the outer loop has a set-point of the angle the robot wants to be at (zero for starters but other angles later on when it is driving around and I want to turn) and the outer loop will ask for a rate of rotation of the body it wants to achieve the set-point. The inner loop gets the rate of rotation of body from the outer loop then controls the steering of the bike to try to achieve that rate of rotation of the body.
Does anyone have better ideas or more importantly know how the hell I would go about tuning it.
It is built with the Mackblock platform and have a Mega2560 at it's heart and also has an onboard MPU6050 as well as a number of other builtin sensors. It can be programmed in Ardunio IDE or it has scratch blocks to program it.
Now what I need help on (maybe even just a little brain storming) is understanding the design of the needed cascade PID (a PID inside a PID) and also understand how to tune a cascade PID.
The design that I was thinking was the outer loop has a set-point of the angle the robot wants to be at (zero for starters but other angles later on when it is driving around and I want to turn) and the outer loop will ask for a rate of rotation of the body it wants to achieve the set-point. The inner loop gets the rate of rotation of body from the outer loop then controls the steering of the bike to try to achieve that rate of rotation of the body.
Does anyone have better ideas or more importantly know how the hell I would go about tuning it.
Re: Help with cascade PID for self balancing bike
one of those things i kind of wish to try is to make an inverted pendulum e.g.
http://ctms.engin.umich.edu/CTMS/index. ... ControlPID
https://www.youtube.com/watch?v=XWhGjxdug0o
but neither do i know how to do it. But if you can figure that out, i'd think it may even be possible to balance a bot on a ball etc.
http://ctms.engin.umich.edu/CTMS/index. ... ControlPID
https://www.youtube.com/watch?v=XWhGjxdug0o
but neither do i know how to do it. But if you can figure that out, i'd think it may even be possible to balance a bot on a ball etc.
-
- Posts: 505
- Joined: Fri Dec 27, 2019 4:53 pm
- Location: Munich, Germany
- Contact:
Re: Help with cascade PID for self balancing bike
It looks to me like a positive feedback regulation instead of a negative one, or it is too slow. Maybe inverting the steering direction?
-
- Posts: 633
- Joined: Thu Dec 19, 2019 1:23 am
Re: Help with cascade PID for self balancing bike
Most successful projects start with research and prototyping at a simple(r) level and progress with enhancing the build(s) until the programmer is completely familiar with both the technology and libraries and their own controlling code.flyboy74 wrote: Sun May 24, 2020 11:57 am I have had a crazy idea to build a self balancing bike. See work so far https://www.youtube.com/watch?v=qjyuvFq ... e=youtu.be
...
Google for examples of what others have done and build a skeleton model using their effort to springboard your prototype.
https://www.google.com/search?&q=arduin ... ng+machine
It's not rocket science, but it is a bit of work.
Ray
Re: Help with cascade PID for self balancing bike
FYI
I have been researching it a lot because I would like to make this project work. It does seem inverted pendulum is the hello world of control theory.
I have been quite impressed by what they have worked out in control theory. For anyone interested here is a series of university lectures put on YouTube https://www.youtube.com/watch?v=Pi7l8mMjYVE&t=880s
I understand most of it but am missing some understanding of some of the math so first need to find the math online to learn the few missing bits. Especially I don't understand the most common used bit of math, how they get from the first line equation to the second line equation in following pic
I have been researching it a lot because I would like to make this project work. It does seem inverted pendulum is the hello world of control theory.
I have been quite impressed by what they have worked out in control theory. For anyone interested here is a series of university lectures put on YouTube https://www.youtube.com/watch?v=Pi7l8mMjYVE&t=880s
I understand most of it but am missing some understanding of some of the math so first need to find the math online to learn the few missing bits. Especially I don't understand the most common used bit of math, how they get from the first line equation to the second line equation in following pic
Re: Help with cascade PID for self balancing bike
It is just the first video of the first lesson in a series of videos that completes the whole course. I am currently wathcing soem other math videos to fill in some of my missing understanding
Re: Help with cascade PID for self balancing bike
i'm trying to pickup these stuff as well, but that some PID things tend to be *non-linear*, getting the right model isn't the easiest thing to do.
Re: Help with cascade PID for self balancing bike
If you watch the whole series then they cover how to linearize a non linear system. Do be prepared for some complex math though.ag123 wrote: Fri May 29, 2020 8:16 am i'm trying to pickup these stuff as well, but that some PID things tend to be *non-linear*, getting the right model isn't the easiest thing to do.
They even cover how to work out mathematically how to optimize balance between dynamic (fast correction) and robust (handle a wide range of disturbances). They even add a kalman filter at the end to remove noise from the sensor as all sensors have noise.
I had just been building and tuneing feedback control system by trail and error, I didn't know people had actuality worked out how to do the complex math behind these systems.
In order to fill in some of the gaps in my math knowledge I am now watching all the videos from this channel "Math for engineers" by Hong Kong university https://www.youtube.com/channel/UClqK6P ... RLlMWVuE0g
-
- Posts: 633
- Joined: Thu Dec 19, 2019 1:23 am
Re: Help with cascade PID for self balancing bike
A friend of mine (deceased and very much missed) wrote a small post many years back on making efficient and accurate lookups for microcontrollers that are computationally challenged. Essentially the power of a spreadsheet will be used to locate multiple sections on a graph where nearly linear slope exists... these areas get translated to lookup areas. Usually, in my experience, the flash usage is light if one scales to keep the numeric data in the integer range.flyboy74 wrote: Fri May 29, 2020 9:27 pm ...
If you watch the whole series then they cover how to linearize a non linear system. Do be prepared for some complex math though.
...
Here is Peter's writeup. https://www.phanderson.com/picaxe/lin_thermistor.html
Note that the link to the Vishay thermistor is broken, substitute any 10K NTC composite part for a representative curve.
https://www.vishay.com/thermistors/curv ... tion-list/
Over the many years since Peter introduced me to this technique, I have been able to easily create fast and accurate and reasonably small tables for some rather ugly sensor plots.
I am unable to answer if such pre-digested analysis can be applied to 3D balancing, but I suspect you will find the technique valuable in general for a variety of analysis.
Ray