LESSON 25. SERVO MOTORS

2.1 Introduction

A servo motor is a dc, ac, or brushless dc motor combined with a position sensing device (e.g. a digital decoder). In this section, our discussion will be focused on the three-wire DC servo motors that are often used for controlling surfaces on model airplanes. A three-wire DC servo motor incorporates a DC motor, a gear train, limit stops beyond which the shaft cannot turn, a potentiometer for position feedback, and an integrated circuit for position control Of the three wires protruding from the motor casig, one is for power, one is for ground, and one is a control input where a pulse-width signals to what position the motor should servo. As long as the coded signal exists on the input line, the servo will maintain the angular position of the shaft. As the coded signal changes, the angular position of the shaft changes.

Servos are extremely useful in robotics. The motors are small and are extremely powerful for their size. A standard servo such as the Futaba S-148 has 42 oz/inches of torque, which is pretty strong for its size. It also draws power proportional to the mechanical load. A lightly loaded servo, therefore, doesn't consume much energy. The guts of a servo motor are shown in the picture below. You can see the control circuitry, the motor, a set of gears, and the case. You can also see the 3 wires that connect to the outside world. One is for power (+5volts), ground, and the white wire is the control wire.

How does a servo work?

So, how does a servo work? The servo motor has some control circuits and a potentiometer (a variable resistor, aka pot) that is connected to the output shaft. The potentiometer allows the control circuitry to monitor the current angle of the servo motor. If the shaft is at the correct angle, then the motor shuts off. If the circuit finds that the angle is not correct, it will turn the motor the correct direction until the angle is correct. The output shaft of the servo is capable of travelling somewhere around 180 degrees. Usually, its somewhere in the 210 degree range, but it varies by manufacturer. A normal servo is used to control an angular motion of between 0 and 180 degrees. A normal servo is mechanically not capable of turning any farther due to a mechanical stop built on to the main output gear. The amount of power applied to the motor is proportional to the distance it needs to travel. So, if the shaft needs to turn a large distance, the motor will run at full speed. If it needs to turn only a small amount, the motor will run at a slower speed. This is called proportional control. How do you communicate the angle at which the servo should turn? The control wire is used to communicate the angle. The angle is determined by the duration of a pulse that is applied to the control wire. This is called Pulse Coded Modulation. The servo expects to see a pulse every 20 milliseconds (.02 seconds). The length of the pulse will determine how far the motor turns. A 1.5 millisecond pulse, for example, will make the motor turn to the 90 degree position (often called the neutral position). If the pulse is shorter than 1.5 ms, then the motor will turn the shaft to closer to 0 degress. If the pulse is longer than 1.5ms, the shaft turns closer to 180 degrees.

L 25 fig.1

As you can see in the picture, the duration of the pulse dictates the angle of the output shaft (shown as the green circle with the arrow). Note that the times here are illustrative, and the actual timings depend on the motor manufacturer. The principle, however, is the same.

2.2 Modifying a Servo Motor

As mentioned in the previous section, the servo motor rotates less than 360 degrees. They can, however, be modified into continuously revolvable DC gearhead motors to drive robots' wheels. The changes are quite easy to do, if you follow the instructions in this section.

The theory behind this modification is to make the servo think that the output shaft is always at the 90 degree mark. This is done by removing the feedback sensor, and replacing it with an equivalent circuit that creates the same readings as the sensor being at 90 degrees. Thus, giving it the signal for degrees less than 90 degrees will cause the motor to tuen on full speed in one direction. The signal for degrees greater than 90 degrees will cause the motor to go the other direction. Since the feedback from the output is disconnected, the servo will continue in he appropriate direction as long as the signal remains.

The result of this is a really nice compact gearhead motor with built in electronics. The interface to this motor unit is a 1 wire control line, +5 volts for pwer, and a ground. As for the details, there are actually only two modifications to make to the servo,

  1. Replace the position sensing potentiometer with an equivalent resistor network

  2. Remove the mechanical stop from the output shaft

You will need a few supplies to do the modifications:

  1. small philips screw driver for opening the case

  2. a soldering iron

  3. a desoldering pump or solder wick for removing the potentiometer

  4. a sharp knife or wire cutters for removing the mechanical stop

  5. Two 2.2k resistors (actually, anything between 2.2k and 3.3k will work, as long as they are equal values)

Here are the steps for the modifications.

1. Open the case by removing the 4 screws located at the bottom of the servo. The bottom plate should come off easily. Remove the top of the case. You will find a set of gears under the top case, a several blobs of white grease. Try hard to save the grease by increasing it on the gears.

2. Be careful to note how the gears arranged, and remove them from the top of the servo. You can place them as they are supposed to sit. The large fine tooth gear in the middle does not need to be removed.

3. Locate and remove the two small philips head screws on the the case near one of the shafts. These screws go through the top case and into the drive motor..

4. Next, you need to remove the circuit board carefully from the case (Beware not to break the connecting wires when you do this). Very carefully pry ip on opposing corners of the circuit board. (You can probably use a screwdriver to help you to do this.) The board should slide out with the motor and potentiometer attached.

5. Now for the actual modifications. First, you will nedd to desolder the potentiometer from the board.

6. Once the pot has been removed, you need to wire in the resistor network in its place. To do this, place the resistors side bt side and twist one pair of leads. Solder them together, but leave one of the leads long enough to make a 3 wire part. Then replace the pot with this 3 wire pot.

7. Now, reassemble the circuit board into the case.

8. Before reinstalling the gears, you will need to modify the gear with the output shaft so that the mechanical stop is removed. The mechanical stop is a small tab of plastic on the lower gear surface. This should be cut down flush with the surface by using a wire cutter or a sharp knife. Try to get all the tab removed.You should also remove the little plastic ring on the motor shaft as well.

9. Replace the gears as they were when you took the motor apart, replace the top of the case, the bottom plate, and the two screws.

The motor should now be able to turn all the way around.

2.3 Driving the Servo Motor

Driving the servo motor using a function generator

A three-wire DC has three input wires: the red wire is usually connected to the power supply, the black wire is usually connected to the ground and the white/yellow wire is usually connected to the controlling signal. One of the simplest way to test/drive a servo motor is to generatea pulse using a function generator. The pulse can be be generated using the square wave function of the function generator. For the servo motor that we are using, Tower Hobbies STD BB TS-69., the power supply is about 4.8 volts and so we can generate a square wave using the TTL output of the function generator. You should adjust the amplitude of the square wave such that it matches the power supply of the servo motor.

Once you have adjusted the amplitude of the square wave pulse, you can adjust the width of the pulse train by adjusting the frequency of the signal. For the servo motor that we are using, the neutral point (the pulse width at which the servo stays at 90 degrees) is about 1520 microseconds(us) or 1.52ms. Any pulse width narrower than 1.52 ms will cause the servo to move to a position less than 90 degrees and vice versa. Note that servo only turns between 0 and 180 degrees if it is not modified. This corresponds to about 0.8ms to 2.5ms of pulse width. Make ensure the pulse width that you use is in within this range.

For a servo motor modified to rotate continuously, the servo will not turn at the neutral pulse width but it will turn clockwise continuously if the pulse width is less than the neutral pulse width and anticlockwise if the pulse width is larger than the neutral pulse width. (the pulse width has to be within the range mentioned above).

Driving the servo motor using the Handy Board

For most applications, it is impossible to drive the servo motor using the function generator. One of the most convenient way to drive the servo motors is to use the Handy Board. The Interactive C has a library routine that allows control of a single servo motor, using digital input 9, which is actually the 68HC11's Port A bit 7 (PA7), a bidirectional control pin. This library routine can be loaded onto the Handy Board by loading the binary file, servo.icb, first and then the file servo.c (this means the file where you write your own C program cannot be named as servo.c!).

Here are the library functions used to control the servo motor:

void servo_on( ) : Enables PA7 servo output waveform.
void servo_off( ) : Disables PA7 servo output waveform.

int servo(int period) : Sets length of servo control pulse. Value is the time in half-microseconds of the positive portion of a rectangular wave that is generated on the PA7 pin for use in controlling a servo motor. Minimum allowable value is 1400(i.e. 0.7ms); maximum is 4860 (2.43ms). The return value of the the function is the actual period set by the driver software. When the servo motor is not modified, the value of period is about 2950 at the neutral point. When the servo motor is modified, the value of period is about 2570 at the neutral point.

int servo_rad(float angle) : Sets servo angle in radians.

int servo_deg(float angle) : Sets servo angle in degrees.

2.4 Sample programs

The following code fragments illustrates how to use the above library functions to drive the servo motor:

float period=70.0; 
int k; 
servo_on(); 
while(1){ 
k = servo_deg(period);    
printf("angle is %d\n", k); 
} 

The above code fragment sets the servo motor into 70 degrees and display the current position on the LCD display (in terms of microseconds of the pulse).If the servo motor is modified to rotate continuosly, the above code fragment cause the servo to rotate in clockwise direction continuously.

int period=1400.0;
int k; servo_on();
while(1){ 
k = servo(period);
printf("period is %d\n", k);
period = period + 100;
} 

The above code fragment will cause an unmodified servo motor to turn in small increments until the mechanical stop is reached. The motor should start again from the 0 degree position sometime after the maximum allowable value of the 'period' is exceeded. The code will cause a modified motor to turn clockwise and anticlockwise alternatively. The value of the period is less than the neutral value at first, so the motor will turn in the clockwise direction. After the neutral value is exceeded, the motor will turn anticlockwise. After the maximum allowable value of the period is exceeded, the value of the period will start from 1400 again and thus it will turn clockwise once again. This can be observed by looking at the LCD display.

 

References http://mechatronics.mech.northwestern.edu/design_ref/actuators/servo_motor_drive.html

Last modified: Friday, 28 March 2014, 6:54 AM