Presentation is loading. Please wait.

Presentation is loading. Please wait.

Controlling Servos with the Arduino

Similar presentations


Presentation on theme: "Controlling Servos with the Arduino"— Presentation transcript:

1 Controlling Servos with the Arduino

2 DISCLAIMER & USAGE The content of this presentation is for informational purposes only and is intended for students attending Louisiana Tech University only. The authors of this information do not make any claims as to the validity or accuracy of the information or methods presented. Any procedures demonstrated here are potentially dangerous and could result in damage and injury. Louisiana Tech University, its officers, employees, agents and volunteers, are not liable or responsible for any injuries, illness, damage or losses which may result from your using the materials or ideas, or from your performing the experiments or procedures depicted in this presentation. The Living with the Lab logos should remain attached to each slide, and the work should be attributed to Louisiana Tech University. If you do not agree, then please do not view this content. boosting application-focused learning through student ownership of learning platforms

3 Types of Servos Continuous Rotation Standard
can only rotate 180 degrees can rotate all the way around in either direction pulse tells servo which way to spin & how fast to spin pulse tells servo which position to hold

4 Electronics to Control the DC Motor
Servo Components Small DC motor Gearbox with small plastic gears to reduce the RPM and increase output torque Special electronics to interpret a pulse signal and deliver power to the motor Electronics to Control the DC Motor DC Motor Gears to Reduce RPM and Increase Torque of DC Motor

5 Wires to Power and Control Servos
Orange = Signal Output Shaft Red = 5V Brown = Ground

6 Wiring Servo to the Breadboard
Since the servos will hooked up for a while, you should keep the wiring tidy, using short jumpers from the power bus.

7 Servos are Controlled with Electrical Pulses
time (milliseconds) voltage (V) 5V - 0V - 20ms pulse width varies between roughly between 1ms and 2ms void setup() { pinMode(12, OUTPUT); } void loop() { digitalWrite(12, HIGH); delayMicroseconds(1000); // hold pin 12 high for 1000μs or 1ms digitalWrite(12, LOW); // hold pin 12 low for 20ms delay(20); }

8 What happens if you try above 2000ms or below 1000ms?
Discover what the pulses do with your servos Complete Activity 1 and Activity 2 for each of your servos Activity 1: Understanding pulse widths Start at 1ms pulses Let servo run Record observations in a table Direction of spin (forward/backward) Speed of spin Increase pulse width by 100μs Repeat steps 2 and 3 End at 2000ms Activity 2: Finding the servo’s stop pulse value Locate range where direction changes Start at lower end of range Let servo run Record observations in a table Direction of spin (forward/backward) Speed of spin Increase pulse width by 10μs Repeat steps 2 and 3 End at upper end of range What happens if you try above 2000ms or below 1000ms? Record the stop value for each servo. Suggestion: Write the value on a piece of tape that you put on the servo. void setup() { pinMode(12, OUTPUT); } void loop() { digitalWrite(12, HIGH); delayMicroseconds(1000); // hold pin 3 high for 1700μs or 1.7ms digitalWrite(12, LOW); // hold pin 3 low for 20ms delay(20); }

9 Playing Around with Programing
Make your Arduino: Go forward Go in in reverse Do a zero turn to the left continuously Do a zero turn to the right continuously Make a wide turn left Make a wide turn right Do a zero turn left/right for a limited amount of time (hint: for loop) Go forward for some time then turn left/right

10 Playing Around with Programing
Discover what is happening with this code. Modify it to do more or something different. “for” loop executes 200 times i = 0, 1, 2, 3, 4, void setup() { pinMode(12, OUTPUT); } void loop() { int i; for (i=0; i<200; i++) { digitalWrite(12, HIGH); delayMicroseconds(1000); digitalWrite(12, LOW); delay(20); } delay(1000); for (i=0; i<400; i++) { digitalWrite(12, HIGH); delayMicroseconds(2000-i); digitalWrite(12, LOW); delay(20); } } create a square wave with a pulse width of 1000ms followed by a 20ms pulse wait one second this for loop causes the servo to go from full speed CCW (pulse width = 2000ms) to full speed CW (pulse width = 1000ms)


Download ppt "Controlling Servos with the Arduino"

Similar presentations


Ads by Google