![]() |
DC Motors Continuous DC motors have been successfully used in many MicroMouse robots. Motors of every shape and size can be found in the surplus market, in toys and in old electronic gadgets.
Gear Reduction Escap Gearhead Motor Dc motors tend to spin too quickly and do not have enough torque to drive the robot wheels directly so some kind of gear reduction will have to be used. The gears both slow down the speed and increase the torque of the output shaft. This gearbox can be created out of individual gears or it can be part of the motor as in the Escap motor pictured above. By knowing the output shaft's speed (RPM) and the diameter of the wheel you will be using, you can get an idea of how fast your mouse will be traveling through the maze.
Encoder Wheels
Paper Encoder Wheel Another necessity when using DC motors is an encoder disk on the robot's drive shaft. This shaft encoder provides a pulse train that can be counted and allows the microcontroller to determine how far the robot has traveled and how fast the wheels are spinning. The encoder wheel can be a solid disk with alternating black and white stripes like the one shown above. An IR light source is aimed at the disk. As the wheel spins, the black stripes absorb the light while the white stripes reflect the light back to a phototransistor. The wheel can also be a disk with slots cut into it like those found in computer mice. In this case, the IR light source is on one side of the disk and the phototransistor is on the other side of the disk. In both cases the phototransistor converts the pulses of light into a signal that is sent back to the microcontroller to be counted. Wiring the encoder wheel sensor is similar to wiring the wall proximity sensors.
Driving DC Motors
The Basic DC Motor Circuit Getting a DC motor to spin is as simple as connecting it to a battery (being careful not to exceed the motor's voltage rating). Reversing the polarity of the motor connections results in the motor spinning backwards. Lowering the voltage applied to the motor slows it down.
H-Bridge To reverse the direction of the motor without rewiring requires a circuit known as an "H-bridge" (notice how the circuit around the motor is in the shape of the letter H.
Forward Closing switches A and D results in the motor spinning forward.
Backward Closing switches B and C results in the motor spinning backward.
Braking Once the motor is up to speed, closing switches A and C disconnects the battery from the motor and shorts the terminals of the motor. This produces a braking effect in DC motors.
Don't Short the Battery!! It is also easy to short out the battery by closing switches A and B or closing switches C and D. Be very careful not to do that!!
An H-Bridge With Transistors To allow the microcontroller to control the H-Bridge, the mechanical switches can be replaced with transistors. Note the use of flyback diodes in the circuit. The winding in the motor is essentially an inductor. When the flow of current in an inductor is suddenly cut off, the current cannot suddenly go to 0. As a result, a voltage is induced opposing this current. This voltage can be so high that it destroys the transistors. The flyback diodes provide a safe return path for this current that bypasses and protects the transistors. The H-bridge can be made out of discrete transistors or it can be purchased as an integrated circuit. Using IC's will help keep the MicroMouse small, and the internal logic prevents the battery from being shorted out as described above. When choosing one of these IC H-bridges, the data sheets should be examined carefully. Some contain internal flyback diodes and some require the designer to add external diodes. Here are some popular chips: Model: L293D Model: L298 Model: SN754410NE Model: LMD18200
Speed Control Applying full power to the motor causes it to spin at top speed and removing power causes the motor to stop spinning. The H-bridge discussed above is capable of these two states. In order to get the motor to spin at lower speeds, a technique known as Pulse Width Modulation (PWM) can be used.
Pulse Width Modulation PWM is an efficient way for digital circuits to simulate a range of analog values. By rapidly switching between full power and no power, an average value somewhere in between can be simulated. Three signals are shown in the figure above. All three signals share the same frequency, but the width of the pulses are different. By varying the duration of the "on" time, the motor can be made to "see" an average value anywhere between 0V and V+. As for the frequency of this signal, anything above 10khz should be good. If you hear a high pitched whining coming from your motors then you might want to use a frequency above human hearing, say 20khz or 25khz.
Summary
Start with a good quality motor, preferably with the gearbox already attached to it. Use an H-bridge to provide power to the motor, and have the microcontroller use pulse width modulation to vary the speed of the motor. Place encoders on the drive wheels so that the microcontroller knows the actual speed of the MicroMouse and can make any necessary adjustments to the speed of the motors. |