Projects

5V Servo Tester and Calibrator

Johann Wyss

Issue 24, July 2019

This article includes additional downloadable resources.
Please log in to access.

Log in

Quickly and easily set the position of servos before mounting the servo horns and installing into your project.

BUILD TIME: 2 HOURS + 3D PRINTING
DIFFICULTY RATING: Intermediate

Thanks to the popularity of Arduino, Raspberry Pi and robotics, the humble servo motor is now becoming a common staple in the home maker’s parts cabinet. Servo motors give us the ability to precisely position the motor to just the right angle. This helps us to accurately control, for example, the direction of a robot or RC car, to articulate a robotic arm, open and close an enclosure lid or door, position the extruder head on a 3D printer or mill, and much more.

Unlike the common hobby motor which we apply DC power to in order for it to turn, the servo motor needs circuitry that sends pulses to the servo to set its angle. Servo motors usually have a limited rotation, up to a maximum of 270° for example, so they usually need to be positioned correctly in your project before you bolt everything together.

Servos have tiny gears within them, which can be made from either plastic or metal. This tester can help determine if any of your gears are damaged or stuck.

THE BROAD OVERVIEW

We have published many projects recently that use servo motors in their operation, including the Lolly Sorting machine in Issue 19 and Grippy Robotic Arm in Issue 21. In both projects, we needed to install the servo in a known position during construction. This meant we had to make an Arduino sketch to move the servo to this known position before installation.

This lead us to design this simple device for makers to use in order to easily set the servo’s position.

We have designed the circuit to be compatible with three of the most popular servo types, 90°, 180°, and 270°. We have also provided several preset positions that a servo is likely to be set to; 0°, 25%, 50%, 75% and 100%, and in order to test the full range of movement there is also an onboard potentiometer.

A rotary switch is used to easily select between the five preset positions. A sixth position sets the circuit up for manual adjustment using the potentiometer.

Selecting between the 90°, 180° and 270° servo types is made easy via a tactile switch, which has LED indicators to show the current setting.

To operate, the user simply connects their servo onto the three pin header, selects the servo type, then uses either the potentiometer to test the servo, or uses the rotary switch to set the servo position.

HOW IT WORKS

This project is made simple thanks to the Arduino microcontroller development board. Essentially all of the work is done using the microcontroller. All we need to do is read the values of various inputs and have the microcontroller drive the connected servo accordingly.

In total, the device has eight different inputs; digital inputs for the six preset positions, one for the servo type selector and one analogue input for the potentiometer. There are four digital outputs; three to show the servo type using the LEDs and one to control the servo itself.

Given the number of inputs and outputs, we decided to use a microcontroller from the ATmega range. While there are ATtiny’s that have the required number of input/outputs, they tend to be a little more difficult to find here in Australia, and more often than not are surface mount devices. This is why we settled on the ATmega328P, which many of you may know from the first Arduino Uno. This also makes programming very simple with the Arduino IDE.

The Fundamental Build:

Breadboard Prototype

Parts Required:JaycarAltronicsCore Electronics
1 × Arduino Compatible NanoXC4414Z6372CE05101
1 × Red 5mm LEDZD0150Z0800CE05103
1 × Green 5mm LEDZD0172Z0801CE05103
1 × Blue 5mm LEDZD0185Z0869CE05103
3 × 330Ω ¼W Resistors*RR0560R7040PRT-14490
2 × 8k2Ω ¼W Resistors*RR0596R0058PRT-14491
1 × 10kΩ TrimpotRT4360RT2480BCOM-09806
1 × 1 Pole 12 Position SwitchSR1210S3021-
1 × Tactile SwitchSP0600S1120ADA367
1 × 28 or 40 Pin Header Terminal StripHM3211P5430FIT0084

Parts Required:

* Quantity required may be sold in packs. Breadboard and prototyping hardware also required.

Before designing a PCB type project, we decided to prototype our circuit on breadboard and use an Arduino Nano to make programming easier, compared to working with an ATmega328P micro on its own. Prototyping with the bare microcontroller would mean constantly removing the IC for programming, which isn’t easy and slows down the process.

You can make this prototype yourself by following the Fritzing diagram.

Follow this table to connect the microcontroller to the switches and trimpot. You can also use a large potentiometer instead of the trimpot if you prefer.

NANO PINCOMPONENT PIN
D2Rotary Switch Pin 1
D3Rotary Switch Pin 2
D4Rotary Switch Pin 3
D5Servo Output (Data)
D6Rotary Switch Pin 4
D7Rotary Switch Pin 5
D8Rotary Switch Pin 6
D990° Servo LED (Red)
D10180° Servo LED (Green)
D11Servo Type Push Button
D12270° Servo LED (Blue)
A6Trimpot / Potentiometer Wiper

Use plug-to-socket jumper leads to connect to the rotary switch.

Note: To set the rotary switch to only travel the six positions you need to relocate the washer that has a tooth into the sixth hole.

For a more detailed explanation of the electronics, proceed to the final device section where we explain the entire devices circuity and how we arrived at choosing each component and/or why.

With the wiring complete we can program the Nano.

THE CODE

The code is available for download from the resources section of our website. For the most part, the code is very simple. We have made it easy to follow by providing each sectional block with a brief title explaining the function.

A few areas of the code may not instantly be recognisable. For example, in the setup, we define the inputs via a ‘for’ loop.

for (int count = 0; count < numSelector; 
count++) {
    pinMode(selectorPins[count], INPUT_PULLUP);
  }
  for (int count = 0; count < 3; count++) {
    pinMode(ledPins[count], OUTPUT);
  }
  pinMode(11, INPUT_PULLUP);
}

This was done to make it easier to modify the code to suit the pinout when we changed the circuit to PCB, to make it easier to follow, and also to save lines of code.

We simply stored all of the pin numbers for the rotary switch into an array called selectorPins. We then used this array in conjunction with a ‘for’ loop to individually address each pin. This saved us from having to manually check each pin and thus is a little more efficient, and hopefully easier to read. We also used this function when reading the input pins for a LOW state, as shown here.

for (int count = 0; count < numSelector; count++) {
  if (digitalRead(selectorPins[count]) == LOW) {
    selState = selectorPins[count];    
  }

Here we read each element in the array and insert that element into the digitalRead() function. If the count was 0 from then the first element, in our case 2, is inserted into the digitalRead(). This tells the program to digitalRead(2), or read the digital pin with the number inserted from the array.

We later use the value stored in selState to dictate what output to the servo the user has requested i.e. what preset position.

To detect the pushbutton state, we use the code:

buttonState = digitalRead(11);
if (buttonState != lastButtonState) {
  if (buttonState == HIGH) {
    state ++;
  }
  delay(10); //a basic debounce, 
  // consider software debounce
  if (state > 3) {
    state = 1;
  }
}
lastButtonState = buttonState;

Since we had three possible options to pick from, we needed a button press to toggle between the three states. This is done by reading the button state on each loop of the program. If the current state is not the same as the previous state, we know to change to the new selection. However, we needed a simple way to make sure each press only resulted in one change of state, i.e. we didn’t want a single press to change the state more than once. We could have used a software debounce but we chose to simply add a 10ms delay instead.

From there, we used an ‘if’ statement to make sure we don’t exceed the maximum number of states, and simply save our current button state to the memory location lastButtonState. On the next loop, we can once again compare the new current state against the last.

The final part of the code that we should explain is the servo control section.

val = map(servoPos, 0, 100, 0, maxPos);
while (val > currentPos) {
  testServo.attach(5);
  currentPos ++;
  testServo.write(currentPos);
  Serial.println(currentPos); // debug
  delay(10);
}
while (val < currentPos) {
  testServo.attach(5);
  currentPos --;
  testServo.write(currentPos);
  Serial.println(currentPos); // debug
  delay(10);
}
testServo.detach();

In the first line of the code, we used the map() function to convert the number stored in the memory location called servoPos, which has a value between 0 and 100 to a number between 0 and maxPos.

This maxPos variable is defined by the user’s servo selection input and varies from the three possible states of 90°, 180° and 270°. These become the maximum possible position.

Let’s say the user has selected 90° servos. We map the 0 – 100 values stored in servoPos to a number between 0 and 90, then store that value into the variable val, which we will later write to the servo.

We decided to use ‘while’ functions to slow down the servo movement and have them react a bit smoother. Without these loops, the servo will try to change position too quickly, which isn’t good for the servos. Essentially, these loops work by incrementing or decrementing the current value/position of the servo by one until the desired servo position is reached. This, in conjunction with a 10ms delay, provides a nice fluid servo motion.

The remainder of the code is fairly self-explanatory and should be quite easy to follow and modify.

TESTING THE PROTOTYPE

With the code uploaded to the Nano, we can now test the prototype. Keep power applied to the Nano, which also provides power to the circuit and the servo about to be tested.

Use the select button to select the type of servo, which should be indicated by the corresponding LED. Attach your servo onto the 3-pin header, paying careful attention to the polarity. Usually, the servo wiring colours are Brown, Red, Yellow.

In our case:

  • Brown is the GND connection
  • Red is 5V
  • Yellow is the signal wire

Use the rotary switch to move the servo to the 5 different preset positions. This would equate to 0° all the way to 100% of the maximum range of the servo as selected via the select button. Be sure not to select the incorrect servo type because doing so could damage your servo. Finally, set the rotary switch to the sixth position so you can rotate the servo manually using the trimpot or potentiometer (depending on which one you are using in your prototype).

Servo Motor Overview

The position and direction of a servo motor is controlled using a PWM (Pulse Width Modulated) signal.

The width of the pulse, repeated at a period of 20ms (50Hz) determines the absolute angle of the output. For example, a 1.5ms pulse turns the shaft of the motor to its neutral position of 90°. Providing the signal repeats every 20ms, the servo will try to hold this position even if an external force is applied to it, unless it exceeds its maximum torque rating.

Note: Specifications of servo motors do vary. Be sure to check the manufacturer's datasheet to confirm the voltage, timing, turn rate, rotation constraints, etc.

If your servo does not turn as expected, go over your wiring again. If you have success, you can move on to build your own servo tester in 3D printed case.

The Main Build:

Complete Servo Tester

ADDITIONAL Parts Required:JaycarAltronicsCore Electronics
1 × ATmega328P MicrocontrollerZZ8727Z5126CE05190
1 × 16MHz Low-Profile Crystal(Included)V1289A(Included)
2 × 22pF CapacitorsRC5316R2814(Included)
1 × 10kΩ Linear 9mm PotentiometerRP8510--
1 × LM7805 Voltage RegulatorZV1505Z0505CE05291
5 × 100nF CapacitorsRC5360R2865-
1 × 1N4001 Diode*ZR1004Z0109CE05272
1 × 100uF CapacitorRE6150R4825CE05258
1 × 100nF CapacitorRC5360R2865-
1 × 220µF CapacitorRE6158R4847CE05149
1 × 10mH Inductor^LF1522--
1 × 28 or 40 Pin Female Header StripHM3230P5390PRT-00116
2 × KnobsHK7770h6016ADA2047
1 × PCB Mount DC SocketZD0154P0620-
4 × No.4 x 9mm ScrewsHP0565H1139-

ADDITIONAL Parts Required:

* Quantity required may be sold in packs. ^ RS components sell a suitable product part number 191-1204 however you can simply omit this part and short the connections. The device will lose accuracy but will still function as intended.

DESIGNING THE MAIN CIRCUIT

The electronics, despite looking quite complex on the schematic, are very basic. If we break it down into basic blocks such as power supply, inputs and outputs, and microcontroller, the circuit is quite simple to follow. Let’s explain each block in more detail.

POWER SUPPLY

The power supply for this project was designed using the LM7805 linear voltage regulator. The regulator takes an unregulated input voltage, which needs to be greater than 7.7V, and outputs a regulated stable 5V. Whilst not very efficient, the component is very simple to use, largely in part to its low number of passive components required for its operation.

The TO-220 package is capable of delivering currents exceeding 1A (provided heatsinking and cooling is adequate), therefore, it will certainly be capable of providing the much smaller currents we will need. Our servo tester is designed to work with 5V servos which has a maximum current draw of about 200mA. This regulator should be more than capable to deliver this 1W range.

The unregulated input power comes into the circuit via a 2.1mm DC jack in a centre positive configuration. From there it goes through a 1N4001 diode, which acts as reverse polarity protection. This protects the circuit if the user accidentally connects power with the centre pin as negative.

C4 is a bypass capacitor, which is placed across the input supply rails. This smooths out any high frequency noise on the input and is required for the linear regulator’s operation.

C5 is also a bypass capacitor. Its job is to remove high frequency noise on the output and prevents oscillations. Since the value of these bypass capacitors is not of huge importance, we simply use the recommended 100nF ceramic type.

The larger C6 electrolytic capacitor has been added to help smooth out any load ripple, and help avoid the voltage dropping when the servo is actuating.

For this circuit, we need an input DC voltage greater than 7.7V because of the regulator’s 2V voltage drop and to 0.7V that drops across the reverse polarity protection diode.

We also need to consider the temperature this regulator can produce when in operation. Linear regulators work by becoming a variable resistance in series with the load that causes a voltage drop to reduce the supply voltage to a controlled output voltage, burning up excess voltage as heat. This causes the linear regulator to convert the unwanted surplus of electrical energy into unwanted thermal energy.

As an example, if you are using a 12VDC power supply and the servo draws a current of 210mA, the voltage regulator needs to dissipate 1.47W. Here’s the formula to work that out:

P = V × I

P = (Input Voltage - Regulated Output) × Current Input

P = (12 - 5) × 0.210

P = 1.47W

If the input voltage was higher, let’s say 15V, the power dissipation would rise to:

P = (15 - 5) × 0.210 = 2.1W

To get an idea of the expected temperature increase with this load we need to get a value called the “Thermal resistance”, which can be found in the National Semiconductor LM7805 datasheet. The Thermal Resistance in the datasheet states (for the LM7805 in the TO-220 package) the temperature case to ambient will increase by 50°C per Watt.

†Exceeding recommended 70º case maximum temp. *The internal protection circuit has shut down the device.

With a dissipation of 1.47W, we can expect the temperature of the component to reach:

ΔT = Power Dissipation × Thermal Resistance

ΔT = 1.47 × 50

ΔT = 73.5°C

Whereas, with the input raised to 15V the temperature will increase to 105°C (2.1 × 50). This is the expected increase in temperature above ambient. Therefore, if your ambient temperature is 25°C you need to add this to the result. This shows that without a heatsink, the input voltage should be between 7.7V and 14V.

However, the current draw on this device is not constant and only has a peak current draw of around 200mA when the servo is moving. As such, there is minimal chance for the regulator to need a heatsink. Despite this, to increase the longevity of the component we will attach it thermally to the copper plane of the PCB. This will help to dissipate heat away from the case and prevent damage to the regulator.

INPUTS AND OUTPUTS

Many of us are used to connecting our electronics up to match the Arduino development board pin numbers, however, these designations mean nothing outside of the Arduino framework. When dealing with the microcontroller itself, you will need to abandon the Arduino nomenclature and lift the veil of the microcontroller hidden beneath. To do this, download the datasheet for the ATmega328P.

DIAGRAM CREDIT: Atmel

You will notice that none of the pins match what we would usually consider them to be in the Arduino framework. This is because the Arduino framework has been constructed around making microcontrollers much more accessible. For example, instead of having pin designations having IC pin 27, designated as PC5 (ADC5/etc.), in the world of Arduino, we simply use Analog(5). However, since we are building a PCB, and we want this PCB to be easy enough for hobbyist users to build at home, we needed to make the PCB as efficiently as possible using only one side.

Therefore, we needed to map the Arduino pins to the actual pins on the microcontroller. Lucky for us that was made quite easy, as the ATmega328P we are using is identically mapped to the ATmega168 used in the Arduino UNOs. As such the mapping is as follows:

DIAGRAM CREDIT: Atmel

After figuring out which pins we were using, we made some modifications to the code to minimise the need for circuit tracks to cross when we were building the final device. We then tested the new pin assignments in the code and modified the prototype to match. As such the version of the prototype you see will be this modified version.

To make it easier to follow the input and output components of the circuit we will break them into smaller individual sections.

POTENTIOMETER CIRCUIT

The first is the potentiometer voltage divider, which we use to allow the user to manually test the range of a servo. This will identify stuck or damaged gears and can be used with the servo mounted in position to test the range of motion of attachments. For example, you could test to make sure the airfoils on your model plane are not binding up while moving.

This potentiometer simply creates a voltage divider, which varies linearly with regards to its wiper position. That is to say at the top position it will give 100% of VCC, in the middle it will give 50% VCC and at the bottom, it will be 0V.

We use the microcontrollers analogue to digital converter connected to the wiper to read this voltage level. Since the ATmega328P has a 10bit ADC, this will provide an output between 0 and 1024. Because we are talking a binary number it can be shown using the equation:

binary ADC output = 2n (Where n is the number of bits the ADC has)

210 = 1024

In the code, we take this value, and using the map() function, convert it to a number with a range between 0 and 100 (100 being the maximum). This will make deciding the output values later much easier.

ROTARY SWITCH CIRCUIT

The next step is to figure out the switch’s configuration. We need a switch to allow us to select between six possible states. Now there are ways that will allow us to use fewer pins such as multiplexing, however, given we have sufficient pins we saw no need to make the project more complex then it needed to be. Thus we stayed using six individual pins, one for each state.

We chose a 1 pole 12 position rotary switch, which has a clever little washer with a tooth on it that allows you to set the total number of possible positions from 2 to 12. This means when used in your project you will only be able to select from the six possible states, not all twelve.

We originally attached a 10 resistor to the pole of the switch marked A and connected this to ground. This was intended to protect against short circuits and avoid the possibility of destroying an I/O pin of the microcontroller if you get something wrong when coding. This does, however, add another challenge. The microcontroller is looking for a LOW input i.e. 0V. By using a 10kΩ resistor in conjunction with the internal pullups of the microcontroller, we can never actually get 0V on the input. We’re essentially creating a voltage divider. To calculate if it would be an issue we needed to consult the datasheet once again.

With the full datasheet we learned that the pull-up resistor value can be anywhere between 20kΩ and 50kΩ. This means, at worst, the resistor is 20kΩ, however in conjunction with our 10kΩ, we will get a voltage of 1.6V at the pin.

We calculate this using the voltage divider equation:

Vout = Vin × (R2 / R1 + R2)

Vout = 5 × (10k / 20x + 10k)

Vout = 1.6V

We need to read the datasheet to make sure that the microcontroller will read a voltage of 1.6V as a low. We learned for the microcontroller to be guaranteed to detect a LOW on a digital pin, the voltage must be less than 1.5V:

LOW = <(0.3 × VCC). Since our VCC is 5V this means our voltage for LOW detection should be: 1.5V

Using the lowest possible value for the internal pullup resistor is likely to be fine, however, we are building this device to teach newcomers to electronics. We need to accommodate by making sure that the designs we provide are within spec. This avoids any doubt that the circuit is the cause of issue. We have modified the design to use an 8.2kΩ resistor on the pole pin of the switch, instead of 10kΩ.

With this resistor, the output voltage from this voltage divider will be about 1.45V, which should be enough to counter the 5% tolerance of the resistor but let’s check. 4.5% of 8200 = 410, which means our resistor can have a value 8200Ω ± 205Ω, therefore, our worst case the resistance would be 8405Ω. This demonstrates our absolute worst-case scenario output voltage from this voltage divider will be... (Drum roll please): 1.479V

Since this is within the specs of our circuit we will leave it in. However, if this circuit was designed to keep people alive we would certainly not rely on such a fine margin of error, and would err on the side of caution and decrease this to 0V by removing the resistor all together.

Now we need to check that in the worst-case scenario, i.e. the internal pullup is only 20kΩ, that the current through this switch would not be enough to damage the pin, in the unlikely event the programing accidentally pulled the pin high.

The ATmega328P has an absolute maximum current per pin of 40mA, any more than this risks damaging the microcontroller.

Since the combined resistance equals 28.2kΩ we can easily calculate the current using Ohms law:

I = V / R

I = 5 / 28200

I = 177µA

If the pin was accidentally pulled high in programming the current from the pin would be:

I = V / R

I = 5 /8200

I = 609µA

Therefore, we can confidently conclude that using an 8.2kΩ resistor pulling the switch to ground will consistently both protect the ATmega328P from accidental pin shorting, and also work flawlessly in conjunction with the internal pull-up resistors.

LED CIRCUIT

For the outputs, we have three 5mm LEDs and the Servo output itself. We are using a red, green and blue LEDs, which have slightly different specifications. To calculate the current limiting resistor value required for each LED we first need to find the forward voltage and forward current for the LED. This is found in the datasheet. The forward voltage for an LED varies with colour and manufacturer so if you’re wanting maximum brightness be sure to use the values for If and Vf from the datasheet specific to your LED.

For an example, Jaycar lists its 5mm Red LEDs as having a forward voltage (Vf) of 2.3V (typical) and a forward current (If of 20mA). Therefore, to calculate the resistor needed for the Jaycar Red LEDs listed you use the equation:

R = (Vcc - Vf) / If

R = (5 - 2.3) / 0.02

R = 135Ω

This shows the minimum resistance value you need to power this LED is 135Ω. However, this will also produce the highest brightness and will likely reduce the lifespan of the LED due to the Vf having a range with 2.3V being typical. Provided you use a value higher than this you should be fine.

If we needed maximum brightness we would usually just go the next value in the E12 series, in this case 150Ω. These LEDs are just used as an indicator so we are going to recommend a value of 330Ω for each of the resistors to keep it simple and provide the longest possible lifespan of the LEDs.

SERVO CIRCUIT

The servo output circuit is straightforward. We have added a bypass capacitor close to the servo VCC line to reduce high frequency noise, and we also included a higher value electrolytic close to the servo header pin to help work as a buffer for when the servo is actuating. This is usually required because when the servo moves it draws a lot of current, usually a few hundred milliamps. Depending on the type of servo, this sudden change in current can result in an abrupt drop in voltage, which can cause the voltage to microcontroller to drop below its minimum voltage. This can cause a reset.

If you’re having issues with erratic servo movement or microcontroller resetting, you can increase this value. 200µF is usually fine, however, some makers prefer 470µF.

MICROCONTROLLER

The final part of the circuit to cover is the circuits that support the microcontroller.

We essentially have three sets of external components; a single 100nF bypass capacitor (C3 on the main schematic) to filter high frequency noise to ground, providing a stable 5V to the microcontroller.

We also have a lowpass filter made using a 10mH inductor (L1) and a 100nF capacitor (C7). Together these components ensure a stable voltage supply to the AVCC input to the microcontroller. This removes any noise on the rail over the specific frequency called the cutoff frequency. We calculate this frequency using the following formula.

F = 1 / ((2π) × √(L × C))

F = 1 / ((2π) × √(10 × 10-3) × (100 × 10-9))

F = 5032Hz

This means the circuit will filter out frequencies higher than 5kHz, as recommended by the ATmega328P datasheet.

It’s worth mentioning that this circuit is only recommended when using the ADC of the microcontroller. Although it should be there for ADC stability, if you wish to bypass this circuit you can simply connect AVCC directly to VCC.

CRYSTAL CIRCUIT

As you can see in the schematic, the crystal (Q1) has two 22pF capacitors (C1 and C2) connected to ground on either side. These capacitors are load capacitors and are used to allow the crystal to oscillate reliably at the specific frequency.

The datasheet for your specific crystal will state the required load capacitance, however, it is usually a safe bet in non-life critical applications to just use a 22pF capacitor. In some applications, 22pF capacitors can cause erratic and unstable clock pulses, which can create significant issues with timing sensitive commutation protocols. However, since we are not using any of these communication protocols 22pF will be fine in our case.

3D PRINTED ENCLOSURE

We designed the 3D printed enclosure to be as small as practical, factoring in the large rotary switch.

It has been designed to be printed in 5 pieces, with the front and rear panels being secured together using 3mm screws. This clamps the button and PCB firmly together while TPU rubber feet can be secured to the base with epoxy.

The front panel was printed flat on the build surface of our Flashforge Creator Pro and took approximately 2.5 hours at 300-micron layer height. Our build was printed without supports in Flashforge branded PLA.

The rear panel took about 1.5 hours at 300-micron layer height on the Flashforge Creator Pro and was printed in the same green Flashforge PLA. It was printed without supports, laying flat on the build surface.

The button was printed in Flashforge red PLA at 100-micron layer height and took 16 mins to print.

The feet were printed in TPU rubber at 300-microns, 25mm/min.

The enclosure is designed to sandwich the PCB between the front and back covers with the holes all aligning so that the screws go through the rear cover, through the PCB, and into the front cover. Therefore, take extra care when manufacturing your PCB to ensure the mounting holes and perimeter are correct.

THE PCB

Instead of trying to build the project onto perfboard, we have designed a PCB using EagleCad. The gerber files are available on our website if you want to mill or etch your own PCB.

Note: If you are manufacturing the board yourself you only need to manufacture the bottom layer. The top layer of the PCB in Eagle is a flood filled ground plane, which is not needed for the device to function correctly. It was added for the manufacturing process and added thermal properties.

We used the Bantam PCB mill for our original prototype, producing exceptional results. Building the PCB prototype on the milling machine allowed us to verify the board layout was correct before sending the PCB off to be manufactured.

ASSEMBLY

When assembling the device, we strongly recommend that you solder the LEDs when the PCB is sitting in the enclosure. This will allow you to align the LEDs with the front of the case. This is done because the switch extends 15mm past the surface of the PCB. If you solder the LEDs to the PCB they will sit down inside the enclosure which, thanks to the LED surrounds designed into the case, won’t affect operation. It will, however, look better with the LEDs flush with the enclosure surface.

When assembling the PCB, you should follow the standard procedure of installing and soldering components in relation to their size. We like to start with the resistors moving on to the crystal and ceramic capacitors etc., then move onto the next sized components. This will make it easier to solder as the board is easier to keep level and stable this way.

If you had your PCB manufactured, you can put a dab of heatsink plaster/thermal paste on the tab of the voltage regulator and bolt the tab to the exposed vias on the PCB. This will help to thermally bond the regulator to the PCB and thus the PCB will act as a heatsink. This isn’t necessary when using the recommended 12V input, but will increase the lifespan of the component if higher input voltages are used. Naturally, take care with the LEDs, diode and electrolytic capacitors to ensure they are correctly placed because they are polarised.

For the servo connector, we need to make an extender. To do this, we used a 3 pin section of the female pin header and a 3 pin male connector. Placing the small pin ends against the pins of the female header and soldering them together as shown here.

Start the enclosure assembly by first securing the feet to the enclosure. We did this using a 2-part epoxy, however, hot glue or similar will work too. You then want to insert the rotary switch setting retainer into the correct pin count. This toothed washer limits the 12-position switch to only 6 possible positions.

With that firmly in place, flip the front cover face down on a table and put the push button into the locator, and the three LEDs loosely into their locators. Gently lift the front cover and place the PCB into position guiding the LED leads into their corresponding holes. It’s a good idea to screw the board in at this point so you can carefully manoeuver the LEDs into position and solder them to the PCB.

After soldering the LEDs, remove the screws holding the PCB and inspect the PCB to make sure the LED leads are not twisted or shorting. If satisfied insert the servo connector extender we made earlier into the male socket on the PCB, then place the PCB back into place.

Clip the rear cover into place and secure the two sections together with some M3 screws. After this, attach the lock washer and nut to the rotary switch and hand tighten it to the enclosure.

Now you simply need to cut the shaft of the rotary switch down to a suitable size. We cut our switch down to about 12.5mm from the surface of the enclosure for the ideal fit.

Note: The knob we used has a simple line indicator on the top cap of it which indicates its position. This cap can easily be removed and oriented so that it aligns with the indicator marks on the front panel of the enclosure.

Finally, secure the adjustment potentiometers knob using the provided grub screw and you’re done.

TESTING

Testing is similar to the prototype, however, using an external power supply with a 2.5mm barrel jack set to centre positive.

If nothing happened when you attached the power, double check the PCB and ensure the 1N4001 in position D1 is in correctly (The white bar on the diode should align with the white bar on the PCB.) and that you have a centre positive supply that is higher than 7.7V.

WHERE TO FROM HERE?

You should now have a 5V Servo Tester that can live on your workbench, ready to test and calibrate your servos before you put them into your next exciting project.

If you were wanting to make the device smaller in size, you could use a single addressable LED Neo Pixel, which would only need one digital pin. You could also use voltage dividers and the 12-position switch to use only one analogue input pin. The voltage dividers would be used so that a specific voltage was measured if the switch was in a certain position. This would, of course, present some challenges with routing a single-sided PCB, however, it is certainly possible.

Had we designed the circuit in this way we would have been able to drop the microcontroller down to an ATtiny85, as we would only need 2 analogue pins; one to read the potentiometer and one to read the 12-position switch. We would also only need 2 digital pins one PWM to drive the servo and one to change the colour of the LED.