Material Required

  1. Arduino UNO
  2. Servo Motor
  3. Power Supply
  4. Breadboard
  5. Connecting Wires


Circuit Diagram



What is a Servo Motor?

Before going into detail, first we should know about Servo Motors.

Servo motors are available at different shapes and sizes. A servo motor will have mainly there wires, one is for positive voltage another is for ground and last one is for position setting. The RED wire is connected to power, Black wire is connected to ground and YELLOW wire is connected to signal



A servo motor is a combination of DC motor, position control system, gears. The position of the shaft of the DC motor is adjusted by the control electronics in the servo, based on the duty ratio of the PWM signal the SIGNAL pin.

Simply speaking the control electronics adjust shaft position by controlling DC motor. This data regarding position of shaft is sent through the SIGNAL pin. The position data to the control should be sent in the form of PWM signal through the Signal pin of servo motor.

The frequency of PWM (Pulse Width Modulated) signal can vary based on type of servo motor. The important thing here is the DUTY RATIO of the PWM signal. Based on this DUTY RATION the control electronics adjust the shaft.

As shown in figure below, for the shaft to be moved to 9o clock the TURN ON RATION must be 1/18.ie. 1ms of ON time and 17ms of OFF time in a 18ms signal.

For the shaft to be moved to 12o clock the ON time of signal must be 1.5ms and OFF time should be 16.5ms. This ratio is decoded by control system in servo and it adjusts the position based on it. This PWM in here is generated by using ARDUINO UNO

Code
#include <Servo.h>

Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;

int i = 0;

void setup () {
   servo1.attach (3);
   servo2.attach (5);
   servo3.attach (6);
   servo4.attach (9);
}

void loop () {
   for (i = 0; i <180; i ++) {
     servo1.write (i);
     servo2.write (i);
     servo3.write (i);
     servo4.write (i);
     delay (10);
   }
   for (i = 180; i> 0; i--) {
     servo1.write (i);
     servo2.write (i);
     servo3.write (i);
     servo4.write (i);
     delay (10);
   }

}

No comments

Theme images by Dizzo. Powered by Blogger.