Sie sind auf Seite 1von 7

Servos

http://www.lizarum.com/assignments/physical_com...

Physical Computing: Servos


M A K I N G M OTI ON S W I TH S E R V O M OTOR S / / N A V I GA TI ON

puppets, and of course, robots. What's inside:

A Servo is a small device that has an output shaft. This shaft can be positioned to specific angular positions by sending the servo a coded signal. As long as the coded signal exists on the input line, the servo will maintain the angular position of the shaft. As the coded signal changes, the angular position of the shaft changes. In practice, servos are used in radio controlled airplanes to position control surfaces like the elevators and rudders. They are also used in radio controlled cars,

Pots and Servos

The servo motor has some control circuits and a potentiometer (a variable resistor) that is connected to the output shaft. This pot allows the control circuitry to monitor the current angle of the servo motor. If the shaft is at the correct angle, then the motor shuts off. If the circuit finds that the angle is not correct, it will turn the motor the correct direction until the angle is correct. The output shaft of the servo is capable of traveling somewhere around 180 degrees. Usually, its somewhere in the 210 degree range, but it varies by manufacturer. A normal servo is used to control an angular motion of between 0 and 180 degrees. A normal servo is mechanically not capable of turning any farther due to a mechanical stop built on to the main output gear. The amount of power applied to the motor is proportional to the distance it needs

1 de 7

08/12/10 22:20

Servos

http://www.lizarum.com/assignments/physical_com...
to travel. So, if the shaft needs to turn a large distance, the motor will run at full speed. If it needs to turn only a small amount, the motor will run at a slower speed. This is called proportional control. Angles of Rotation:

Continuous Rotation servos The continuous rotation servos keep on rotating when pulsed with power. The most common continuous rotation servos from Parallax rotate in one direction when pulsed with power with a delay above 1500 microseconds and the other way when pulsed with a delay below 1500 microseconds. This program will make the continuous rotation servo go 100 steps one way then 100 steps the other way.
#define motoPin 9 void setup(){ pinMode(motoPin,OUTPUT); } void loop(){ for(int i = 0; i < 100; i++);{ digitalWrite(motoPin,HIGH); delayMicroseconds(1850); digitalWrite(motoPin,LOW); delayMicroseconds(1850); } for(int j = 0; j < 100; j++);{ digitalWrite(motoPin,HIGH); delayMicroseconds(1250); digitalWrite(motoPin,LOW); delayMicroseconds(1250); } }

What servos are good for Roboticists, movie effects people, and puppeteers use them extensively Any time you need controlled, repeatable motion Can turn rotation into linear movement with clever mechanical levers

Where you find them

2 de 7

08/12/10 22:20

Servos

http://www.lizarum.com/assignments/physical_com...

The underpinnings of one of the five transforming dresses featured in Hussein

3 de 7

08/12/10 22:20

Servos

http://www.lizarum.com/assignments/physical_com...
Chalayan's latest runway show. Wires within the tubes connect to motors at the bottom of the dress. The motors reel in wires attached to the outer layer of the garment, altering its shape.

When using the servo, it is helpful to mark the servo horn. This allows you to follow the rotation:

Connect the servo to the Microcontroller like this:

The computer can't really output analog values, but it can fake it. It fakes it using Pulse Width Modulation or PWM. This program moves a servo across its full range:

But doesn't Arduino have PWM?

4 de 7

08/12/10 22:20

Servos

http://www.lizarum.com/assignments/physical_com...
Yes Arduino has built-in PWM on pins 3, 5,6, 9,10,11, and you can use analogWrite(pin,value) to write an analog value (PWM wave) to a pin. You can light a LED at varying brightnesses or drive a motor at various speeds. After a call to analogWrite(), the pin will generate a steady wave until the next call to analogWrite (or a call to digitalRead or digitalWrite on the same pin). But it operates at a high, fixed frequency and isn't usable for servos. The PWM speed used for analogWrite() is set to 490Hz currently. It's not something changeable without understanding more about how AVRs work. So when programming AVRs in C outside of Arduino, PWM speed can be set to just about any value. Here's the good news, the Servo library takes care of this for you:

Exercise
Wire up the servo and a potentimeter:

You are going to drive the servo with a potentiomer.


#include <Servo.h> Servo myServo; int pos=0; int analogSensor=0; void setup(){ myServo.attach(9); myServo.write(0); Serial.begin(9600); } void loop() { pos=analogRead(analogSensor); Serial.println(pos); pos=map(pos,0,750,0,180); myServo.write(pos); delay(15); } // tell servo to go to position in variable 'pos' // waits 15ms for the servo to reach the position

S E RV O CRITTE RS

From my class:

5 de 7

08/12/10 22:20

Servos

http://www.lizarum.com/assignments/physical_com...

Others:

6 de 7

08/12/10 22:20

Servos

http://www.lizarum.com/assignments/physical_com...

MKTET2-2T.jpg

twitchie code

7 de 7

08/12/10 22:20

Das könnte Ihnen auch gefallen