Project tutorial

# All About Servo Motors and Servo Motor Tester © CC BY-NC-ND

Servo!!! The motor for Robots

• 9,961 views
• 1 comment
• 15 respects

## Components and supplies

 Arduino UNO
×1
 555 Timers
×1
 Rotary potentiometer (generic)
×1

## Apps and online services

 Arduino IDE

Thanks

I needed a servo tester for my workshop, to have at hand whenever I change servo horns or need to see if a servo is dead. I decided to use a 555 timer to do this.

Driving a servo

This is covered everywhere on the internet, so I’ll be brief. A typical RC servo is controlled by a 50Hz square pulse signal called Pulse Width Modulation (PWM). The high pulse time varies from 1ms to 2ms, where 1ms gives 0 degrees and 2ms gives 90 degrees. This is followed by a low time of 16-18ms.

The servo has a three pin 0.1″ connector with the following pinout:RED – +4.5v to 6.5vBLACK – GroundWHITE/YELLOW – PWM Signal

### Implementation

In order to have a low time that is longer than the high time, it it is necessary to put a diode over R2, in a configuration called extended duty cycle astable. Thus, the schematic becomes:

We need to use maths to solve for R1, R2 and C.

With the diode in place, the formula is given as:

The potmeter regulates between 1ms and 2ms for the high pulse, so it follows that 2200 Ohm corresponds to one millisecond. The high pulse should never be under 1ms long, so we need an 2.2kOhm resistor in series with the potmeter. This is the value for R1 in the schematics. When the potmeter is fully on, we have 4.4 kOhm and a 2ms high pulse. Knowing this, we can solve for the capacitor value C:

Since we know that we need 2200 Ohm per millisecond, we can simply say that

Or, if we want to do things the hard way, we insert our capacitor value into the formula to solve for R2:

To verify this, I had a look at the graph in the 555 timer datasheet, knowing now that R1+R2 = 44kOhm.

The graph gives a capacitor of about 0.7uF, so it seems things are correct. Using these values as a starting point, I made the final circuit and did some small adjustments on the component values by watching the output pulses on an oscilloscope. This is my final parts list:

TLC555CP (555 timer)8-pin solder tail DIP (socket)2.2kOhm potmeter (R1_pot)2.2kOhm resistor (R1)33kOhm resistor (R2)500nF capacitor (C)150nF capacitor (C)100nF capacitor (decoupling)47uF capacitor (decoupling)3-way male 0.1″ pin connector (servo connector)

Filling in all values, the schematic now looks as follows:

I tested Fritzing, a simplified electronics layout editor for hobbyists. I still prefer Eagle, but at least it is cool to be able to show the circuit as it would be on a bread board:

Then I created a PCB design for this. and went to jlcpcb.com for ordering my PCBs. I got my PCBs in 6 days and for \$2 + 25\$(shipping) only. The quality of PCB was awesome.

Then I soldered everything and it looks like this.

So that was it. It worked fine.

Thank you for Reading Have a Nice day!!!

## Code

##### Code for Servo MotorC/C++
```#include <Servo.h>

Servo myservo;  // create servo object to control a servo

int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin

void setup() {
myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
myservo.write(val);                  // sets the servo position according to the scaled value
delay(15);                           // waits for the servo to get there
}
```

## Schematics

servo_tester_zQKDVpxBc2.fz

#### Author

##### RoboCircuits
• 22 projects
• 181 followers

April 21, 2019

#### Members who respect this project

and 9 others

See similar projects
you might like

• 15,191 views
• 23 respects

#### Servo Motor Control with Remote

Project showcase by Alfa

• 26,053 views
• 40 respects

#### Using Serial Monitor to Control Servo Motor

Project tutorial by Kub_Luk

• 40,698 views
• 44 respects

• 43,134 views
• 45 respects

• 18,532 views