• Skip to main content
  • Skip to primary sidebar

Homemade Circuit Projects

Get free circuit help 24/7

New Projects | Privacy Policy | About us | Contact | Disclaimer | Copyright | Videos 

You are here: Home / Arduino Engineering Projects / How to Interface Servo motors with Arduino

How to Interface Servo motors with Arduino

Last Updated on May 17, 2019 by Swagatam

In this post we are going to learn what servo motor is, how it functions, how to interface with microcontroller and what make this motor special from other motors.

Being an electronics enthusiast we would have come across many kinds of motors, here we are going to take a look at special type of motor called servo motor.

What is a Servo motor?

Servo motor or simply servo is a special type of motor which is designed for precise control over position, acceleration and velocity. Unlike all other types motor, servo can only rotate 180 degree bi-directional. It has mechanical gears and stopper which limit the angular rotatory of servo.

Typical servo motor: 

caution electricity can be dangerous

The servo motors are used in robotics, CCTV cameras, RC cars, boats, toy aircrafts etc. Servos are used where we no need continues rotatory motion, but lock in a specific position or move some load with controlled velocity within the moveable angular limit.

Servo aren’t simply a motor like other types, but it is module, which combines of a normal DC/AC motor, a group of gears, control electronics and a feedback system. Let’s look at the each mentioned stages in detail.

DC/AC motor which is employed on a servo module can be brushless or brushed motor, on most of the hobby servos DC motor is used and AC motors are used in industrial applications. The motor gives rotational input to the servo. The motor rotates at several hundred RPM inside the servo and output rotation is about 50 or more times less of its RPM.

The next stage is the gear assembly, which control the angular rotation and speed of servo. The gear may be made from either plastic or metal depending on how bulky the load is. Generally DC motors are run at high RPM and low torque; the gear assembly will convert the excess RPM into torque. Thus a small motor can handle a huge load.

The next stage is control electronics which constitutes of MOSFETs and ICs for controlling the rotation of the motor. A feedback system is always present in servo motors for tracking the current position of the actuator.

In servos generally a feedback component is a potentiometer, which is directly connected to rotating actuator. The potentiometer acts as voltage divider which is fed to the control electronics. This feedback helps control electronics to determine the amount of power given to the motor.

A servo motor in a fixed position will reluctant move from its current position if any external force try to disturb. The feedback system monitors the current position and powers the motor against external disturbance.

The above scenario is same when the servo is moving its actuator. The control system will compensate the external force and move in determined velocity.

By now you know quite a bit about servo motor and its functioning mechanism. Let’s see how to control the servo motors using microcontroller.

Servo motors have 3 terminals unlike other motors which have 2 terminals, two for supply (5V nominal) and one for control signal. The wires are coloured for easy identification of terminals.

The control signals of servos are PWM at 50Hz frequency. The pulse width of the signal determines the position of the actuator arm. A typical hobby servo motor operates from 1 to 2 milliseconds pulse width.

Applying 1 ms pulse width control signal will keep the actuator at 0 degree position. Applying 2 ms pulse width control signal will keep the actuator at 180 degree position. Applying signals in between 1-2 ms will keep the actuator within 0-180 degree angle. This can be better understood by given below image.

 

By now you would have understood how a servo is controlled by pulse width modulation (PWM).

Now let’s learn how to interface a servo motor with Arduino.

Circuit diagram: 

how to interface a servo motor with Arduino.

The wiring is easy and self-explanatory. You need external power supply if you are using a bulky servo motor. If you try to power from arduino power’s supply you will end-up overloading the USB port on the computer.

If you have servo similar which is illustrated at the beginning of the article, then you may power it from arduino 5V supply, also shown in author’s prototype.

Author’s prototype: 

Arduino need servo library for handling it, it made our task easy and it’s already in the Arduino IDE.

Program:

//--------Program developed by R.Girish--------//
#include <Servo.h>
Servo motor;
int pos = 0;
int t=10;
void setup()
{
motor.attach(7);
}
void loop()
{
A:
pos=pos+1;
motor.write(pos);
delay(t);
if(pos==180) { goto B;}
goto A;
B:
pos=pos-1;
motor.write(pos);
delay(t);
if(pos==0) { goto A;}
goto B;
}
//--------Program developed by R.Girish--------//

The above program will sweep the actuator 0 to 180 degree right and 180 to 0 degree left and cycle repeats. This is a simple program for testing the servo; you may need to write your own code for your customized applications.

You'll also like:

  • 1.  Using Digital Potentiometer MCP41xx With Arduino
  • 2.  Controlling LED Strip Light ON/OFF and Brightness with any Remote Control
  • 3.  Arduino PWM Signal Generator Circuit
  • 4.  Water/Coffee Dispenser Motor Circuit
  • 5.  Password Security Lock Circuit Using 4×4 Keypad and Arduino
  • 6.  SMS Based Pump Controller with Automatic Dry Run Shut Off

About Swagatam

I am an electronic engineer (dipIETE ), hobbyist, inventor, schematic/PCB designer, manufacturer. I am also the founder of the website: https://www.homemade-circuits.com/, where I love sharing my innovative circuit ideas and tutorials.
If you have any circuit related query, you may interact through comments, I'll be most happy to help!

Have Questions? Please Comment below to Solve your Queries! Comments must be Related to the above Topic!!

4 Comments
Newest
Oldest
Inline Feedbacks
View all comments

Primary Sidebar

Categories

  • 3-Phase Power (15)
  • 324 IC Circuits (19)
  • 4017 IC Circuits (52)
  • 4060 IC Circuits (26)
  • 555 IC Circuits (99)
  • 741 IC Circuits (20)
  • Arduino Engineering Projects (83)
  • Audio and Amplifier Projects (115)
  • Battery Chargers (83)
  • Car and Motorcycle (94)
  • Datasheets (73)
  • Decorative Lighting (Diwali, Christmas) (33)
  • Electronic Components (101)
  • Electronic Devices and Circuit Theory (36)
  • Electronics Tutorial (120)
  • Fish Aquarium (5)
  • Free Energy (34)
  • Fun Projects (13)
  • GSM Projects (9)
  • Health Related (20)
  • Heater Controllers (29)
  • Home Electrical Circuits (103)
  • How to Articles (20)
  • Incubator Related (6)
  • Industrial Electronics (28)
  • Infrared (IR) (40)
  • Inverter Circuits (98)
  • Laser Projects (12)
  • LED and Light Effect (93)
  • LM317/LM338 (21)
  • LM3915 IC (25)
  • Meters and Testers (66)
  • Mini Projects (149)
  • Motor Controller (67)
  • MPPT (7)
  • Oscillator Circuits (26)
  • PIR (Passive Infrared) (8)
  • Power Electronics (34)
  • Power Supply Circuits (79)
  • Radio Circuits (10)
  • Remote Control (48)
  • Security and Alarm (61)
  • Sensors and Detectors (121)
  • SG3525 IC (5)
  • Simple Circuits (75)
  • SMPS (29)
  • Solar Controllers (61)
  • Timer and Delay Relay (53)
  • TL494 IC (5)
  • Transformerless Power Supply (8)
  • Transmitter Circuits (41)
  • Ultrasonic Projects (16)
  • Water Level Controller (45)

Calculators

  • AWG to Millimeter Converter
  • Battery Back up Time Calculator
  • Capacitance Reactance Calculator
  • IC 555 Astable Calculator
  • IC 555 Monostable Calculator
  • Inductance Calculator
  • LC Resonance Calculator
  • LM317, LM338, LM396 Calculator
  • Ohm’s Law Calculator
  • Phase Angle Phase Shift Calculator
  • Power Factor (PF) Calculator
  • Reactance Calculator
  • Small Signal Transistor(BJT) and Diode Quick Datasheet
  • Transistor Astable Calculator
  • Transistor base Resistor Calculator
  • Voltage Divider Calculator
  • Wire Current Calculator
  • Zener Diode Calculator

© 2023 · Swagatam Innovations

wpDiscuz