Hobby Servo Fundamentals - Sawicz

11
HOBBY HOBBY HOBBY HOBBY SERVO SERVO SERVO SERVO FUNDAMENTALS FUNDAMENTALS FUNDAMENTALS FUNDAMENTALS BY: DARREN SAWICZ

Transcript of Hobby Servo Fundamentals - Sawicz

Page 1: Hobby Servo Fundamentals - Sawicz

HOBBYHOBBYHOBBYHOBBYSERVOSERVOSERVOSERVO

FUNDAMENTALSFUNDAMENTALSFUNDAMENTALSFUNDAMENTALSBY: DARREN SAWICZ

Page 2: Hobby Servo Fundamentals - Sawicz

IN T ROD U CT I O N

obby servos are a popular andinexpensive method of motion

control. They provide an off-the-shelfsolution for most of the R/C androbotic hobbyist's needs. Hobbyservos eliminate the need to customdesign a control system for eachapplication. Without hobby servos(hereafter referred to only as servos)you would have to:

• design a control system• analyze the transient response• fine tune the feedback loop• determine the proper gear ratio for the

desired speed or effi ciency• choose a motor• build the mechanical sections• build the amplifier and motor driver• try to make it fit inside what ever you're

trying to control!

Although servos are very common,technical information is hard to comeby. A search of the Internet will bringup bits and pieces but it is hard tolocate a single source for all theinformation. In this document I willattempt to provide all the informationyou would need to hack a servo ormake your own.

S ER VO BAS I CS

hroughout this document I will beusing the Tower Hobbies TS-53

servo to describe how servos work.Other servos may be a different sizeor have metal gears or bearings butthe basic concept of operation is thesame.

Since the early 1990's servos haveused a de-facto standard pulse widthmodulation technique to control theposition of the output shaft. The

pulse is fed to the servo via a controlline. The control line does not supplypower to the motor directly it is aninput to a control chip inside theservo and as such it does not haveto supply much current to the servo.Consequently if you are designing aservo controller you may use justabout any technology (CMOS, TTL,Discreet Components) to drive thecontrol line.

Aseparatepowerwiresuppliesthepower to

theservo.Thegroundforpower isalsoused asthegroundfor thecontrolline.

Althoughthere areonlythreewires,

manufacturers haven't standardizedthe pinouts. Most connectors arewired the same but there are

H

T

Page 3: Hobby Servo Fundamentals - Sawicz

FIGURE 1: SERVO CONTROL TIMING

1ms (MinimumRequired Time)

The servo is positioned to the extremeleft.

2ms

The servo ispositioned to the

extreme right.

1.5ms

The servo is centered.

exceptions like the Airtronicsconnector where the power andground wire is reversed. Connectinga servo that is wired incorrectly canblow your servo or fry the receiver orboth.

Most servos can be rewired simplyby lifting the plastic tab holding thepin into the connector, pulling the pinout the back, and reinserting the pinsin the proper place.

The power wire carries the majorityof the current to the motor. Thecurrent varies from almost nothing(9.6mA for the TS-53) when theservo isn't receiving any controlsignals, to a maximum current whenthe servo is fully loaded (600mA for

the TS-53).

The receiver regulates the voltageon the power wire when it is usedwith R/C equipment. The servos donot get the full voltage of the batterypack. Applying more than 5 Volts tothe servos can damage them.

Page 4: Hobby Servo Fundamentals - Sawicz

If you were trying to implementthe timing from amicrocontroller you could use aregister to hold a 0 to 100%PWM signal and tack it on tothe end of a 1ms-delay routine

E LE CT RI C AL SI GN A LS

At first glance the electrical signalsused to control servos seem overlycomplex. When you consider thatone signal line is presenting theservo with digital direction andproportion information you start tosee the elegance of the solution.

This elegance comes at a price forthe poor hobbyist with little or nobackground in electronics. You can'tjust hook it up to a battery and watchit go (unless you modify the servo todo just that). There are howevercircuits which allow you to control aservo without using a receiver. Letslook at the signal we need togenerate.

The voltage on the control lineshould be 0 Volts for a low signal(logic 0) and 5 Volts for a high signal(logic 1). The voltage to the controlline should be applied through a 10kresistor to limit the current in casesomething fries.

In FIGURE 1 you can see the timingrelationship between the pulse widthand servo position.

The servo's control logic needs tosee at least a one millisecond pulsebefore the actual pulse widthmodulated (PWM) signal.

The control part of the signal isbroken down into the 1ms minimumtime, the 1ms PWM signal, and aroughly 40ms delay. This delay is notas critical as the other parts of thetiming signal. It is essentially thedead time between control signals. Ifyou repeat the control signals tooquickly (i.e. 10ms delay) the servowill buzz and jitter. If you repeat thecontrol signals too slow (i.e. 70msdelay) the servo will shut off betweensignals and its position will notremain constant.

In the case of R/C equipment thisdead time is used by the transmitterto transmit the other channels. If thechannels were placed back-to-backthere would be enough room forapproximately 20 channels beforeyou would have to transmit the firstchannel again.

The receiver demultiplexes thereceived pulses and puts one pulseon each output. The rising edge ofeach pulse is the start of a newchannel.

It is important to note that the"channels" of a two or four, etc.channel transmitter, are notseparated by frequency like radio orTV stations (Frequency DivisionMultiplexed), they are pulses on thesame radio channel separated onlyby time (Time Division Multiplexed).The only way you can change theradio channel you are on is toreplace the crystal.

If you are designing a multi-channelcontroller you will soon discover thatbecause the PWM portion of thesignal is variable you will have a

Page 5: Hobby Servo Fundamentals - Sawicz

NOTE: If you are custom buildinga wireless transmitter the ≈40mSrepeat time is required to complywith FCC and DOC bandwidthlimitations. The sidebandsgenerated by the FM modulationcannot extend into adjacentchannels.

variable length delay time. Forexample:

You design an eight-channel controller.The fixed time component is 1ms x 8channels = 8ms. The variable PWMsignal can vary between 0ms x 8channels = 0ms when they are all fullycounter clockwise, to 1ms x 8 channels= 8ms when they are all fullyclockwise. This adds up to between 8msand 16ms depending on the positions ofthe servos.

If you were trying to have a constantrepetition rate of 40ms you wouldneed to change the dead timeaccordingly. With a microcontrolleryou could add up all the constanttime plus all the variable time andsubtract it from 40ms to calculate thedead time. This takes time and usesup the microcontroller's resourcesneedlessly. The dead time is notwritten in stone. It does not have tobe the same each time.

S ER VO CIR CU IT S

Servos have their own proprietarycircuitry built inside the servo case.This circuitry consists of a pulsewidth comparator, which comparesthe incoming signal from the receiverwith a one-shot timer whose perioddepends on the resistance of apotentiometer connected to theservo's drive shaft. This feedback iswhat provides the stability for thecontrol circuitry. The differencebetween the control signal and thefeedback signal is the error signal.This error signal is used to control aflip-flop that toggles the direction thecurrent flows through the motor. Theoutputs of the flip-flop drive an H-Bridge circuit that handles the highcurrent going through the motor.

If you were going to try to build acircuit to take a PWM signal andconvert it to a motor position, you'dprobably end up with a fairly largecircuit. A microcontroller would dothe job but if you can't programyou're back to square one.

Page 6: Hobby Servo Fundamentals - Sawicz

Thankfully there is a chip availablewhich does the work for you. TheM51660L servo motor control chipfrom Mitsubishi contains all theelectronics needed to decode thesignal and control a motor.

All you supply are two PNPtransistors for the upper half of theH-bridge and a handful of resistorsand capacitors. A complete circuit isgiven on the second last page oftheir data sheet:

BLOCK DIAGRAM

11

13

91 2 3

8714

Supply(4.8V)

GND

5InputControl logic circuit

Flip-flop

4

6

10

12

Output drivecircuit

Stretcher input

Error pulse output

Timing capacitance

Servo position voltage input

One-shot multivibrator

Pulse stretcher

Voltage regulatingcircuit

External PNP transistor drive (1)

Output (1)

Output (2)

External PNP transistor drive (2)

Regulated voltage output

VCC

Timing

APPLICATION EXAMPLE

Servo motor control circuit for radio-controlled

14

13119531

12108642

M

VCC

10µ2SA6952SA695

0.1µ

560k

M51660L

7

180k

0.1µ 2.2µ

5k

1k

0.03

µ

Input

0.1µ 18k

UnitResistanceCapacitance

: Ω

Page 7: Hobby Servo Fundamentals - Sawicz

If you don't have a radio transmitterand receiver handy you won't haveany way of generating the controlsignal for the servo. A simple circuitusing a 555 timer chip can generatethe needed signal.

The equations for the 555 timer aresimple and easy to use. They are asfollows:

THIGH = 0.693(R1 + R2)C

TLOW = 0.693(R3)C

Since R2 is variable the time thesignal is high will vary from:

0.693(10k + 10k)0.15e-6 = 2.079mS

to

0.693(10k + 0)0.15e-6 = 1.039mS

The time the signal is low is equal to:

0.693(390k)0.15e-6 = 40.54mS

The diode is there to bypass resistor

R3 during the THIGH charging phase.

The timing values are close enoughto work with just about any servo. Ifyou want exact timings you canreplace resistor R1 with a trimmerpotentiometer.

To Servo

TRIG2

Q3

R4

CVolt5

THR6

DIS7

VCC

8GND

1

U1

NE555

+5V

R1

10k

R3

390k

R210kLinear

D1

1N4148

C1

0.15uF

+5V

Page 8: Hobby Servo Fundamentals - Sawicz

AreaRobotics

RC2

CX1

+T4

T5

Q6

Q7

R3

U1A

74HC4538

R1

3k

C1

1uF

+5V

+5V

U274HC86

To Servo

From Control

Servo Reverser Circuit

S ER VO RE VER SER S

Servos occasionally have to bemounted in such a way that theyrespond opposite to the intendeddirection. You push the control stickleft and the car turns right. Youcannot simply reverse the leads tomake the motor turn the other way.What is needed in this case is theinverse of the applied signal.

You cannot simply invert the signalor you will get a ≈2mS off time with a≈40mS on time. Lets look at what weneed to do:

THIGH = 1mS the servo is fully CCW

THIGH = 2mS the servo is fully CW

Therefore, you want a circuit whichconverts a 1mS pulse into a 2mSpulse and vice versa.

It might seem a little daunting butlets think of it in terms of subtraction.Three minus one leaves two. Threeminus two leaves one. JUST WHATWE NEED!

Now the problem is where do we getthe three from, and how do wesubtract times from pulses?

The answer is simpler than youthink. A one-shot timer supplies the3mS pulse when it is triggered by therising edge of the control signal. Thislines up the rising edges so the"subtraction" has a reference point.The "subtraction" is even easier.Look at the truth table for an XORGate:

X Y OUTPUT

0 0 0

0 1 1

1 0 1

1 1 0

When the control signal (X) starts itgoes high for at least 1mS. Therising edge of X triggers the one-shottimer which then supplies the signalY. Now notice on the chart that whenX and Y are '1' the output is '0'.

Suppose X drops out at 1.3mS. Thecontrol signal (X) goes low but the3mS one-shot signal (Y) stays high.Again looking at the chart, when X is'0' and Y is '1' the output is '1'. Thiscontinues until the one-shot timesout at 3mS at which time its outputgoes low until it is re-triggered by thenext control signal. At the time Ygoes low you can see that the outputhas been high for 3mS – 1.3mS =1.7mS. And thus the servo hasreversed from a little to the left to alittle to the right.

Page 9: Hobby Servo Fundamentals - Sawicz

M OD IFY ING A SER VO

There may come a time when it isadvantageous to use the servo as anormal DC gearhead motor. Both theinner mechanical and electricalmechanisms need to be modified toallow for continuous rotation.

Start by removing the control hornsattached to the output shaft. Thegear cover won't come off if youdon't. Next remove the four screwson the bottom of the servo case.They hold both the gear cover andbottom cover in place.

Carefully remove the gear cover.Pay attention to the placement of thegears. They can only go one way.

The gear you need to modify is thelarge black one in the picture above.It connects the output shaft and thefeedback potentiometer to the rest ofthe drivetrain.

There is a mechanical stop on thegear that strikes another stop on theinside of the gear cover. Thisprevents the shaft from turning toofar and damaging the potentiometer.

You need to remove this stop toallow for full rotation. It is easy to

Page 10: Hobby Servo Fundamentals - Sawicz

If you are using an M51660servo motor control chip you canincrease the deadband byincreasing the resistance on Pin9.

remove using a pair of flush cutters,an X-acto knife, or a file.

Removing the stop on the gear isonly half the problem. There are stillstops built into the potentiometer.You must now remove it as well.

The potentiometer is removed bydesoldering it from the circuit board.You must then replace the pot withtwo resistors of equal value. Two2.2K resistors should work well. Thevalues aren't critical as long as theyare equal.

One end of each resistor goes intothe center (wiper) hole. The free endof each resistor then goes into theremaining hole on either side.

The resistors form a fixed voltagedivider that replaces the variablevoltage divider of the potentiometer.This tricks the servo into thinking it iscentered all the time.

When you supply a control signal>1.5mS it drives the motor CW, butbecause the feedback signal istelling the servo it is still centered theservo keeps trying to drive it

clockwise continuously. When thecontrol signal is < 1.5mS the servodrives the motor CCW for the samereason.

This solution is good if your servo isalways moving. If you try to stop theservo you will probably notice thatthe servo creeps in one direction orthe other, or it just vibrates back andforth. This is because you haveremoved the feedback loop. If thecenter signal produced by thevoltage divider is different from thecenter signal generated in thetransmitter the servo will moveinstead of stop.

The best way around this problem isto build your own controller with amicrocontroller (or otherwise) andincorporate a deadband around1.5mS. When the control signal iswithin this deadband (1.5mS ±5uS orso) the servo doesn't move.

If you want to build your owncontroller or just use the servo as aregular gearhead motor you cansimply de-solder the motor from thecircuit board, attach wires to themotor terminals, and put it back inthe servo case.

Page 11: Hobby Servo Fundamentals - Sawicz

RF-020TH

VOLTAGE NO LOAD AT MAXIMUM EFFICIENCYSPEED CURRENT SPEED CURRENT TORQUE OUTPUT EFF

STALLTORQUEMODEL OPERATING RANGE NOMINAL

rpm A rpm A OZ-in g-cm W % OZ-in g-cmRF-020TH-10210 2.0 ~ 5.0 4.5V CONSTANT 12600 0.058 9580 0.184 0.055 3.93 0.386 46.6 0.228 16.4

DATA SHEET FOR TS-53 SERVO'SELECTRIC MOTOR

2.0

3.8

3.6

HOLE

DIRECTION OF ROTATION

ISO M2.0x0.4 TAPPED HOLE

2 PLACES

10.2

RED MARK(+)

(–)

24.4 REF.

20.0

2.018.0

0.3

6.15

1.5

7.0

4.4

12.1 REF.

17.1

1.6

4.7

Usable male screw length 1.2 max. frommotor mounting surface.

SHAFT LENGTH 23.5

WEIGHT: 16g (APPROX)

UNIT:MILLIMETERS

RANGE

RF-020TH-10210 4.5V

75

50

25

0.75

0.50

0.25

15,000

10,000

5,000

I Nn

I

N

<g·cm>

<mN·m >

TORQUE

10 20

1 2

EFFICIENCY [%]

CURRENT [A]

SPEED [r/min]

Ts 16

Is 0.59

n