raspberry pi part 17

Post on 14-Aug-2015

41 Views

Category:

Engineering

4 Downloads

Preview:

Click to see full reader

TRANSCRIPT

www.techvilla.org.in

TECHVILLA

www.techvilla.org.in

www.techvilla.org.in

Servo motor control using raspberry-pi

Servo motor theory.

Controlling servo motor using pwm.

www.techvilla.org.in

Overview

Servo motors are used for angular positioning, such as in radio control airplanes. They typically have a movement range of 180 deg but can go up to 210 deg.

The output shaft of a servo does not rotate freely, but rather is made to seek a particular angular position under electronic control.

They are typically rated by torque and speed. A servo rated 40 ounce-in/.21 means that at 1 inch from the hub, the servo can exert 40 ounces of force and move 60 deg in 0.21 sec.

www.techvilla.org.in

What makes a Servo

The basic hobby servo has a 180:1 gear ratio. The motor is typically small.

Typically, a potentiometer (variable resistor) measures the position of the output shaft at all times so the controller can accurately place and maintain it’s setting.

Servo motors and are constructed out of basic DC motors, by adding:

• some gear reduction• a position sensor for the motor shaft• an electronic circuit that controls the motor's

operation

www.techvilla.org.in

Feed-back loop

open-loop

closed-loop

www.techvilla.org.in

Connection with raspberry

www.techvilla.org.in

Code# Servo Controlimport timedef set(property, value):try:f = open("/sys/class/rpi-pwm/pwm0/" + property, 'w')f.write(value)f.close() except:print("Error writing to: " + property + " value: " + value)  def setServo(angle):set("servo", str(angle))set("delayed", "0")set("mode", "servo")set("servo_max", "180")set("active", "1") delay_period = 0.01

www.techvilla.org.in

while True:for angle in range(0, 180):setServo(angle)time.sleep(delay_period)for angle in range(0, 180):setServo(180 - angle)time.sleep(delay_period)

top related