How to Control Servo Motor Speed with Arduino

Actually, the working principle of servo motor is the angle where it will rotate (commanded by a controller) and not at whatever speed it rotates or which direction it will rotates, to right or to the left? No, a servo motor only knows the angle, not direction. If existing position now in the corner 00 and the controller ordered it to spin 900 then it will rotate clockwise. And conversely, if the current position is 1800 and the controller ordered it to spin 450 for example, then the motor will rotate counter clockwise. So once again, the servo motor only knows ‘angle’ parameter not direction or speed.

How to Control Servo Motor Speed with Arduino?


As I mentioned in the preceding paragraph, a servo motor has only one rate of speed (by manufacturer default). How measure the speed? Speed parameter usually specify in specifications / datasheet. For example, Tower Pro SG90 servo motor has a speed of 0:12 seconds / 60 degrees. In other word its speed is 0.72 RPS (Rotation per Second) or 43 RPM (Rotation per Minute).  Well, the servo motors will towards a certain angle with this typical speed constantly. How do I adjust the speed? If you set the servo motor speed using the technique of PWM (Pulse Width Modulation), it’s obviously impossible. Well, the only way to control the speed of the servo motor is give a ‘delay’ every movement 10 of angle. Sound tricky? Yes indeed, but there is no alternative ways. :)

I will show how to control servo motor speed with set delay giving each movement 10 of angle. By giving a different delay it will get different speeds. 'Speed' rate here is relative value (e.g. fast, a little faster, slower, a little slow, etc). It can’t be exactly measured e.g. 20 RPM, RPS 0.37 RPS, etc). You have to figure out yourself how much delay that corresponds to the speed you need.

Tools and materials for Servo Motor Speed-Arduino experiments

1. Arduino board suchas Uno or others
2. Servo Motor, for example Tower Pro SG90 or MG90
3. Jumper cable male to male (3 pieces)

Connect Arduino board with servo motor under the corresponding color as follows:
Arduino
Motor Servo
5v
red
Gnd
black
9
yellow
The experiment circuit is shown in the picture below



Next, upload below sketch to your Arduino board.

#include <Servo.h>

Servo servomtr;

int pos = 0;
int servomtr_speed = 15;

void setup() {
servomtr.attach(9);
}

void loop() {
for (pos = 0; pos <= 180; pos += 1) {
servomtr.write(pos);
delay(servomtr_speed);
}
for (pos = 180; pos >= 0; pos -= 1) {
servomtr.write(pos);
delay(servomtr_speed);
}
}

If the sketch has been uploaded, the servo motors should rotates clockwise and counterclockwise alternately with speed rate according to ‘servomtr_speed’ variable in sketch above. Try to change this variable value to suit your needs.

So, it’s a little trick How to Control Servo Motor Speed with Arduino. Maybe you need this trick to slowdown your servo motor in order to join with other parts in your system.
Previous
Next Post »