Servo Motor: Basics, Working Principle, Theory And More



Here we will dive into the Servo Driving and Servo Motor World from the basics like: what is a servo motor, servo definition and how does a servo motor work to Servo vs Stepper comparison. We will also look at the types of server motors and feedback types.

We will finish with a dive in the Arduino Servo World where we see Hobby Servo, How to Control Servo with Arduino and Arduino Servo Library.


Electric motors have been around for many years. They are widely used in many applications, such as home appliances, Automation, line manufacturing and even in your smartphones.Recently electric vehicles are a new application where servos are used.

Maybe four or five decades ago we didn’t expect electric motors to work that precisely and our focus was just only on having more powerful motors which were able to do heavy duties that humans couldn’t do. But today because of the huge progression in technologies like power electronics and control, and on the other hand the growing need for precise and yet repeatable tasks, the need for motors that can be controlled precisely has significantly increased. So in order to respond to the demand of precise motion the servo motor came to market and changed the game. So nowadays having a position control system with 2*10^(-5) degrees is something common in the industry. Can you imagine so many delicate tasks like surgeries can be done using servos?

Servo Motor Applications

Nowadays servo motors are used in many applications like antenna positioning, line manufacturing, robotics, CNC, and metal cutting and forming machinery. They are even used in your smartphones to change the focus of its camera. As you can see, they are used in a wide range of sizes and powers.

Imagine a robotic arm that is used to do precise tasks like welding or a metal forming machine.

So to name a few servo applications:
  – Robotic arms: These equipment are fairly used in industrial manufacturing and servos are the very basic part of them.
–   Camera: Servos are used to do the autofocusing and also to position a camera.
  – Metal machinery: CNC and cutting machines are one of the main uses of servos. These machines are used to cut and form metal sheets.
  – Line manufacturing: Servos in collaboration with other components are used in production lines to do tasks like moving materials and components, sorting the and automating operations where need to be done precisely.
  – Electric mobility: Electric mobility, electric vehicles particularly, are a big era of using servos. This field is getting more popular so fast and is becoming one of the biggest markets of servos.

In addition to what is listed here, there are many other applications that serve as a key component in them. For example, remote surgeries which are getting more common.

What is a Servo Motor

Servo motor is part of a motion control system that produces motion in response to a command. To do the job, there should be a closed loop control system. This simple closed loop control system consists of an actuator which here is an electric motor, a sensor to measure controlling parameters, and a controller to generate suitable commands to achieve the desired output. So in order to understand servos better, let’s take a look at a simple diagram of a closed loop control system.

Servo Motor | Basics, Working Principle, Theory, and More! 1
A negative feedback closed loop control system receives an input signal as the command. If the actual value of the system output differs from the value declared by the command, it means the system has an error. This command in a servo mechanism can be a specific angle that must be obtained. The amount of the error is calculated and then fed to the controller which is often a sophisticated PID. Then the system starts reacting to the command which is generated by the PID. Here we can say the motor’s shaft starts rotating. Meanwhile, The output of the system is measured and the change in motor shaft angle is continuously measured by a sensor.

Servo Mechanism Chart

Now that we have a better understanding of closed loop control systems, we can take a deeper look at the servo motor mechanisms world. Servo motor mechanism is also a closed loop control system and is established based on negative feedback. You can see what’s going on in a servo system more clearly in the picture below.

Servo Motor | Basics, Working Principle, Theory, and More! 2
The program task is to create the desirable command based on the whole system task. Program sends a command to the controller and the controller, based on both the current output and the desired output, sends to the driver a signal. Driver Converts this signal to current to feed the motor. The encoder reads out the position and sends it back to the driver and the controller


You might have seen many source codes so far. For example an arduino blinking code or maybe a complicated face detection code. A servos system also needs a code to tell the system what must be done in every situation. ّIn other words the source code is the input logic of the whole servo system and is in charge of issuing appropriate commands based on the whole system situation. This source code can be written in different languages. It can be in assembly, C, C++ or even ladder if the system is run by a PLC.


The controller is where the source code is interpreted. When the source code is ready it’s downloaded to the controller and runs. Controllers of servo systems are the same as other control systems. Based on the application the controller system can be of many kinds. Arduino is maybe the most common controller which is used mostly for prototyping or for educational purposes. On the other hand in Industrial Projects when a high level of reliability and safety is required, PLCs are the best choice. In many projects you might need to have your own customized controller which is designed based on microcontrollers, DSPs ,FPGAs, SOCs etc.


The driver is an electronic amplifier that provides electric power for the servo motor based on the motor type. It’s also in charge of monitoring the position sensor. The driver receives its command from the controller and modifies the electrical power so that the motor reaches the desired output. Servo drivers are powered by DC, 1-Phase, or 3-Phase AC based on their application and architecture. This Input power is then converted to the desired AC or DC through a power electronic circuit and finally fed to the servo mechanism.
Noice: Some manufacturers combine the controller and driver into one module. It doesn’t change the procedure. But of course, it makes the system more compact and most of the time yields to more simplicity.


An electric motor makes the electrical power into mechanical power and then to motion. Driver powers the motor up and forces it to rotate. The power fed to the motor and its timing determines its amount of rotation, speed, and torque. Motors have different types and most of the time servo systems are categorized based on the motor type. The motors available in the market are mostly DC brushed or brushless or AC synchronous or asynchronous type.

Sensor (Encoder)

Encoder is the last part in the flowchart above. Every closed-loop feedback system needs a sensor in order to measure the controlling parameter. In a servo system, the output is the position or speed of the servo’s shaft. The Encoder measures the angular change and sends it back to the driver and controller. So the system controller can monitor the output status and issue the corresponding command based on that.
Some of the servo motors available in the market are mostly self-contained which has an integrated circuitry to receive commands and also an integrated feedback system that is used to determine the angular position of its shaft. For example, SG90 is a micro servo that contains a driver motor and encoder. e two main types of servo motors which are AC servo motor and DC servo motor.

Types of Servo Motors

Servo Motor or Servo are not a specific class of motor, this term is often used to refer to a motor suitable for use in a closed-loop control system. Here is a list of the most used motors.

DC Servo Motor

This servo type uses a dc motor as their moving part. One of the most important advantages of DC motors compared to other types of motor is their motion control simplicity. DC motors are mostly of permanent magnet type which is cheap and easy to use. There are two major types of DC motors which are called Brushed and Brushless DC motors.

Brushed DC Motors

Brushed DC motors, which are the older type, are the simplest type of motor and so easy to use. They consist of a stator and a rotor. The stator is mostly made of permanent magnet material and creates N and S poles. These two magnetic poles create a magnetic field.
The other main part is the rotor. Rotor has a bunch of windings that are wired through multiple slots all around the core. The rotor is mechanically coupled to the shaft of the motor. The power implied to the motor is fed to its rotor and magnetizes it. The interaction between stator and rotor creates a torque that rotates the shaft.

Powering rotor is made through commutators and brushes. This is where the name “brushed dc motor” comes from. Commutators are copper plates that are around the shaft and are electrically connected to rotor windings. Brushes one the other hand, are two junctions that are made of natural graphite and finely divided metals. Brushes slip on the commutators and conduct the input current through them to the rotor windings while the shaft is rotating. Since The brushes are not permanently connected to the rotor and slip on it, they need to be changed frequently which not only increases maintenance cost, but also decreases reliability. These parts also add some extra resistance which reduces the overall efficiency of the motor. In the following picture, you can see an image of parts of a brushed dc motor.

Though brushed dc motors are cheap and easy to use, they need more maintenance than other motor types because of their brushes. So they are not a good choice to be used where a high degree of reliability is desired or maintenance might be costly.

Brushless DC Motors

Brushless dc motor is the other type of dc motor and as its name implies, it has no brushes. In this type, the commutation is done by electronic circuitry. This circuit consists mainly of transistors, Mosfets, IGBTs, … as switches, and a hall effect sensor. So, unlike the brushed type, this one can’t be connected directly to a dc power supply and needs a driver.

The stator is made of the permanent magnet material. The rotor magnetic field is made by powering the stator coils through the driver. These two magnetic fields create the torque needed to rotate the rotor.

Brushless dc motors (BLDCs) are more expensive, but more reliable and less noisy compared to brushed dc motors and are preferred where more reliability and less maintenance is desired.

AC Servo Motor

AC motors are another type of electromotors. This type of motor is powered by either a single or three phase ac current. AC servo motors have two types which are called asynchronous ac motors and synchronous ac motors. This type of electric motor is more reliable and more rigid than dc motors and are available in higher powers. The rotation speed of ac motors is determined by the input frequency.

Asynchronous AC Motor

This one is the most common motor type used in servo systems. Let’s get into more details of its structure to get to know how it works. This type uses AC current to act. The stator includes windings that absorb input power. The input AC current flows through these windings and creates a rotational constant magnitude magnetic field. On the other hand, the rotor has no winding and consists of copper bars whose endings are connected together by copper rings and create a cage shaped structure. That’s why they are also called squirrel cage rotors. While the magnetic field generated by the stator winding currents rotates around the rotor, it induces a voltage along the rotor bars and this is why this type is also called an “induction motor”. This voltage causes a current to flow in these bars which results in another magnetic field. This magnetic field tries to follow the magnetic field of the stator and as a result, rotates the rotor with itself. So the rotor starts moving and speeds up, but it never can reach the speed of the stator magnetic field because in this case no varying magnetic would cut the rotor bars and so there would be no induction. So the rotor always rotates at a speed that is a bit lower than the magnetic field and these two never get synchronized. The rotational speed of the magnetic field is determined by the input power frequency. So we call this type an asynchronous ac motor.

Synchronous AC Motor

Synchronous AC motor is another type of electromotor that can be used in a servo system. The difference between it and the synchronous type is in the rotor. Unlike an induction motor, the rotor is a permanent magnet, so the motor does not use induction to create a magnetic field for the rotor, as it has its own permanent field. In this type, the rotor rotates with the exact speed of the stator magnetic field. Sometimes the rotor is not made of permanent magnetic materials and a dc power supply is used instead to create the magnetic field.

The synchronous type is relatively more expensive compared to the induction type due to the use of a permanent magnet or an extra power supply and winding for the rotor. But its control is simpler compared to an induction motor, because it is not that highly related to the amount of loading while it’s within the nominal power range of the motor.

Final Consideration

Choosing the right motor depends on the scope and the need of the project, but we like to recoup all the major aspects we already discuss in a comparison table.
Servo Motor | Basics, Working Principle, Theory, and More! 3

Different Types of Control in Servo Motors

Based on the application, we may have different control targets. So there are three main types of control for a servo which are position control, speed control, and torque control. One or a combination of these control targets may be desired in a servos system.

Position Control

Position control is the most basic and most used control process in servomechanisms. Consider you want to move the position of a robotic arm, your smartphone wants to move its lens to focus on an object, or maybe a 3D printer is moving its arm. These are examples of when position control comes into place. In these cases, you need to control the exact position of the actuator with the most possible precision.

Based on the application there are two procedures for positioning in the position control system, which are relative positioning (distance) and absolute positioning (position). In distance positioning, the amount of movement of the actuator is important but not where it is. For example, a machine’s task is to drill a metal surface every 10 centimeters. In this case, it moves the object or its arm by 10 centimeters each time. On the other hand, in the same example, if the exact position of the holes is important, the arm should know where to start the process and where to go when it drills every time. For using position control a technique called homing is used. Homing is the process of determining the origin of an actuator’s position in which its position must be controlled. Every position control system needs to have a procedure that could be used to determine its zero or home point. All the measurements are done based on that position.

Speed Control

In some cases, one might need to control the movement speed of an arm or instead of its position. A conveyor system can be a good example of implementing speed control. Imagine a system whose goal is to carry objects from one point to another at the desired speed no matter how much they weigh.

Torque Control

Torque control is another mode of control for servo motors. In this mode, the amount of torque (or we can say force) that is provided to the task must be controlled. This mode is mostly used when changes in torque can cause damage or a malfunction. For example, if the torque of an arm exceeds it might break the object it holds.

Feedback Sensors

Servo motors mostly use two types of sensors to measure displacement. They can use potentiometers or encoders.


Consider a rotary potentiometer whose resistance varies while it rotates. By using a voltage supply we can create a divider circuit. The voltage measured on the variable tap of the potentiometer changes as the potentiometer rotates. In this way by measuring the voltage we can measure the angular rotation and of the potentiometer. So if we connect the motor shaft to the potentiometer knob, then we can measure its movement.

Potentiometers are mostly used when the accuracy and constancy of measurement is not that crucial. In order to get good results, you should use a high quality potentiometer whose resistance varies without jumping and glitching while rotating. This type of sensor can’t be used well for speed measurement. Therefore it can be used only in less sophisticated servomechanisms that are not that precise.

Optical Incremental Encoder

The encoder on the other hand is equipment that uses optics to measure rotation. They use an optical transmitter and an optical receiver. There is a round plate that has several holes around it. This plate is mechanically coupled to the motor’s shaft. While the motors and the plate rotate, the light passes through the holes or gets blocked. The number of times the light passes through the plate determines the angular rotation. You can see a graphical description of these parts in the following images.
Servo Motor | Basics, Working Principle, Theory, and More! 4
It is good to know that optical encoders are a bit more complicated than this. Because they need a mechanism to determine the rotation direction. To do this the use another row of holes that has a bit of displacement compared to the main holes and depending on which row of holes is first achieved in each pulse, it can determine the direction of rotation.

The precision of the encoder is determined by the number of these holes. For example, if an encoder has 1000 holes on it, it can measure the displacement of 360/1000 = 0.36 degrees. One important thing to consider when choosing an encoder is its precision. More holes lead to higher precision, but on the other hand, you need a faster digital pulse reader (High Speed Counter) in order to monitor the burst of pulses. This gets more challenging at higher speeds since the number of pulses per second is the number of the holes multiplied by the speed:

Pulse Frequency = Number of Holes * RPM /60

So, for an encoder that has 2000 holes, at a speed of 3000 rpm, the frequency is 100 kHz.
As you can see this type of encoder can’t determine the exact position, but the displacement. There are absolute encoders, but they are more expensive and less convenient compared to the incremental type.

Encoders are used in industrial applications which are more precise, reliable, and more noise prone. They have digital outputs which can be an advantage compared to encoders.

Servo vs Stepper

Stepper motors are another type of motor that are used widely in positioning systems. Due to their inherent ability to control their angular position, obtained thanks to the way they are built, using them is so straightforward. A stepper motor is powered through its stator windings. By powering these wingdings a magnetic field is created. This magnetic field absorbs the stator and forces it to rotate. So each time exactly the next stator pole is magnetized. So they need a driver to power their windings. Most stepper drivers receive a pulse and move the stepper’s schaft a particular angle. For example a stepper motor with 200 steps per round, rotates by 360/200 = 1.8 degree, when a pulse is sent to its driver.
Servo Motor | Basics, Working Principle, Theory, and More! 5

Stepper Motors Control Mechanism

The control mechanism of the stepper motor is totally different from a servo. A stepper motor controls its output without implementing feedback. Each pulse which is received by the driver input, is considered to make a specific change in the shaft’s position. So for a specific amount of movement, the number of steps must be calculated. You can see the stepper control command flow in the diagram below.
Servo Motor | Basics, Working Principle, Theory, and More! 6
The program which is developed by the motion control designer is downloaded to the controller. Controller to rotate the motor by means of the driver. The procedure is so straightforward.


Positioning Performance

Since steppers don’t have a feedback sensor, they might have errors in their shaft position which can’t be detected. This error mostly occurs due to missing steps. If the load is not suitable for the stepper or the moving mechanical parts haven’t been well designed or suitably coupled together, misstepping steps may occur. So It means that position control systems that use steppers, need to have a home or zero position point, to use as a reference in order to calibrate the position.

Torque vs Speed Performance

The other important point to consider using a steppe,r is their unsatisfying performance at high speeds. The torque of the stepper’s shaft decreases significantly as the speed increases. This increases the number of missed steps and also might cause the stepper to halt under low loads. On the other hand, servos stabilize their shaft torque by absorbing higher currents at higher speeds. So they are more sophisticated to operate at higher speeds. In a nutshell, if you have a constant load whose speed doesn’t vary in a wide range, a stepper can do the job, but otherwise, you should stick to a servo! For example, if you’re into creating a 3D printer or a laser cutter, a stepper is a good choice, because the load is so light and constant. In addition, every time you are printing a new object or cutting a new sheet, positioning resets which compensates for previous errors. On the other hand in a CNC milling machine where the load is heavy and variable, you can’t use a stepper at all.

Holding Torque

The torque which a motor can provide to maintain its shaft position when it’s under a force is called Holding torque. Stepper motors provide a higher amount of holding torque. So if maintaining the position of the shaft is an important task, choosing a stepper over a servo has its benefits.


Steppers are less expensive compared to servos as they require less components because they don’t use an Encoder for the Feedback. In addition, they usually need a simpler controller and simpler program to perform the position control task. These all diminish the overall cost of the position control mechanism. On the other hand, servos are more expensive, harder to implement, and thus more time consuming.

Final Consideration

As we see, though steppers are easy to use and less expensive compared to servos, servos have crucial advantages over servos, which are the precision of the movement, and the ability to know the exact angle of the shaft. Therefore steppers are mostly used in applications where their load torque is not much and a little error in placement is acceptable. And servos are used in projects with a higher level of reliability and precision.

Servo Motor | Basics, Working Principle, Theory, and More! 7

Industrial Servo Drives

In the robotic industry it is always necessary to have moving parts. The moving process can be of different types. Though some are as simple as moving a pneumatic cylinder back and force, in some cases it can be more challenging. Consider a three joint robotic arm which is in charge of picking up an object and putting it somewhere else.
Servo Motor | Basics, Working Principle, Theory, and More! 8

Image references here.

The motion of such a robot is a big challenge and needs a bunch of considerations. In this case the motion of all the joints should be determined considering the position, velocity and acceleration constraints. A poor motion planning obviously yields undesired behavior which might cause the robot to fail to perform its tasks. Here we are to address some of the challenges in robot motions and the solutions.
First let’s take a look at different components which are used in industry to perform motion planning tasks.

Servo Motor Control

A servomechanism is a closed loop control system. It uses encoders to measure the amount of displacement. The main task of a servo driver is reaching the desired position at desired time. In order to do this task, a servo drive should not only be able to measure and control position, but also to control torque and speed during the process. This yields a more robust and reliable control system. In the following picture you can see a diagram of a closed loop control system that is used in SOLO motor controllers, typically used in industrial servo drives to control position, speed and torque.
Servo Motor | Basics, Working Principle, Theory, and More! 9

Hobby Servo

If you are interested in experiencing the joy of doing position control projects and don’t have access to industrial servomechanisms, or you want to prototype a motion control project- a simple robot for example- hobby servos are a perfect option for you. Hobby servos are very tiny motors that can run with currents to the small extent of a few milliamperes provided by a 5 volt voltage source. They are not longer than 3 or 4 centimeters in every direction and have all the necessary components a whole servo system must have.

If you want to do a position project you need a standard servo. The amount of rotation in each direction is limited in this type of motor. Otherwise, if you want to do a speed control project, you can use continuous or open-loop hobby servo. This type can rotate freely at your desired speed.

Servo Motor | Basics, Working Principle, Theory, and More! 10

Hobby servos consist of three main parts which are:
  – A dc motor.
  – A potentiometer to measure position.
  – An electronic circuit to control position.
Everything is enclosed in a single box.

These motors are driven with only three wires:
  – Positive input voltage.
  – Input command.
  – The ground.

Here is an example where is possible to see the components and cables of a hobby servo:

Servo Motor | Basics, Working Principle, Theory, and More! 11

Hobby Servo Sizes

Most servos found in the market are in sizes which are micro, standard, and giant. The power and therefore the torque amount gets more by choosing the bigger size. You can see an example of these three sizes (in mm) in the picture below.

Servo Motor | Basics, Working Principle, Theory, and More! 12


In this part, we are going to introduce to you a micro servo which is totally a good choice for beginners and also for small projects and a good Arduino servo to start with. SG90 is of the position control hobby servo type and has the capability of controlling it’s position in approximately 180 degrees. It’s a self contained package, including motor, feedback sensor, and driver and You need just 3 wires to control the position. These three wires are +5V, GND and Pulse. The pulse output actually is a PWM signal with a 20 ms period. The high value of the signal is between 1ms and 2ms and determines the amount of angular position change. So 1ms means -90 degree change in the position and 2ms means +90 degree in position. Obviously, a 1.5 ms duration pulse makes no movement in the motor. In the picture below you can see how the PWM signal command works clearly.

Servo Motor | Basics, Working Principle, Theory, and More! 13

Arduino Servo

Now, we will show how to control a servo with Arduino, more precisely a hobby servo, and thanks to Arduino guys, who created the Arduino servo library you don’t even need to create a PWM signal and it’s duty cycle using timer registers. There is a simple Arduino servo library called “Servo.h” integrated into the Arduino IDE that can be used to drive SG90 or any other servo with the same type of command and power.

In higher Powers, where the motor is bigger, or it uses a more advanced feedback signal, a specific component called a “motor controller” is needed. The “motor controller” will handle the motor complexity and also will simplify the work of the Arduino side. Same as this motor controller which is made with very specific functionality and shape, there are also Arduino servo shields that are able to stack on top of an Arduino and simplify the connection phase.

Schematic Section

In order to create a simple robot using a hobby servo like SG90, we need some components listed below:
  – An Arduino (UNO or only other model you are used to)
  –  A SG90 hobby servo
  – A 5V power supply
  – A bunch of wires

Here we will explain how to connect a servo to Arduino, as we are using a hobby servo, the connection is easy and as you can see in the schematic:

Servo Motor | Basics, Working Principle, Theory, and More! 14
As explained earlier in the article, SG90 has 3 wires which should be connected to the ground, +5 V, and an Arduino PWM generator pin.

Code Section

Code wise, in order to control servo like SG90 or SG9 using the library “Servo.h”, in your code you need to create a servo and yous it’s methods. Here you can see a list of all the methods of the servo class. We are going to explain this in detail and show you some code examples.

  –  attach(pin)
This method is used to assign a digital pin to servo command. So you can send the pulse (PWM) to the servo and set its position.

  –  write(angel)
This method is used to set the angle of the servo. Angle could be a number between 0 and 180. If you want to set the position of the servo to, for example, +90 degree, you need to use, “write(180)” command.
Notice: On continuous servos, this method is used to specify the speed. For example, write(0) means negative full speed and write(180) means positive full speed.

  –  writeMicroseconds()
It’s another method to control the shaft angle. As it’s mentioned earlier in the article, SG90 accepts a Pulse with a duty cycle between 1000 and 2000 us. So if you send a writeMicroseconds(1000) or writeMicroseconds(1000) , it means that the servo should rotate to -90 or +90 degrees respectively.

  –  read()
This method is used to read the current position of the servo

  –  attached()
This method has a parameter which is the pin you want to check if a stepper is attached to. It returns true if the pin is attached to a servo and false if not.

  –  detach()
If you don’t want to use a pin as a servo variable or are worried about the unwanted movement of the servo attached to a pin, you can detach the servo variable from the pin by this method.

You can see down below a simple code to drive a SG90:

Share This

Share This

Share this post with your friends!