Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
717 views

Arduino Servo Motor

This document discusses controlling servo motors with an Arduino. It provides specifications for the Tower Pro SG-5010 servo motor, including operating voltage, torque, speed and range of motion. It also describes how to connect the servo to the Arduino, use the Servo library functions to control position, and establishes a communication protocol for controlling multiple servos simultaneously. The document encourages experiments controlling two or more servos to move a robot arm between positions.

Uploaded by

Jirapong Manit
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
717 views

Arduino Servo Motor

This document discusses controlling servo motors with an Arduino. It provides specifications for the Tower Pro SG-5010 servo motor, including operating voltage, torque, speed and range of motion. It also describes how to connect the servo to the Arduino, use the Servo library functions to control position, and establishes a communication protocol for controlling multiple servos simultaneously. The document encourages experiments controlling two or more servos to move a robot arm between positions.

Uploaded by

Jirapong Manit
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Arduino Servo Motor Control

Outline

Tower Pro SG-5010 Wiring Diagram Arduino Servo Shield Arduino Servo Library Communication Protocol Let's Roll...

Tower Pro SG-5010

Operating Voltage: 4.8V~6.0V Stall torque: 5.50 kg-cm (4.8V) 6.50 kg-cm (6.0V) Operating speed: 0.20 sec/60degree (4.8V) 0.16 sec/60degree (6.0V) Dead band width: 10us Temperature Range: 0 ~ 55 Dimension: 40.2 x 20.2 x 43.2 mm Rotational Range: 180 degree

Wiring Diagram
SIGNAL

GND VCC

Arduino Servo Shield

Arduino Servo Library


#include <Servo.h> Functions:


attach() write() writeMicroseconds() read() attached() detach()

Functions

attach() Attach the Servo variable to a pin. Syntax: servo.attach(pin) servo.attach(pin, min, max) Parameters pin: the number of the pin that the servo is attached to min (optional): the pulse width, in microseconds, (defaults to 544) max (optional): the pulse width, in microseconds, (defaults to 2400)

Functions

write() Writes a value to the servo, controlling the shaft accordingly. Syntax: servo.write(angle) Parameters angle: the value to write to the servo, from 0 to 180

Functions

writeMicroseconds() Writes a value in microseconds (uS) to the servo, controlling the shaft accordingly. Syntax: servo.writeMicroseconds(uS) Parameters uS: the value of the parameter in microseconds(int)

Functions

read() Read the current angle of the servo (the value passed to the last call to write()). Syntax: servo.read() Returns: The angle of the servo, from 0 to 180 degrees.

Functions

attached() Check whether the Servo variable is attached to a pin. Syntax: servo.attached() Returns: true if the servo is attached to pin; false otherwise.

Functions

detach() Detach the Servo variable from its pin. If all Servo variables are detached, then pins 9 and 10 can be used for PWM output with analogWrite(). Syntax: servo.detach()

Example
#include <Servo.h> Servo myservo; int pos = 0; void setup() { myservo.attach(9); } // create servo object to control a servo // a maximum of eight servo objects can be created // variable to store the servo position // attaches the servo on pin 9 to the servo object

void loop() { for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees { // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for(pos = 180; pos>=1; pos-=1) { myservo.write(pos); delay(15); } } // goes from 180 degrees to 0 degrees // tell servo to go to position in variable 'pos' // waits 15ms for the servo to reach the position

Communication Protocol

What is the protocol? Why do we need a protocol?

Communication Protocol

An example of 5 bytes command


0xFF 0xFF Motor No. Angle CheckSum

First two bytes (0xFF) as the starting bytes Angel from 0 ~ 180 Check Sum = Byte1^Byte2^Byte3^...^ByteN

Let's Roll...

Try to control two and more servo motor. Try to assign a home position to the robot arm. Try to assign the robot arm to another pose and them back to the home position

You might also like