Blog
Servo motor
what is a servo motor?
Definition of Servo Motor
What does "servo" mean?
Origin and Meaning of "Servo"
What does " Servomechanism " mean?
What is a servo motor used for?
In robotics, servo motors are often used as the core driving device for robot joints, providing precise rotation angles and torque output to facilitate robots in completing various complex tasks, such as precision assembly of various parts, welding of components, and material handling. Their servomechanism can correct errors in real-time and enhance the smoothness of motion.
In the aerospace field, servo motors are used in aircraft control surface control systems, such as servo actuators for rudders, elevators, and flaps, to precisely adjust flight attitudes, enhance flight stability, and improve performance and reliability in extreme environments.
Among DIY enthusiasts and college student groups, small servo motors like the SG90 micro servo motor, which are affordable and easy to use, are widely applied. They combine one or more micro servo motors with other modules to create more convenient systems, such as an ultrasonic obstacle-avoidance pan-tilt combined with an ultrasonic module.
This type of ultrasonic obstacle-avoidance pan-tilt is often used in intelligent obstacle-avoidance car projects. After the ultrasonic module detects an object, it sends the information to the microcontroller for processing. Then the microcontroller controls the servo motor to move, changing the direction of the ultrasonic module. This achieves the effect of detecting multiple directions using only one ultrasonic module, reduces the use of serial ports, and simplifies code writing.
Servo motor specifications & Buy servo motor
When buying a servo motor, besides the servo motor price, the most important thing to pay attention to is the servo motor specifications. There are four main categories to note in servo motor specifications:
| Category | Parameter Name | Unit |
|---|---|---|
| I. Basic Electrical Parameters | Rated Voltage | V |
| Rated Current | A | |
| Rated Power | W or kW | |
| II. Mechanical Performance Parameters | Rated Torque | N-m |
| Peak Torque | N-m | |
| Rated Speed | rpm | |
| Maximum Speed | rpm | |
| III. Control Performance Parameters | Resolution | pulse/rev or bit |
| Positioning Accuracy | arc-sec or ° | |
| Repeatability | arc-sec or ° | |
| Bandwidth | Hz or kHz | |
| IV. Physical & Environmental Parameters | Dimensions and Mounting | mm |
| IP Rating | IPXX | |
| Operating Temperature Range | °C | |
| Weight | kg |
Below, I will introduce the parameters of several commonly used servo motor models for reference.
| Product Model | SG90 | MG90S |
|---|---|---|
| Dimensions | 23x12.2x29mm | 22.8x12.2x28.5mm |
| Weight | 9g | 12g |
| Operating Torque | 1.6kg·cm (4.8V) | 2kg·cm (4.8V) |
| Response Speed | 0.12 sec/60° (4.8V) 0.10 sec/60° (6.0V) |
0.11 sec/60° (4.8V) |
| Operating Temperature | -30 to +60°C | 0 to 55°C |
| Dead Band Width | 5μs | 5μs |
| Connector Type | - | JR, FUTABA compatible |
| Rotation Angle | 180° | Max 90° |
| Servo Type | Analog Servo | Analog Servo |
| Operating Voltage | 3.5V~6V | 4.8V |
| Construction Material | Plastic gears | Metal copper gears |
| Accessories Included | Three function arms, fixing screws, wire length 25CM | Servo wheel, wire length 25CM, accessories for fixing propeller and aluminum sleeve, etc. |
| Suitable For | Fixed-wing aircraft, helicopter KT, glider, small robot, manipulator and other models | Fixed-wing aircraft, helicopter KT, light aircraft, small robot, manipulator and other models |
What is the working principle of a servo motor?
The pinout of a servo motor is distinguished by colors. Taking the common SG90 and MG90S servo motors as examples, they generally have three leads of different colors, each with a distinct function, as follows:
| Pin Name | Common Wire Colors for SG90 and MG90S | Function Description |
|---|---|---|
| VCC (Power Positive) | Red | Provides power for the servo motor and is the energy input pin for the motor to operate. Usually needs to be connected to a stable power source, such as a 5V power supply pin on a development board, or an independent 4.8V - 6V DC power supply. |
| GND (Power Negative / Ground) | Brown or Black | Acts as the reference ground for the circuit and forms a complete current loop in combination with the power positive. |
| PWM (Signal Line) | Orange, Yellow or White | Used to control the rotation angle or speed of the servo motor. By inputting PWM signals with different duty cycles, the control circuit inside the motor will drive the motor to rotate to the corresponding position. |
Servo motor connection: VCC can be connected to the 5V pin of Arduino or the 5V pin of Raspberry Pi Pico; if the motor load is large, it is recommended to connect an external 4.8V - 6V DC power supply, and at the same time connect the power ground to the development board ground. GND is directly connected to the GND pin of the controller to ensure consistent ground potential of the entire circuit. PWM (signal line) can be connected to any PWM pin of Arduino (such as pin 9) or any GPIO pin of STM32 (PWM signal needs to be generated through a timer).
Servo motor construction
- A Motor Core as the power source;
- A Gear Train for reducing rotational speed and increasing torque;
- An Output Shaft responsible for transmitting the motor's rotational motion to external loads.
- A Servo Driver, a Feedback Sensor, and Driver Circuitry.
Servo motor working principle
The servo motor circuit diagram is as shown below. During operation, the microcontroller first sends a PWM signal to the servo motor. Then, the "brain" of the servo motor, the Servo Driver, compares the PWM signal received from the microcontroller with the feedback signal formed by the actual motion state of the motor monitored in real-time by the Feedback Sensor, calculates the error, and finally outputs a drive signal. The Driver Circuitry adjusts the current or voltage input to the motor according to the instructions received from the controller to control the motor's speed, direction, and torque. This forms a feedback system, through which the servo motor continuously corrects its position, speed, and torque.
The angle of a servo motor is determined by the duration of the working pulse applied to the control line. A servo motor expects to receive a working pulse every 20 milliseconds. The length of the working pulse determines the angle to which the servo motor rotates. For example, a 1.5-millisecond pulse will make the servo motor rotate to the 90-degree position. When the pulse sent to the servo motor is shorter than 1.5 milliseconds, the servo motor rotates to a position and keeps its output shaft deflected counterclockwise by a certain angle from the neutral point. When the pulse width is longer than 1.5 milliseconds, the situation is reversed.
How to use a servo motor with arduino
After the previous learning, I believe everyone has a good understanding of servo motors. Now let's learn a servo motor Arduino project: controlling a servo motor via buttons and a rotary encoder.
The signal wire of the servo motor is connected to pin 9. The positive poles of the three LEDs (blue, brown, and green) are connected to pins 6, 5, and 4 respectively. The buttons are connected to pins 2 and 3, and the rotary encoder is connected to pin A0. We will implement the following functions: pressing button 1 will make the continuous rotation servo motor rotate clockwise; pressing button 2 will make the continuous rotation servo motor rotate counterclockwise. When the rotary encoder is twisted, the servo motor will rotate according to the twisted angle.
Servo motor arduino code
#include
Servo myservo;
int potValue;
int degrees;
void setup() {
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
// Outputs for Debugging LEDs
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
// Outputs for servo
myservo.attach(9);
}
void loop() {
// Outputs for the debugging LEDs
digitalWrite(4, !digitalRead(2));
digitalWrite(5, !digitalRead(3));
analogWrite(6, analogRead(0)/4);
if (!digitalRead(2)) {
myservo.write(0);
} else if (!digitalRead(3)) {
myservo.write(180);
} else {
potValue = analogRead(0); // 0 to 1023
degrees = map(potValue, 0, 1023, 0, 180);
myservo.write(degrees);
}
delay(10);
}
The demonstration effect is as follows:
Relevant Materials
A video applied to a self-made automatic water dispenser
FAQ
Types of servo motors
Servo motors can be classified by power type into DC servo motors and AC servo motors. In daily life, the ones commonly used are generally DC servo motors. AC servo motors are often used in industrial control scenarios.
What is the main difference between a servo motor and a normal motor?
| Feature | Servo Motor | "Ordinary" Motor (e.g., DC Motor) |
|---|---|---|
| Control Method | Closed-loop (with feedback) | Open-loop (no feedback) |
| Main Function | Precise control of position, speed, and torque | Convert electrical energy into continuous rotation |
| Feedback System | Includes encoder or resolver | None |
| Response | Very high torque at low speeds, fast acceleration, quick response to command changes | Torque is speed-dependent (lower torque at low speeds), slower response |
| Complexity and Cost | More complex system, higher cost | Simpler design, lower cost |
| Operation Mode | Moves to commanded position and resists external forces to maintain that position | Continuous operation when powered. Speed varies with voltage and load |
| Typical Applications | Robotics, CNC machines, automated manufacturing, remote control models (for steering) | Conveyors, fans, pumps, household appliances, power tools |
Is a servo motor AC or DC?
Servo motors come in both DC and AC types.
The application of high-torque servo motors
High torque servo motors are primarily used in applications requiring powerful and precise controlled movement under heavy loads, such as in industrial robotics, CNC machinery, and automation equipment.
Servo motor vs stepper moStor
| Feature | Servo Motor | Stepper Motor |
|---|---|---|
| Control Principle | Closed-loop control: Built-in encoder provides real-time position feedback to the driver, continuously correcting errors. | Open-loop control: Infers position by counting pulses, no feedback, assuming the motor always responds correctly. |
| Torque Characteristics | Rated torque and overload torque. Can output 2-3 times the rated value for a short time (instantly) to overcome resistance. | Holding torque: Maximum torque when maintaining position. Torque decreases sharply with increasing speed. |
| Speed and Performance | Good high-speed performance: Typically up to 3000-5000 RPM or higher. Extremely fast dynamic response, excellent acceleration/deceleration performance. | Good low-speed performance: Significant torque loss at high speeds, prone to step loss. Usually operates below 1000 RPM. |
| Accuracy | High. Accuracy depends on encoder resolution (usually very high). But there is a "drift" issue that requires continuous correction through feedback. | High. Accuracy is determined by motor step angle (e.g., 1.8° per step, i.e., 200 steps per revolution). No cumulative error. |
| Vibration and Noise | Runs smoothly with low noise (especially at low speeds). | May have vibration and noise at low speeds (but can be improved with micro-stepping drive technology). |
| Cost | Higher. More complex system (requires motor, encoder, advanced driver). | Lower. Simpler system (both motor and driver are cheaper). |
| Complexity | System is complex, requires tuning (adjusting gain parameters) to achieve optimal performance. | System is simple, plug-and-play, easy to set up and use. |
| Step Loss Phenomenon | Will not lose steps. The encoder detects position deviations and corrects them immediately. | May lose steps. If load torque exceeds motor torque, the motor will lose steps, and the system cannot detect it, leading to position errors. |
| Best Application Scenarios | Applications requiring high speed, high dynamic response, and high overload capacity. | Applications requiring low cost, simple control, medium-low speed, and high holding torque. |