raspberry pi part 17
TRANSCRIPT
![Page 1: Raspberry pi Part 17](https://reader035.vdocuments.site/reader035/viewer/2022062216/55cd318dbb61eb27688b4665/html5/thumbnails/1.jpg)
www.techvilla.org.in
TECHVILLA
www.techvilla.org.in
![Page 2: Raspberry pi Part 17](https://reader035.vdocuments.site/reader035/viewer/2022062216/55cd318dbb61eb27688b4665/html5/thumbnails/2.jpg)
www.techvilla.org.in
Servo motor control using raspberry-pi
Servo motor theory.
Controlling servo motor using pwm.
![Page 3: Raspberry pi Part 17](https://reader035.vdocuments.site/reader035/viewer/2022062216/55cd318dbb61eb27688b4665/html5/thumbnails/3.jpg)
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.
![Page 4: Raspberry pi Part 17](https://reader035.vdocuments.site/reader035/viewer/2022062216/55cd318dbb61eb27688b4665/html5/thumbnails/4.jpg)
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
![Page 5: Raspberry pi Part 17](https://reader035.vdocuments.site/reader035/viewer/2022062216/55cd318dbb61eb27688b4665/html5/thumbnails/5.jpg)
www.techvilla.org.in
Feed-back loop
open-loop
closed-loop
![Page 6: Raspberry pi Part 17](https://reader035.vdocuments.site/reader035/viewer/2022062216/55cd318dbb61eb27688b4665/html5/thumbnails/6.jpg)
www.techvilla.org.in
Connection with raspberry
![Page 7: Raspberry pi Part 17](https://reader035.vdocuments.site/reader035/viewer/2022062216/55cd318dbb61eb27688b4665/html5/thumbnails/7.jpg)
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
![Page 8: Raspberry pi Part 17](https://reader035.vdocuments.site/reader035/viewer/2022062216/55cd318dbb61eb27688b4665/html5/thumbnails/8.jpg)
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)