Servo

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 5

How to control servo motors with arduino

Servo motors are often used in robotics


projects, but you can also find them in RC
cars, planes, etc.

They are very useful when you need precise


position control and/or high torque.
How does a servo motor work?

 A standard hobby servo typically consists of a small


electric motor, a potentiometer, control electronics, and
a gearbox.

 The position of the output shaft is constantly measured


by the internal potentiometer and compared with the
target position set by the controller (e.g. the Arduino).

 The control electronics adjust the actual position of the


output shaft so that it matches the target position. This
is known as a closed-loop control system.

 The gearbox decreases the speed of the motor, which


increases the torque at the output shaft. The maximum
speed of the output shaft is usually around 60 RPM.
Servo control
 Servo motors are controlled by sending a PWM (pulse-
width modulation) signal to the signal line of the servo.

 The width of the pulses determines the position of the


output shaft.

 When you send the servo a signal with a pulse width of


1.5 milliseconds (ms), the servo will move to the
neutral position (90 degrees). The min (0 degrees) and
max (180 degrees) position typically correspond to a
pulse width of 1 ms and 2 ms respectively.

 Note this can vary slightly between different types and


brands of servo motors (e.g. 0.5 and 2.5 ms). Many
servos only rotate through about 170 degrees (or even
only 90) but the middle position is almost always at 1.5
ms.
360-degree (continuous) vs 180-degree
(standard) servo
 Most RC servos are from the 180-degree variety, which means that
they can only rotate in a range of 0 to 180 degrees. However,
continuous rotation, also known as 360-degree servo motors, are also
available.

 Continuous rotation servos react differently to the control signal than


standard 180-degree servos. With a continuous rotation servo, you
can not control the exact position of the output shaft, only the
speed and the direction. A 1 ms pulse will set the speed of the servo
motor to full speed in one direction and a 2 ms pulse to full speed in
the other. A value near 1.5 ms lets the motor stop.

 If your servo behaves in an unexpected way, you might be using a


continuous servo instead of a standard one.
 Wiring a servo motor is very easy because you
only need to connect three wires: power,
How to connect a servo motor to
ground, and signal. The power wire is typically the Arduino?
red and needs to be connected to 5 V.

 A micro servo like the SG90 consumes around


10 mA when it’s idle and 100 – 250 mA when
rotating, so you can power it directly with the
5 V output of the Arduino. However, you need
to be careful when using multiple or larger
servo motors. 

 If your motor(s) consume more than 300


mA you should use an external power
supply to avoid damaging the Arduino!

You might also like