I'm working on building a balancing robot and having a bit of trouble with it. The robot was designed and printed on my 3D printer. The idea was to try and use all printed parts except for electronics. For the electronics I'm using a UNO, accelerometer/gyroscope on a 6DOF board, and H-bridge to drive the motor. The motor just a random 12V motor I found at a surplus store.
Here's the electronics set up. The 5V runs on the top power rail and 12V on the bottom rail. The 6DOF board (top left) runs off the 3.3V from the UNO.
For the code I'm using a modified version of the code from this post http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1284738418
Here's a screen shot of the unfiltered angle (blue) and the angle from the Kalman filter. This is just me moving it around randomly. The filter seems to be working.
And a video of how it typically goes - YouTube
I've been trying to tune the PID parameters for hours but I can get anything even remotely stable. I'm starting to think the problem my be in the inherent sloppiness of the printed gears. I'm also worried that the motor may not have enough torque either and I'm thinking I should get buy a geared motor.
I suggest you do some tests to see if the torque is sufficient. If you lean the robot against a wall at some angle off the vertical and then apply full power to the motor to try to make it overbalance the other way, how far off the vertical can the initial tilt be before the torque is insufficient to move it to the vertical?
For the PID controller, I think you will need the I term at or close to zero to avoid oscillation, because the robot mechanics already provide an integral term. So set I to zero and concentrate on P and D.
Thanks. I tried that and it does seem like the motor is very under powered. Especially since I'm running it off an external 12V supply. The extra weight of the battery pack will probably make it useless.
The extra weight of the battery pack will probably make it useless.
Use large wheels with the heavy batterys below the centerline of the wheel's axel and the bot might balance itself without any help.