Go Down

Topic: Self Balancing Robot (Read 26 times) previous topic - next topic

msx

Sure, i've uploaded it here. Contains all the code and examples, and it's released in the public domain.
The code should work good, but it's not 100% tested.

http://www.lugato.net/MD23.zip

zhengrob

Seems good enough! Great job!

You can try to move the heavy battery to the bottom of the robot. This may reduce the swing effect somewhat.

BTW, could you supply some details on the LCD you use and as well the AXELCD library files?

msx

Thanks zhengrob :) Are you using it in a project?

About the battery, is doesn't work that way, becouse the robot is an inversed pendulum and so it actually works better when the weight is high rather than down (it increase intertial and give more reaction time).

The LCD i'm using is the Picaxe LCD display, this one, datasheet here. Basically it's a standard lcd with an additional board attached. It can work serially or with I2C. As my robot was almost only I2C, i used that mode. The library is very simple, it just sends the correct i2c messages with a syntax similar to the Serial.println method.

I'll post sources this evening.

zhengrob

Hello msx! thanks for your message!

I am just learning Kalman filter algorithm and your project is a good example instruction to me.  Arduino is new to me therefore any details will help me to better understand the entire routine.

msx

sorry, a little late, here's the picaxe lcd i2c display library :)

http://www.lugato.net/AXELCD.zip

kas

Hi,

I have build a balancing robot based on Sparkfun 5DOF acc/gyro combo, Arduino and Parallax continuous servo.
I had sofar mixed results and suspect the servos have to much backslash

I want to test the AX12 route.
Can you point me to some Arduino code to run these specific servos  ::)

TIA
Yves

-------------------------------------------------------------------------------
The "looseness" you describe is a real problem with balancers.  I used motors similar to yours at first, but was able to achieve much tighter and more responsive balancing by switching to zero-backlash servos (Dynamixel AX-12).

Here's a little sample movie of what a difference reduced backlash makes: ....

That demo is using the "encoder" (continuous rotation pot) integrated into the AX-12.

A friend of mine worked on a commercial balancing toy.  He mentioned that it used cheap high-backlash motors, and they had to use sophisticated filtering and modeling to accommodate the backlash.  It took an experienced control expert quite a while to get it working.

So I'll just stick with tighter motors.  

- Nathan

ironbot

Hi,
This is really nice work!!
How did you design the control law? Do you have or used any white paper on (LQR) controller design?

:)

msx

Thanks :)
uhm no, I implemented a PID controller to control the motors.

ironbot

>I implemented a PID controller to control the motors.
Well, did you publish your implementation steps somewhere? Is it possible to know and repeat your steps? :)

I have a background in mathematics of PID, LQR and so on, but no practical experience. It could be very helpful to just repeat your steps for the first time, if it is allowed.

:)


msx

It is sure possible :) It just require some understanding and patience.

Well first off i did a quick test of the hardware, making a simple arduino program to read some raw values from the IMU, just to check that it was working properly.

Then i studied/implemented/adapted the Kalman filter to obtain the correct angle, which was the thing that was scaring me off the most (it would be a waste to have a complete robot and then be unable to read the value :P). I proceeded by strapping the Arduino and the Imu on a wood stick. Then i did a simple pc program (with Delphi, but you can use whatever :P) that reads the angle data from the serial line, and show a simple line that is (should be) oriented as the robot. That gave the best "feeling" of how precise the measuring was. At that point i spent quite some time debuggin the filter to obtain a stable and responsitive reading, mostly a work of trial and error that is unluckly very coupled with the specific hardware and setup (read: you have to adjust your own parameters :P)
After i was satisfied with it, i designed the robot (well most of it was already on my mind), i used pen and paper and rulers and also did some 3d sketches with blender. Then went on building it. I can say: keep the design as simple as you can, becouse then just the slightest error drilling a hole or gluing something can make everything displaced and ultimately a great pain :)

Then i did some test, simply running the motors proportionally to the current angle. At the time i didn't know what a PID controller was :)
That gave some results but of course it wasn't stable at all. I learned the PID controller and implemented it (which is easy) and tuned it (which is hard, as you probably already know :P ). The best thing you can do is to find some generic values to determine the order of magnitude and then attach three potentiometers to dinamically change the P,I and D parameters while the robot is running. Wikipedia has a good practical article on the PID that explained a couple of tecniques to find the parameters.
At the end the results was the one on the videos: the robot can actually stand without fall for indefinite time, but it's not completely stable and swings back and forth quite a lot.
That's possibly a combination of bad hardware, bad robot structure, and me not being an engineer :)

Btw i'm now planning a second version with different hardware, i'll post on this forum as soon as i've something :)

That was it, feel free to ask any question. :)
The complete source is avaiable on this thread.

ironbot

Thank you very much for sharing your experience, it gives insight! I am following you ;)

msx

great :)
if you are planning on hardware, i'll suggest making it smaller than mine. It was too heavy and the structure was barely strong enought not to break apart when falling. In my new version i'm keeping the Arduino and the IMU, and using instead a simple motor driver (an L293something), two small pololu motors and 4 AA cells.

ironbot

Thank you for information!
Actually I'm late for using this information, as I've already purchased the hardware.

By the way, why didn't you use a driving system based on incremental quadrature encoders? Well they have their own specially adapted Kalman filter, and I think that (at least theoretically) using them together with their KF, gives a cheaper/better/lighter/more sophisticated driving system. May be you have already tested them?




Cuauhtemoc Luna

Hi my friend, this is really great, congratulations ;). I found in an other forum than you "burn" the MD23. I am worried, because I followed your steps and I do not want to burn my md23, do you found what was the problem?, thanks a lot.

Cuauh

msx

#29
Jan 17, 2009, 10:43 am Last Edit: Jan 17, 2009, 10:47 am by msx Reason: 1
Thanks :)
Yes i did burnt an MD23. That was a very sad experience, my first "expensive" hardware lost.
Anyway, i did it just connecting the MD23 to an unregulated power supply. Yes that's a stupid mistake, but i'm learning electronics on the go, and i was not aware.. basically the power supply shoot 15V or more to the board and a chip released its magic smoke.

If you're unaware of the issue (but you probably are :P), i suggest learning it the soft way reading this:
http://www.sparkfun.com/commerce/tutorial_info.php?tutorials_id=103


ironbot: uhm no, i didn't used the encoders.. I can't see how to take advantage of them. how would you use them ?

Go Up