R/C SERVO TESTER

This pocket sized servo signal emulator makes it a breeze to test and setup your servos. It features digital accuracy and is easy to build and use.

Introduction

I recently found myself having to test a large number of R/C servo controlled devices. My normal routine is to grab my spare receiver, plug in the servo and battery, then fire up the transmitter. As simple as this sounds, it is inconvenient for me, especially when the "spare" Rx is installed in a plane. When the transmitter nearly fell off the workbench one day, I decided enough was enough.

I thought about buying a R/C servo signal emulator, but I am a do-it-yourself sort of guy. The various projects I saw on the internet did not turn me on. What I found were circuits that were usually based on LM555 timers. They all seemed to use too many components for too few features.

My goal was to use a cheap PIC microcontroller and do everythingIcould to minimize the component count. The PIC would ensure precise R/C signal generation and I figured that features could be easily added in firmware rather than by more components. In the end I met all my expectations. And although I used junk box parts, the cost to duplicate my work is well under $10.

The R/C Servo Tester (RCST) is easy to use. Just plug in a 4-cell battery and your servo. The variable pot allows you to set any servo position you wish, within the 1.0mS to 2.0mS range of a modern R/C system. With the press of a button, you can find the precise center to your servo. Flick a switch and the servo will cycle (run back and forth ) at your chosen speed.

Servo Control Basics

The servo signal is a simple digital pulse. It spends most of its time at a logic low (0V). About every 20mS it goes logic high (3to 6VDC) and then quickly goes low again. It is this tiny window of logic high time, called the pulse width, that gets the attention of the servo.

Please refer to the drawing. The period labeled "A" is called the frame rate. In the example it is repeated every 20mS (50 times per second), which is quite typical for most radio systems.

Modern servos define center as a 1.5mS pulse width, as shown by detail "B" in the drawing. Full servo rotation to one side would require that this pulse width be reduced to 1.0mS. Full rotation to the other side would require the pulse width to increase to 2.0mS. Any pulse width value between 1.0mS and 2.0mS creates a proportional servo wheel position within the two extremes. The frame rate does not need to change and is usually kept constant.

The servo will not move to its final destination with just one pulse. The servo amp designers had brilliantly considered that multiple pulses should be used to complete the journey. This little trick reduces servo motor current draw and it helps minimize erratic behavior when an occasional corrupt signal is received. To move the servo, you must repeat the pulse every few milliseconds, at the chosen frame rate. Modern R/C systems use a 40Hz - 60Hz frame rate, but the exact timing is not critical. If your frame rate is too slow, your servo's movementwill become rough. If the rate is too fast the servo may become very confused.

Circuit Construction:

My board was point-to-point wired using 30 gauge insulated Kynar wire. This wire is normally used for wirewrapping, butworks fine with a soldering iron. I just strip a bit of insulation off and solder it to the parts. I recommend a 40 watt or less soldering iron (700° tip)

Layout is not critical except that cap C3 should be close to the PIC (mine is soldered directly across pins 1 and 8). Cap C1 should have 2% tolerance for best accuracy. Use a socket for the PIC chip. If your servo voltage will be higher than 5V, such as a five cell R/C pack, then you will need to add an LDO voltage regulator (e.g. LM2931-5 Vreg).

The connections to the battery pack and servo are handled by female servo cables or simple 3-pin headers. I built it both ways and prefer the header version. You can see my stacked 3-pin headers on the upper right of the photo.

Check your work carefully. Do NOT install the PIC chip until you have verified that pin 8 is ground and the pin 1 has 4.75 to 5.25 VDC on it. Remove power BEFORE you install the chip. Double check the servo cable for correct polarity before you plug a servo in. Simple mistakes can destroy electronic parts, servos, and may generally ruin your day.

Your exact PIC choices have some flexibility. You can use a PIC12C508, PIC12C508A, PIC12C509, and PIC12C509A. The PIC12C50x is not a "Flash" part, so you will need a traditional PIC chip programmer to "burn" the hex file's object code into the microcontroller.

Be sure to verify that your chip burning system has selected the proper configuration fuses, as shown below. For example, if your programmer uses the PICALL software, then press F3 to review the Config fuses.

WDT:

Watchdog Disabled

MCLR:

MCLR Disabled

Oscillator:

IntRC

Memory:

Code Protected

The PIC's Hex file is designed to automatically instruct the programming hardware to chose these values. However, it is always a good idea to check them for accuracy. By the way, after you program the PIC yourprogrammer will report a failure if you attempt to verify the PIC again. Do not be alarmed -- everything is OK. Just ignore the "failure." Whatever you do, do NOT program the chip twice!

If you have trouble burning the PIC, then please check your programmer. Whatever the fault, it is not a RC-CAM hex file issue. The most common problem is that the user has forgotten to burn the PIC's four configuration fuses, as mentioned above. More programming information can be found starting here.

The entire firmware is written in "C." You do not need to know anything about the C language to build your system. All you need is the object code (Hex file) to program the PIC, which is provided at no charge for personal use. A hobbyist can use the firmware in a personal project at no charge. But, anyone that desires to use it in a product for distribution (or wishes to offer pre-programmed parts) must first obtain written permission.Sorry, but I will not provide the text based source code.

Instructions: Servo Signals for all Seasons

With S1 and S2 turned off, the variable pot is used to select the servo's position. The endpoints are software limited to approximately 0.95mS on the low end and 2.1mS on the high end. The step resolution is 10uS, which allows for very smooth movement.

To cycle the servo back and forth, enable switch S2. The cycle speed is determined by the pot's position. The seven sweep times vary from about twice per second to once per twenty-five seconds. Step resolution will vary, depending on the chosen speed. The servo steps are coarse on the faster speeds.

To find the servo's electronic center, just press and hold S1. The servo pulse will be forced to 1.5mS and the servo wheel position should move to a nominal center location. You can also use this feature to help calibrate the knob's tick marks, since it will indicate where they knob needs to be for a centered servo.

The pot position controls an "RC" timing circuit. In effect, R1, C1, and some clever PIC software, are used in place of an A/D converter to measure the pot's position. Since the reference is not voltage regulated, it is affected by battery voltage. The decoded pot position can vary about 5% over the voltage range of a typical 4-cell NiCD or NiMH pack. However, the S1 (Center Switch)timing is not affected by the battery voltage and will remain accurate throughout all expected voltages.

Design Documents:

The technical details are available as file downloads. There is no charge for the information when used in a personal (hobby) project. Commercial applications must obtain written approval before use.

Please be aware that the information is copyright protected, so you are not authorized to republish it, distribute it, or sell it, in any form. If you wish to share it, please do so only by providing a link to the RC-CAM site. You are granted permission to post links to the web site's main page ( Please respect this simple request.

Schematic Files: PDF file of the RCST circuitry. The components are from
Hardware Revision: Rev A, dated 02-19-2003

PIC Object Code: Hex file and license details for the compiled RCST firmware. You should occasionally check for updates.
S/W Version: V1.0, dated 02-19-2003.

The Small Print:

If you need a part then please consult the sources shown in the project (see schematics download). I do not work for, nor represent, ANY supplier of the parts used in this project. Any reference to a vendor is for your convenience and I do not endorse or profit from any purchase that you make. You are free to use any parts source that you wish.

All information is provided as-is. I do not offer any warranty on its suitability. That means that if you build and use this device, you will do so at your own risk. If you find software bugs then please report them to me. I can only make corrections if I can replicate the bugs, so please give me enough details to allow me to witness the trouble.

FeedBack:

I would enjoy hearing from anyone that uses this useful R/C gadget. Please send me an email if you build it.

What’s a Servo?

A Servo is a small device that has an output shaft. This shaft can be positioned to specific angular positions by sending the servo a coded signal. 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. In practice, servos are used in radio controlled airplanes to position control surfaces like the elevators and rudders. They are also used in radio controlled cars, puppets, and of course, robots.

A Futaba S-148 Servo

Servos are extremely useful in robotics. The motors are small, as you can see by the picture above, have built in control circuitry, and are extremely powerful for thier 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.

A servo disassembled.

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. In the picture above, the pot can be seen on the right side of the circuit board. This pot 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 degrees. If the pulse is longer than 1.5ms, the shaft turns closer to 180 degrees.

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.

Controlling Servos - By Aaron Ramsey

Overview

Servos are a very handy resource for people involved in robotics. Servos are basically a small geared motor with a controller. You send an electrical pulse to the servo to tell it where to turn to. Normally a servo can only turn in a 120 to 180 degree range and is used for positioning, but a servo can be taken apart and modified so that it turns the full 360 degrees, essentially creating a geared motor. This article is about how to position the servo using pulses, not how to hack the servos.

What good it it?

Servos are normally used by hobbyists to position rudders, flaps, etc.. on hobby airplanes. What can we use them for? Well, as I describe in my GP2D02 article, servos can be used to sweep sensors arrays back and forth. They can also be used to create legs on a robot. There are many other uses. They come in all different sizes, from less than an inch in length to several inches long. The larger ones are very strong and can be used to move very large loads.

Alright, how do we use it?

A servo has three wires. A signal line, power line and ground line. Different manufacturers have a different orders and colours for the wires, but they are fairly easy to identify which is which. Red and black wires are the power wires, and the third is the signal line. I have servos with either orange or white signal lines. You can test a servo by connecting +5V and GND to the appropriate wires, then just tapping the control wire on +5V quickly. This simulates the control pulse, and the servo will move left or right.

The control pulse?

A servo is controlled by a series of pulses with certain high and low times. The high time controls the position of the servo. A typical servo accepts a 1 ms to 2 ms high pulse in order to position itself over a 110 degree sweep. The low time can vary from 10 ms to 20 ms, and plays no role in the position of the servo. The control signals are linear, so that a pulse of 1.5ms will position the servo very close to centre. Some brands of servos will accept pulses lower than 1ms amd higher than 2ms. This lets you position the servo over a greater angle. I've had servos which can sweep 180 degree with servo pulses ranging from 0.7ms to 2.4ms. Just how far you can sweep a servo is determined by experimental means. Just be sure to gradually push the servo rather than feeding it extreme values to see how far it can go. You can physically damage the servo gears by trying to move it too far in one direction or the other. You'll know when you are going too far by the sounds that the servo makes. <grin> Below is a sample servo pulse.

A typical servo that I use is a Cirrus CS-70 Standard Pro Servo. It is rated 0.15 sec/60 degrees at 4.8 volts and 0.12 sec/60 degrees at 6.0 volts. It is powered by 5 volts. In order to position it accurately, I actually need to give it 6 pulses, each around 12 ms long. Usually 2 pulses are enough to get the servo in the general position that I want it to be, and the 4 additonal pulses are just fine tuning. If accuracy is not important to your application, you can cut back on the number of pulses that you send. If you are sweeping the servo over a great distance, you need to send it more pulses.

Something to note is that the servo is only powered when you are actually sending it a pulse. When it is not receiving pulses, the motor will not hold the servo arm in place. The gearing helps to hold it in place, but if you are creating a walker which needs the servo to physically hold it off the floor, you need to continuously send pulses to the servo. If you are just sweeping a sensor back and forth, you only need to send the pulses while you are moving the servo.

So, how do I generate that pulse?

Below, I present some C code for the CCS compiler for the PIC processors. The code is fairly readable, even though I use some functions specific to the CCS compiler. You should be able to easily move this code to another compiler or language. Basically I loop 6 times. Inside the loop I output a high on pin B0 of the PIC, delay for 1.5ms, output a low on pin B0, and delay for 10ms. It's really that easy!