Presentation is loading. Please wait.

Presentation is loading. Please wait.

Istituto Tecnico Industriale A.Monaco EURLAB Control a Servo Motor If you want to swing an robot arm or … steer a robot you need a special motor (Servo).

Similar presentations


Presentation on theme: "Istituto Tecnico Industriale A.Monaco EURLAB Control a Servo Motor If you want to swing an robot arm or … steer a robot you need a special motor (Servo)."— Presentation transcript:

1 Istituto Tecnico Industriale A.Monaco EURLAB Control a Servo Motor If you want to swing an robot arm or … steer a robot you need a special motor (Servo). In this lesson, you will learn how to control a small DC Servo motor using an Arduino and further on a potentiometer (resistor). You can connect the servo motor directly to a port of a micro controller like an Arduino. Servo arm

2 Istituto Tecnico Industriale A.Monaco EURLAB Control a Servo Motor The position of a servo arm depends on the pulse width of signal which is send e.g. by arduino. Move a servo arm

3 Istituto Tecnico Industriale A.Monaco EURLAB Control a Servo Motor. The wave form depends on pulse with time t P and time of oscillation t PER. t P = 1 ms Servo arm 0° t P = 1,5ms Servo arm 90° t P = 2ms Servo arm 180° Voltage heigth 5V The Pulse must be refresched every t PER = 20 ms This manipulated signal form is called pulse width modulation (PWM) Pulse Width Modulation (PWM)

4 Istituto Tecnico Industriale A.Monaco EURLAB Control a Servo Motor PWM- Pulse Power supply V DC =5V Ground (GND) - Servo connected with Arduino and Breadboard Output PIN 8 is used to send the Signal to SERVO PIN 7 may be used for a second SERVO PIN 3, 5, 6, 9, 10, 11 can be used for PWM and SERVO Circuit diagramm (Schematic)

5 Istituto Tecnico Industriale A.Monaco EURLAB Control a Servo Motor This program code moves the servo arm to 180° This happens one time only. If you want to move it to another angle modify the code and compile it again. programm code #include // Header with servo library Servo servo1; //an object servo1 is created // Global variables int angle1 = 90; //angle is defined and set to 90° Try an other angle => modify it void setup() { // put your setup code here, to run once: servo1.attach(8); // the attached method is used by servo1 object to set the real Servo to pin 8 } void loop() { // put your main code here, to run repeatedly: servo1.write(angle1); // the attached method send the value of angle 90 to the servo1 ( send PWM signal) delay(20); // wait 20ms, then do loop again and the next signal will be send } In the following link you will see what happen https://123d.circuits.io/circuits/1692388-servo-manipulation-1

6 Istituto Tecnico Industriale A.Monaco EURLAB Control a Servo Motor If you want to use more servos Output PIN 8 is used to send the PWM Signal to SERVO 1 PIN 7, may be also used with another SERVO 2 Add following programmcode and compile it again. #include // Header with servo library Servo servo1; //an object servo1 is created Servo servo2; // second object servo2 is created // Global variables int angle1 = 90; //angle is defined and set to 90° Try an other angle => modify it int angle2 = 60; //angle2 is defined and set to 60° Try an other angle => modify it void setup() { servo1.attach(8); // the attached method is used by servo1 object to set the real Servo to pin 8 servo2.attach(7); // pin 7 is used by servo2 object to set the real second Servo to pin 7 } void loop() { // put your main code here, to run repeatedly: servo1.write(angle1); // the attached method send the value of angle 90 to the servo1 ( send PWM signal) servo2.write(angle2); // the attached method send the value of angle 60 to the servo2 ( send PWM signal) delay(20); // wait 20ms, then do loop again and the next signal will be send }


Download ppt "Istituto Tecnico Industriale A.Monaco EURLAB Control a Servo Motor If you want to swing an robot arm or … steer a robot you need a special motor (Servo)."

Similar presentations


Ads by Google