Servo motors are one of the most commonly used actuators in embedded systems, robotics, and automation projects. Their popularity comes from their ability to provide precise angular control over mechanical movements. In this tutorial, we will explore how servo motors work, how to interface a servo motor with an Arduino UNO, and how to control its position using both the Arduino Servo library and custom PWM code.
What is a Servo Motor?A servo motor is a type of rotary actuator or motor that allows for precise control of angular position, speed, and acceleration. It is commonly used in applications such as robotic arms, camera gimbals, RC cars, and automatic door openers.
A servo motor typically consists of the following internal components:
- A DC motor
- A gearbox (gear train) for torque amplification
- A feedback sensor (typically a potentiometer or encoder)
- A control circuit to manage input signals
- An output shaft that delivers mechanical rotation
The internal circuitry of a servo motor uses a closed-loop feedback system. Here’s how it works:
- A PWM signal is sent from the microcontroller (e.g., Arduino) to the servo's control pin.
- The control circuit inside the servo compares the PWM signal (target angle) with the actual position provided by the feedback sensor.
- If there is a discrepancy between the current and desired position, the internal DC motor rotates the shaft in the required direction.
- This process continues until the desired angle is reached.
This feedback loop ensures that the servo moves accurately to the commanded position and maintains it.
Working Principle of Servo MotorServo motors are controlled using Pulse Width Modulation (PWM) signals. These signals have a fixed frequency (typically 50 Hz) but vary in pulse width. The width of the pulse (in microseconds) determines the angle of the shaft.
- A pulse width of 544 microseconds (µs) positions the shaft at 0°.
- A pulse width of 1500 µs positions it at 90° (center).
- A pulse width of 2400 µs rotates the shaft to 180°.
The PWM signal is sent approximately 50 times per second (20 ms period). The duty cycle (high pulse duration) determines how far the shaft turns.
The Tower Pro SG90 is a widely used micro servo motor in hobbyist electronics due to its compact size, lightweight body, and ease of control with microcontrollers like Arduino.
🧾 SG90 Specifications:- Weight: 9 g
- Dimension: 22.2 x 11.8 x 31 mm approx.
- Stall torque: 1.8 kgf·cm
- Operating speed: 0.1 s/60 degree
- Operating voltage: 4.8 V (~5V)
- Dead bandwidth: 10 µs
- Temperature range: 0 ºC – 55 ºC
- VCC (Power Supply Pin):This pin is connected to the positive terminal of the power source, typically 5V when using hobby servo motors like the SG90. It supplies the electrical power necessary for the internal DC motor, control circuit, and position feedback system to operate. Ensure a stable power supply, especially when using multiple servos, to prevent erratic behavior.
- GND (Ground Pin):The GND pin must be connected to the negative terminal of the power supply or ground (GND) of the microcontroller. It provides a common reference point for all voltages in the circuit. A proper ground connection is crucial for the servo to function correctly and communicate with the microcontroller.
- Control (Signal Pin):This is the pin used to send commands to the servo motor. It receives a Pulse Width Modulated (PWM) signal from a microcontroller (such as an Arduino), which determines the angle of rotation. By varying the duration of the high pulse in the PWM signal, the position of the servo shaft can be precisely controlled.
In the wiring diagram above, a micro servo motor is connected to an Arduino UNO. The VCC pin of the servo is connected to the 5V output of the Arduino using a red wire, providing the necessary power to the motor. The GND pin of the servo is connected to the GND pin of the Arduino using a black wire, completing the electrical circuit. The control (signal) pin of the servo is connected to digital pin 10 of the Arduino, which is a PWM-capable pin used to send control signals for positioning the servo arm.
VideoTo learn more checkout: How to Control Servo Motor with Arduino
Comments