PDA

View Full Version : Cool Balancing Robot a Success!!!


Flipper_118
Apr 19, 2007, 10:17 PM
It works,

I posted here a few months ago about building a "gyro stabilized balancing robot".....today I finally succeeded!

Quick Overview:
The project is based on a HC11 micro processor and only uses an IR distance sensor (the Sharp GP2D12 to be exact) to determine the tilt angle. The IR sensor is mounted at an angle to the ground to create the largest sensor swing without having problems with beam reflections. The control systems simply takes this sensor value, amplifies it, filters it (just a cap), then sends it to the on board ADAC to update the PWM signal to the motor (only one wheel is driven...hence the one heat sink on the h-bridge).

This robot would not balance any longer then about 5-10seconds on tile floor. So I (with the help of my instructor) started working on a damping factor to smooth out the balance oscillations. Programming in assembler isn't the funnest and I could never get the software gain factor and damping factor sorted out to work together....so I decided to try a more physical damping factor.....carpet! Once I placed the robot on the carpeted floor it balances perfectly! The carpet is nice and short and doesn't compress under your feet much at all, in fact a few sheets of news paper would prolly suffice, but it balances perfect now!

After weeks and weeks of pluggin away it is nice to see something amazing come out of your hard work and $$$ :p . Pictures to follow...I am quite busy with exams right now but if there is any interest I will post a video and am happy to answer any questions you may have.....I wrote a 20 odd page technical report on this thing so I am fairly sure I know how most of the levers and cranks work. ;) .

Thanks for the motivation fellas,

Curt

Flipper_118
Apr 19, 2007, 10:24 PM
Here is a link to the old thread...just in case you wanted the full story.

http://www.rcgroups.com/forums/showthread.php?t=624483&highlight=balance

RX5
Apr 19, 2007, 11:11 PM
how about a PIC16F84A version? :)

rmteo
Apr 19, 2007, 11:25 PM
Congratulations on your success. Keep up the good work!!!!

lazy-b
Apr 20, 2007, 12:28 AM
Guys: How about a video, please post it in www.youtube.com

Flipper_118
Apr 20, 2007, 01:46 AM
Just finished editing a clip for one of my classes so I'll see if I can get it up on youtube this weekend.

toxicmouse
Apr 20, 2007, 03:13 AM
nice work. what sample rate did you have on the IR sensor?

i noticed that only the one motor was wired up, does it also work with both motors running?

andrewm1973
Apr 20, 2007, 07:52 AM
how about a PIC16F84A version?

Why would you want to step down from a HC11 to a pic16F84?

Flipper_118
Apr 20, 2007, 11:58 AM
nice work. what sample rate did you have on the IR sensor?

i noticed that only the one motor was wired up, does it also work with both motors running?

The board was running at about 1.2288mhz once the crystal was divded down by a factor of 4, and I was running the sampling as fast as the micro could take it. Although the IR apparently only updates at 25hz. So that was prolly my limiting factor for sample rate.

Only 1 motor is running due to the short nature of the project and for simplification. 2 motors could just have easily been operated...I was just short on time and the balancing algorithm dosnt change for 1 motor or two.....well......for the sake of simplification we will say that the algorithm dosnt change. ;)

Curt

RX5
Apr 20, 2007, 02:32 PM
Why would you want to step down from a HC11 to a pic16F84?

cuz HC11 is not available in our area..

rcBluebird
Apr 21, 2007, 04:38 AM
Congrats, keep up with your hard work.

I have some suggestions. Using accelerometer to detect the tilt at
http://www.analog.com/en/subCat/0,2879,764%255F800%255F0%255F%255F0%255F,00.html. It has PWM built in, so the code would be less complicate. Assembly is bad, but it is the best for code size. Otherwise, you can use Nios II with DSP built-in, and they have sample code for filtering. Call Altera (www.altera.com) for educational support. I did before, and they sent me an eval board with a Nios II component.

Great to hear it worked.

Flipper_118
Apr 21, 2007, 06:10 PM
Thanks fellas,

Heres the video. I was asked by my College to create a video that they could show at Info week for Electronic Engineering Students. There are also thoughts of implementing this type of robot into the control systems course in the future! Pretty exciting to be talking to program heads just for a simple balancing robot!

http://www.youtube.com/watch?v=DDBkg1PfvFY

Curt

AirBorne_AZ
Apr 22, 2007, 12:29 AM
Curt,

Very nice to see your project succeed! Congratulations, I think this is the first problem that everyone studies in their first control systems class. I also studied it, but never made any physical project out of it. Good to see that you actually put that knowledge to practical project. Way to go man! The field of control systems is really awesome!

Flipper_118
Apr 22, 2007, 03:11 PM
AirBorne_AZ,
Thanks, I don't have a clue as to why my school didn't implement it for the last 10 years! It is a perfect example of damping, gains, stable and unstable systems, etc!!!

I think after seeing the success and simplicity in this system I may make a smaller model driving by large servos (modified for 360) just to further simplify the PWM signals, since the hardest part of the project was the output of 2 pwm signals from the micro. I programmed it so that one of the pwm signals for the H-Bridge was a slave to the 1st PWM signal out the micro in order to keep both signals in PERFECT unison. But this made shifting of the modulated signals, independently, VERY difficult. :p

I have the idea floating around my head to combine a gyro with the IR's to get a smoother balance action. I would use the IR's as a definite position sensor, and use the gyro to help detect rate of angle change (acceleration of error angle is one way to create a damping factor to stop small oscillations). 2 more tests then I can start thinking about this stuff. :D

Curt

lazy-b
Apr 24, 2007, 05:22 AM
Thats Nice project.....This is the BEST SAMPLE OF FEEDBACK CONTROL.....have saw somewhere in the net, use parallax Basic Stamps, use an RC Airplane wheel connected directly to Modify RC Servo.

This is call Inverted Pendulum......this is Single Axis control, your next step is to make a 2 axis control, a Balancing Broom Stick in a X-Y table would be nice, or a more challenginng RC Unicyle Robot.

keep us posted on your project.

Ellion

AndyKunz
Apr 24, 2007, 08:05 AM
The inverted pendulum is an app note on the Microchip site, AN 964.

Text: http://ww1.microchip.com/downloads/en/DeviceDoc/41223B.pdf

Code: http://ww1.microchip.com/downloads/en/AppNotes/AN964.zip

Andy

mattijs321
Apr 24, 2007, 08:11 AM
a little strange that you used IR as a sensor...i'd have gone with gyro and MEMS accelerometer (they can be used to measure tilt from perpendicular to earth)

nice work though


does it stay upright when you push it??

Flipper_118
Apr 25, 2007, 09:47 PM
a little strange that you used IR as a sensor...i'd have gone with gyro and MEMS accelerometer (they can be used to measure tilt from perpendicular to earth)

nice work though


does it stay upright when you push it??

Thanks,

I initially wanted to use a rate gyro with wheel encoders to determine if there was any drift...but went for the cheaper simpler method.

It does stay upright when I push it...but due to the low speed of my motors (super high torque tho!) it can only recover from maybe +-10 degrees at the MOST!

The only problem I had with IR is that from surface to surface there was a different reflection factor which varied my signal. In the video after I engage the motors, I tap the 3rd button which I use to manually set the rough zero reference point for the IR sensor. If I were to do it again I would prolly just use 2 sensors and wiggle around until there were approx equal to one another.

Rhathid
Apr 26, 2007, 05:47 PM
I don't get impressed easy but that's pretty sweet. I like the cheap route. I'm more impressed by a low cost solution the gets the job done.

I'm not sure if I missed it out not, but do you have the specs for your circuits as well as code available?

Can you make it move to a different location? Say, stay balanced and roll 4 feet forward, stop for 10 seconds, then return to start?

Keith43221
Apr 26, 2007, 05:55 PM
That was wicked.
But, can you make travel places? Even just like straight line?
Either way, I found it funny just watching it stay up. Very cool.

Flipper_118
Apr 27, 2007, 02:02 PM
Thanks Rhathid and Keith43221,

I do have all the specs for my circuit and the code avaiable, but unless the setup is exactly what I have pictured the code aint gonna work to good. :p Basically all the code does is take a reading from the IR (which is just a varying voltage), then runs that signal thru a small amp with a gain of 40 (my resolution pre-amp), then uses that signal as an input at the analog of the micro (ADAC).
To control the duty cycle I take this input value (hex value now), and multiply it by a linear gain curve and store that directly as the high time for the PWM signal. Since me and my instructor created a signed 8x8 bit multiplication sub routine, I was able to simulate positive and negative values (forward or backward tilt) so it made it quite easy to correct for error angle.
The forward and backward motion is just a matter of hooking up the other motor, and running a user controlled tilt error into the micro. If you move the balance point forward or backward the robot in turn moves that way also. Turning is just an equal opposite offset to the motors (dosnt affect balance at all). Due to the speed issues I was having (not enuff!) my robot would have to more forward very slow in order to still keep balance.
But I got a 92% on this project so I am more then satisfied!

Curt