Two Wheel Dynamic Balancing Robot
this is where the fun begins.
If you fuse both sensor readings together, you can get a
“filtered” output with a very precise value for the actual tilt
angle. Several filters are used in this type of application to
“de-drift” and “de-bias” the gyros and co-sensors; they also
optimize the fusing. One of the most common, well documented
types is the Kalman filter, which uses a model of the sensors
and a least squares function — among other calculations — to
“guess” what the closest value to the true angle is.
A lot of material is written about this filter and it is
used in a vast number of applications. A great deal of documentation exists online and many books are available about
this filtering method. To be completely honest with you, at
this point, I don’t fully understand it. What I did in my robot
as a temporary solution was to use the gyro integral for the
current angle and the long term average of the accelerometer
to de-drift the gyro. To the best of my knowledge, this idea
was first proposed by Trevor Blackwell and it works very
nicely, but right now I am working hard to implement a fully
“optimized” Kalman filter to get the actual angle.
The filter I used is more than enough to make your robot
balance on two wheels for a long, long time, but, like I said
earlier, precision and smoothness is what matters in this
project. Other filtering methods I have heard of are based on
fuzzy logic and — most likely — neural networks; however, I
don’t really know how they are implemented, in practice.
The filter implemented in my code is very stable, but it gets
a bit jerky when used to hover the robot in a fixed place;
sometimes this is minor and unnoticed.
I am not going to go into much detail on the physics
behind the sensors, since space is limited and I want to
provide as much information as possible.
The IMU sensors I used are coupled together in a board.
I used one by Rotomotion; I only used their sensor interface
boards, which are primarily made with one analog device
(ADXL202). I also used a MEMs accelerometer and an
NEC-Tokin (CG-16DO) ceramic rate gyroscope, both of which
are filtered and amplified to provide a clean reading.
Note: The hardware filter provided with the Rotomotion
board is not a Kalman filter. It is an analog, low pass filter
and amplifier (opamp) designed to reduce noise from the
sensors and scale the gains. You will still have to make your
filter via software to get a good angle estimate.
PWM Module, Motors, and
You will need to have enough power to compensate for
quick changes in angle, so choose a PWM drive and a set of
motors that will give you more than enough power to
balance the robot. Keep in mind that less weight is better, so
make a good balance with these factors. Whether you design
your own module or get a specialized one for this, make sure
that you will have sufficient power to work with.
Mine is made by Roboteq (see Parts List for details) and,
in my case, it is commanded by an RS-232 port from my
Figure 3. A physical model with definitions.
MCU, but an analog source is more likely to do a better,
cleaner, and quicker job. The Roboteq module has the
benefit of a wide variety of options for controlling it and it
has a lot of spare power for the application. The typical
application for the Roboteq module is for combat robots,
but, if you are a hobbyist planning to build large bots, this is
a great investment to have in your shop. If you are making a
small robot, this driver might be too much. (If you are
making a huge, ultra, mega big bot, this might not be
enough!) The point is that you will need to choose the right
type of PWM and motors to successfully counteract the real
world physics applied to your robot.
The motors, wheels, and hubs in my project are provided
by NPC Robotics and are made primarily for electric wheelchairs. (See Parts List for details.)
Batteries play a very important role. Your batteries are the
heart of your project and they need to support whatever power
is sourced by the PWM unit, so make your numbers work before
you start implementing PWM, motors, and batteries.
The wheels are also important, but they are not critical,
BasicX MCU BX- 24 ( www.basicx.com)
Rotomotion Z “sensor only” board (2 DOF)
7.2 VDC 3,000 mAh NiMH from R/C cars
Motors by NPC Robotics ( www.npcrobotics.com)
AX2550 Dual PWM module by Roboteq
Note: The batteries were hooked up five in series and then in
parallel with four more banks of serial batteries using a bridge
rectifier between banks to prevent them from discharging each
other when they don’t have the same balance in charge.
SERVO 07.2004 29