01205302_Servo_Motor_v01
01205302_Servo_Motor_v01
UNIT 7
Servo Motor
Section ▢ 11 ▢ 250 ▢ 450
Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ID. . . . . . . . . . . . . . . . . . .
Instructor Part
A servo motor is a closed-loop system that uses position feedback to control its motion
and final position. There are many types of servo motors and their main feature is the
In industrial type servo motors the position feedback sensor is usually a high precision
encoder, while in the smaller RC or hobby servos the position sensor is usually a simple
potentiometer. The actual position captured by these devices is fed back to the error
detector where it is compared to the target position. Then according to the error the
controller corrects the actual position of the motor to match with the target position.
Hobby servos are small in size actuators used for controlling RC toys cars, boats, airplanes
etc. They are also used by engineering students for prototyping in robotics, creating
There are four main components inside of a hobby servo, a DC motor, a gearbox, a
potentiometer and a control circuit. The DC motor is high speed and low torque but the
gearbox reduces the speed to around 60 RPM and at the same time increases the torque.
2
The potentiometer is attached on the final gear or the output shaft, so as the motor
rotates the potentiometer rotates as well, thus producing a voltage that is related to the
absolute angle of the output shaft. In the control circuit, this potentiometer voltage is
compared to the voltage coming from the signal line. If needed, the controller activates
an integrated H-Bridge which enables the motor to rotate in either direction until the two
A servo motor is controlled by sending a series of pulses through the signal line. The
frequency of the control signal should be 50Hz or a pulse should occur every 20ms. The
width of pulse determines angular position of the servo and these type of servos can
3
Generally pulses with 1ms duration correspond to 0 degrees position, 1.5ms duration to
90 degrees and 2ms to 180 degrees. Though the minimum and maximum duration of the
pulses can sometimes vary with different brands and they can be 0.5ms for 0 degrees
MG995 servo is a simple, commonly used standard servo for your mechanical needs such
as robotic head, robotic arm. It comes with a standard 3-pin power and control cable for
Mechanical Specification
Size 40.4*19.9*37.5mm
Weight 58g
Bearing DUAL BB
4
Connector wire FP: 240mm±5mm JR: 300mm±5mm
Motor DC motor
Electrical Specification
Control Specification
5
Learning Unit
1. Sweep Circuit
Servo motors have three wires: power, ground, and signal. The power wire is typically red,
and should be connected to the 5V pin on the Arduino board. The ground wire is typically
black or brown and should be connected to a ground pin on the board. The signal pin is
typically yellow or orange and should be connected to PWM pin on the board. In these
examples, it is pin number 9. For the Sweep example, connect the servo motor to +5V,
GND and pin 9. Sweeps the shaft of a RC servo motor back and forth across 180 degrees.
Sketch 1
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
6
void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
Check
7
2. Knob Circuit
For the Knob example, wire the potentiometer so that its two outer pins are connected
to power (+5V) and ground, and its middle pin is connected to A0 on the board. Then,
Sketch 2
#include <Servo.h>
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
// reads the value of the potentiometer (value between 0 and 1023)
val = analogRead(potpin);
// scale it to use it with the servo (value between 0 and 180)
val = map(val, 0, 1023, 0, 180);
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}
8
Q2-1. Explain sketch 1 corresponding to its result.
Check
9
Problem
P1. Use the LCD with keypad shield to control and display the angle of servo motor.
Sketch P1
Problem 1 (10)
10
Reference
[2] makeblock.com, Micro bit lesson — Using the Ultrasonic Module MG995 Standard
Feb, 2022
11