home quienes somos contacto industria educación
home > educacion > clientes
 

 

 

 

   

Self-Balancing Robot

This project was submitted to Parallax by Juan Pablo Angulo (founder of the Microbotica Robotics Society in Mexico City)

This inverted-pendulum robot monitors its angular position in regard to the floor and commands two DC motors to rotate in the proper direction and speed in order to maintain balance.

The main issues addressed in this project were:

 - Robot Tilt Feedback Sensor
 - Motor Speed and Direction Control
 - Programming Control Law that stabilizes the robot.

Feedback Sensor
In order to balance itself, this robot requires feedback from a sensor that will indicate the angle formed by the robot and the floor (tilt sensor). This problem is sometimes addressed using expensive piezogyros in conjunction with accelerometers which will need the use of Kalman filters in order to provide a noise free reading. However, this is not only expensive but it also requires large amounts of data to be processed and complex computing.

For this project I developed a cheaper and simpler solution, using BASIC Stamp® microcontroller's RCTIME function along with an infrared LED and Infrared phototransistor I was able to take a reading of the amount of infrared light being reflected from a surface. By offsetting this sensor a couple of inches from the axle of rotation and pointing it towards the floor, it senses the amount of reflected light, which will increase or decrease as a function of the angle in question. Feedback part is now solved.

Motor Control
DC motors were used to drive the robot’s wheels; direction and speed needed to be controlled, therefore I used a Motor Mind C motor controller, to which the BASIC Stamp module communicates through a serial link at 38.4 kbps! The Motor Mind Controller is perfect for the job since it takes care of the PWM for driving the DC motors, the BASIC Stamp microcontroller only sends the instruction and the MMC takes care of the rest; thanks to MMC’s high speed communication (38.4 kbps), sending data to it only takes a few mSec, so the BASIC Stamp module can go back to more important business. The DC motors were fixed to a BiANGLE Tech carrier board which is used as a structure for the robot, as a carrier board for de BASIC Stamp Microcontroller, and its large protoboard area is used to host both the robot tilt circuitry and the Motor Mind C integrated circuit. Now we have a working pair of wheels commanded by our BASIC Stamp microcontroller and mounted on a chassis.

Control Law
In order to make this robot work, it was needed to integrate both sensors and actuators together, this was done through the BASIC Stamp Microcontroller. Processing speed is crucial for this robot since it can fall down or become unstable in just a fraction of a second, this is the reason why BASIC Stamp 2p module is more fit for the job than any other Stamp, later I found out that a BS2 also works, but the robot wobbles a bit and is more unstable, you can use either. The task of the microcontroller is fairly simple: monitor the tilt sensor, calculate the error between desired tilt and actual tilt, if the error is zero do nothing, otherwise, command the motor controller to drive the motors in the proper direction, at a speed that is proportional to the error; this is called a “Proportional control law” and the robot will stabilize with it. More programming led to a Proportional Derivative Integral or PID control law, which makes the robot even more stable. Parallax’s Industrial Control tutorial provides a clear explanation on how to program a PID Control law and how it works.

Facts about my robot
Because the BS2p Microcontroller can process 12,000 instructions per second, and most of my program is composed of pretty simple tasks, it takes only a few milliseconds to go through the whole process of sensing, computing and commanding motors, therefore the sensor can be monitored and motors commanded some 800 times per second, making the robot pretty stable!  This Robot is powered by 6 AA Batteries which also serve as the inverted pendulum’s mass. Attaching some sort of protection in case the robot does become unstable and fall is a clever thing to do, and so it is programming the robot to stop trying to balance itself once it has reached a certain angle of tilt, at which it is impossible to recover balance.

Future of the project
In the future I’d like to be able to program a more complex control law, maybe try to implement a Fuzzy PID control on the BASIC Stamp microcontroller and see how well it works in comparison to the conventional PID. Following a line and remote control are also on my list of things I want my robot to be able to do.

I’d like to thank Parallax for developing such a powerful and easy-to-program microcontroller with as many possibilities as one can find for it.

 

 

 

   
 |  |  | |  |  |
RAMBAL Automatización Industrial y Robótica es líder desde el año 1996 , esta ubicado en avenida Francisco Bilbao #351, Providencia, Santiago - Chile