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.
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 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.
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
Brushed DC Motors
Brushless DC Motors
AC Servo Motor
Asynchronous AC Motor
Synchronous AC Motor
Different Types of Control in Servo Motors
Optical Incremental Encoder
Pulse Frequency = Number of Holes * RPM /60So, 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 Control Mechanism
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.
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.
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.
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.
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:
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.
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.
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.
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:
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.
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.
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.
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.
This method is used to read the current position of the servo
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.
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: