The bipolar amplifier is well suited for controlling motors for vehicle propulsion. Figure 12-45 shows a good-sized 24VDC motor that runs nicely on 13.8V from a lead acid battery based power supply. You usually don t need the high speed of a DC motor, so it s better to buy motors with built-in gear reduction, called gear head motors, because they already have lower speed and higher torque. However, you can lower the ratio externally with drive belts where the smaller pulley, such as the one in Figure 12-45, is on the motor, and the larger one is on the axle connected to the wheel. Figure 12-45. Bipolar amplifier connected to a large DC motor RC Servo Interface RC Servos were originally intended for operating the flight surfaces of radio-controlled model airplanes, but have found a new home in robotics. They contain a highly-geared-down DC motor and a shaft feedback circuit that allows accurate position control over a 180-degree range of motion. Control comes in the form of a series of pulses (illustrated in Figure 12-46). The control pulse width varies from 1ms for 0 degrees to 2ms for 180 degrees. Some Servos can rotate beyond this range, but one standard among the many available Servos is that a 1.5ms pulse will place the shaft at its midpoint. 222
1.0 ms 15 ms 0 90 1.5 ms 15 ms 2.0 ms 15 ms 180 Pulse Width Servo Position Figure 12-46. Pulse width and shaft angle Unfortunately, the output of the NXT can t be used to directly create the control pulses for a couple of reasons: the voltage is too high, and you can t generate pulses as short as a few ms. However, you can make a little interface circuit that will generate the proper size pulses and use the NXT output to control the width of those pulses. The heart of the interface circuit is the LTC555 CMOS timer (see Figure 12-47). Pin 1 White NXT Pin 2 Black R1 R2 R3 D1 R4 D2 C1 C2 8 U1 VCC 2 4 TRIGGER 3 5 RESET OUTPUT 6 CONTROL 7 THRESHOLD DISCHARGE GND 1 + 6Vdc Servo Red Servo Yellow or White Servo Black Figure 12-47. RC Servo interface circuit Resistors R3 and R4, along with capacitor C2 and diode D1, determine the pulse width and the time between pulses. Resistor R1 and Zener diode D2 guarantee that the PWM output level of the NXT is limited to 5V, while resistor R2 and capacitor C1 smooth out the NXT PWM to a DC level. The plot in Figure 12-48 shows how the power level is related to the DC level. This DC level is fed into the control input of the TLC555 to vary the Servo pulse width. The Servo also needs its own 6V power supply, which can be easily provided by batteries. 223
Tip It is a good idea to include an on/off switch to turn off power to the Servo when it is not in use. 5 4 Voltage 3 2 1 0 0 20 40 60 80 100 Power Figure 12-48. Plot of output power vs control voltage Figure 12-49 shows the RC Servo interface built on a solderless breadboard. The complete bill of materials for the circuit is in Table 12-6, along with the step-by-step instructions in Table 12-7. With the component values listed, the interface will produce pulses shorter than 1ms for an output power level of 0 and longer than 2ms for a level of 100. An output power level of about 50 will be close to the 1.5ms (90- degree) center point. Connectors for Servos are available from the same suppliers as the Servos themselves. 224
Figure 12-49. RC Servo interface on solderless breadboard Table 12-6. Bill of Materials Component Part Number Description Radio Shack R1 1K Ohm 1/4 W Resistor 271-312 R2 47K Ohm 1/4 W Resistor See R1 R3 10K Ohm 1/4 W Resistor See R1 R4 100K Ohm 1/4 W Resistor See R1 C1 0.1uF Metal Film or Ceramic 272-135 C2 0.22uF Metal Film or Ceramic 272-1070 U1 TLC555 CMOS Timer 276-1718 D1 1N4148 Small Signal Diode 276-1122 D2 1N4733 5.1V Zener Diode 276-563 225
Table 12-7. Component Placement Component Start End U1 pin 1 F3 D2 anode cathode Y2 E2 J1 Y3 J3 C2 Y4 J4 J2 Y7 J7 J3 F7 E7 J4 D3 G6 J5 G4 D5 R1 X2 A2 R2 B2 B6 R3 C3 D4 R4 C4 C5 C1 C6 C7 D1 anode cathode A4 A5 Servo White or Yellow I5 Servo Red Black I6 I7 6V Red Black J6 Y5 NXT White Black X1 Y1 The completed RC Servo and interface can be seen in Figure 12-50. The little 6V battery box conveniently included an on/off switch. The NXT-G output control program from earlier in this chapter is perfect for exploring the operation of the RC Servo. At first, with the output power at 0, the Servo should rotate fully counterclockwise. As you increase the power level, the Servo will start to move clockwise. Eventually the Servo will stop moving when the power level approaches 100. 226
Caution It is generally not a good idea to drive the Servo beyond its normal range of motion (for my Servos, it relates to power levels from 20 to 80). Figure 12-50. Completed RC Servo interface 227