Controlling Servos with the Arduino

Slides:



Advertisements
Similar presentations
temperature system wiring
Advertisements

Using the servo library living with the lab Libraries are computer programs written to add functionality to Arduino programs. A library to control hobby.
Analog and Digital Measurements living with the lab 14 digital input / output pins 6 analog input pins © 2012 David Hall.
Using the Arduino to Make an LED Flash Work in teams of two! living with the lab digital I/O pins (I/O = input / output) USB cable plug power pins.
User-defined functions in Arduino sketches living with the lab © 2012 David Hall.
Using Your Arduino, Breadboard and Multimeter Work in teams of two! living with the lab 1 © 2012 David Hall.
Cascaded switching of a solenoid valve living with the lab transistor relay solenoid valve © 2012 David Hall.
Assembly of conductivity flow loop living with the lab (in preparation for calibrating conductivity sensor)
Switches & whiskers on the Arduino living with the lab lever arm switches mounted to Arduino © 2012 David Hall.
220  470  Gnd5V Currents Through Parallel Resistors 1 living with the lab © 2012 David Hall.
Using Hobby Servos with the Arduino living with the lab © 2012 David Hall.
Kirchoff’s Current Law (KCL) living with the lab University of Pennsylvania Library and Wikipedia Gustav Kirchoff (left) and Robert Bunsen (right) Bunsen.
Adding a Barrel Jack to a Battery Pack living with the lab © 2012 David Hall.
Using for loops to control LEDs living with the lab 1 1 arduino.cc the for statement allows us to repeat a block of commands a limited number of times.
Limited rotation servo basics David Hall output shaft servo horn red wire = 5V + black wire = Gnd - white wire = control signal standard servo.
Building Circuits.
Pump Fabrication Day Group A will draw their pump
Connecting Switches.
Series and Parallel Resistors
Pump Project Requirements
Pump Efficiency Fluid Energy Out + - Electrical Energy In.
Introduction to the Arduino
Why Won’t My Arduino Work?
Troubleshooting Your Multimeter
Using servos.
Servo Library and Functions
Line Following Tips photoresistor circuits
What’s in your kit?.
Pump Project Overview.
Robot Assembly.
How to Use Dial Calipers
Controlling a Motor with Cascading Switches
Introduction to Transistors
Introduction to the Fishtank
RGB LEDs.
Conservation of Mass Problem
Linkages and Mechanisms
Maxbotix Ultrasonic Distance Sensor
Conductivity Sensor.
Introduction to Transistors
Servo Library and Functions
Troubleshooting Your Multimeter
a few of my favorite sensors
Relays.
using for loops to control LEDs
using the Arduino to make LEDs flash
Acquiring Data from an ADXL335 Accelerometer
Using Photoresistors with an Arduino
Line Following Tips photoresistor circuit
Torque and RPM of Gears
Conservation of Mass Problem
analog and digital measurements
Using “if” statements.
Controlling the Heater
Digital Input from Switches
Cash Flow Diagrams <in> <out> $200 $300 $150 $100
Implementing Switches Using Interrupts
Arduino: For Loops.
Non-Concurrent Force Systems
IR Object Detection IR detector IR LED IR light reflected off object
Radio Frequency Transmitter and Receiver
Interfacing a Rotary Encoder with an Arduino
Conservation of Mass Problem
Non-Concurrent Force Systems
Evaluating Design Alternatives
Counting Servo Gear Teeth (FS90R Servos)
Static Equilibrium Problem
Reservoir Loop.
Freshman Design Expo Presentations
Gearmotor Efficiency W table top gearmotor pulley string.
Presentation transcript:

Controlling Servos with the Arduino

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

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

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

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

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.

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); }

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); }

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

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, . . . 199 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)