M a r k   C r o s b i e

You are in: LEGO Differential Drive  Home  Resume  Linux  LEGO  Electronics  Movies  Mac OS X 


Please update your bookmarks..

Go to my new LEGO website

http://mastincrosbie.com/Marks_LEGO_projects

LEGO Differential Drive

Keeping a robot driving in a straight line is not as simple as it sounds. The basic LEGO motors vary greatly in speed even when driven from the same RCX output. As the bearings get worn down each motor will rotate at a different velocity. If a robot is crossing rough terrain the drive wheels will probably be rotating at different speeds. All of these factors need to be taken into account by the driver code and the speed of the motors may have to be adjusted accordingly.

The first issue is: how do I know what the difference in the motor rotational speed is? So far I have tried two different approaches:
  • Use a differential between the two wheel axles to measure the difference in rotation between two wheels. The differential approach is described widely on the net. It has the advantage of only requiring one sensor input, but suffers from the inherent slip in LEGO gearing.
  • Use a rotation sensor on each drive axle to directly measure. The advantage of this approach is a reduction in the measurement error from slippage in the LEGO gear train. The obvious disadvantage is that it requires two sensor inputs.


Using two rotation sensors

Two rotation sensors My first try at this problem was to use a rotation sensor per drive axle. I built on my stall sensor ideas and used rubber bands to give a smooth drive from the motor to the wheels.

Final robot I geared the motor down by using a small and larger drive pulley. The rotation sensor is situated directly above the drive axle and two 16 tooth gears connect the two. A picture of the robot is on the left.

Using a differential

Another approach to solving this problem is to use a LEGO differential in reverse. Usually the differential is driven by a motor and the power is directed to the drive wheels. Reversing the process we can send the drive power into the differential, and then measure how much it rotates. If there is a difference in the rotational velocity of the drive axles, the differential will rotate by a corresponding amount.

Differential The differential is built as shown to the right. The gearing is designed to mate it to the robot chassis I built. The motor drive goes to the pulleys on the outside of the mechanism. It was simplest to mount the motors facing outwards and have the diferential mounted between the wheels.

Differential from above Differential from above Looking from above, these pictures show the differential attached to the motors. The drive to the wheels comes out on axles below the outer pulleys. The motors tip the balance point of the robot away from the wheels, so I had to install the two runner feet that you can see to the right of the picture.

I built this robot and mounted the RCX on top. The program I wrote for legOS would track the rotation of the rotation sensor and adjust the speed of the motors accordingly. You can download the source code and try it for yourself.

Experiences to date

LEGO differential: I found that while the solution using the LEGO differential was easier to build, it gave very poor results. Maybe this was a result of a poorly constructed gear train. In tests the rotation sensor had an absolute error of +/- 1 pulse. As expected, the code scaled back the power on one of the motors. However, the robot started to drift to the left and the rotation sensor never generated another pulse to correct the drift. More experiments are planned...

Two rotation sensors: I wrote some code to do the power correction for the motors, and it still does not work! I realized that Jones and Flynn's excellent book on mobile robots had code for proportional feedback control of motors in Chapter 7. Their code is written for the Handyboard and receives a different input from its rotation sensor than the RCX. You can download my attempt at a solution. I'll return to work on it soon.


 
cover
Building Robots With Lego Mindstorms
Mario has written an excellent book on advanced building techniques using Mindstorms.
cover
Extreme Mindstorms: an Advanced Guide to LEGO Mindstorms
A more advanced programming guide: covers BrickOS and pbForth and NQC.
cover
Dave Baum's Definitive Guide to LEGO Mindstorms
One of the first good LEGO Mindstorms books. Well worth a read.
cover
Joe Nagata's Lego Mindstorms Idea Book
Wow - someday I want to be able to build LEGO like this!
cover
LEGO Mindstorms Interfacing
How to interface your RCX to the outside world with sensors and actuators.

© 2002-2004 Mark Crosbie   shareright © 2002 Phlash