Presentation is loading. Please wait.

Presentation is loading. Please wait.

Raspberry Pi Hands-on Seminars

Similar presentations


Presentation on theme: "Raspberry Pi Hands-on Seminars"— Presentation transcript:

1 Raspberry Pi Hands-on Seminars
Interfacing to Servo Motors Gregory Griffes Gregory Griffes 8/16/15

2 Overview Types of servo motors and operation
Electronic connections to a servo Python code to control a servo Wiring and operating your own servo motor

3 Hardware High power charging hub Custom servo cable Servo motor
RPi GPIO Breakout breadboard 3.3v to 5v Level shifter (I2C safe version)

4 Parts Needed Canakit Ultimate Starter kit with breadboard, breakout board, ribbon cable, jumper wires, and electronic parts one Tek Republic TUH-3700 USB Port Hub charging hub ($30) one HiTec HS-5055MG digital servo motor ($18) one Parallax continuous rotation servo motor ($10) one Adafruit 4-channel I2C-safe Bi- directional Logic Level Converter ($8)

5 Step 1: Avoid Damage to your Rpi hardware
ESD – ElectroStatic Discharge Use a wrist strap, mat, & ESD bags

6 Step 2: Breadboard Remove the Rpi from the static bag
Connect breadboard circuit (see video) Make sure the connector is correctly aligned

7 Step 2: Hardware Warnings
DANGER! Step 2: Hardware Warnings +5V Damage! Voltage and current can damage Rpi GPIOs are 3.3 volt and NOT protected from other voltages Applying 5 volts to a GPIO can cause permanent damage to the Rpi When wired correctly – no damage occurs Rpi GPIO max voltage = 3.3v Rpi GPIO max current = 16ma (0.016) Rpi all GPIOs max current = 50ma / /- Rpi Correct +3.3V Rpi GPIO

8 Pulse Width Modulator PWM used for controlling the servo motor

9 Servo Motors PID (Proportional Integral Differentiator)

10 Servo Motor Specs Parameter Tower Pro SG51r Tower Pro SG-5010
Stall Torque @4.8v, 8.3 oz-in1 @4.8v, 76.4 oz-in Speed @4.8v, 0.08sec/60°2 @4.8v, 0.19sec/60° Price $5 Availability good Surge current3 5.2v v Voltage Droop4 3.9v 3.3v Voltage Droop5 4.8v 4.6v 1” away from center line 8.3 ounces of force. The closer to the shaft the more force is applied but the travel distance is less. Takes 80 milliseconds to move 60 degrees at 4.8v power source Amps required to move to a new position Long wires (>12”); small gauge (breadboard wires); no filter cap Short wires (6”); large gauge (USB charging cable); 1000uf filter cap

11 180 degree servo (aka. Standard Servo)
Type A: Wire colors: Brown (GND), Orange (+5v power), Yellow (PWM signal) 500us -> 2500us = counter-clockwise rotation Type B: Wire colors: Black (GND), Red (+5v power), Yellow (PWM signal) 500us -> 2500us = clockwise rotation

12 Continuous Rotation servo
Wire colors: Black (GND), Red (+5v power), White (PWM signal) 1000us = maximum speed clockwise rotation 1500us = stopped 2000us = maximum speed counter- clockwise rotation

13 Custom Servo Motor cable
PWM signal connection 1000uf capacitor USB Charging cable Servo motor

14 Wiring up the servo Power off the Raspberry Pi Wire breadboard
Connect servo Power on servo and Rpi

15 Three approaches to controlling the servo
Direct from 3.3v GPIO Using the Adafruit I2C safe level shifter Using the Adafruit 8 channel level shifter 3.3V GPIO I2C Safe 8 Channel Advantage Simple Cheap No soldering Can be used for both servo and sensors Fits on GPIO breakout breadboard 8 channels No pullups needed Smaller footprint than two I2C safe devices Disadvantage Unreliable long term Does not protect the RPi output from higher voltages Only 4 channels Requires pull ups Does not support I2C interface Additional breadboard needed Cost $0.05 $4 $8

16 Servo Motor Schematic (I2C safe)
Use a separate power source for the servo Reason: when the motor moves, it causes a spike on the +5v power line

17 Using 3.3 volt GPIO output Custom Servo cable Servo motor GPIO 18
Series resistor (3.9k approx) RPi GPIO Breakout breadboard

18 Using Adafruit 8 channel level shifter
Servo motor Servo cable 3.3v to 5v Level shifter (8ch version) RPi GPIO Breakout breadboard

19 Verify Have someone else verify your wiring to make sure you don’t damage your Rpi when you turn it on

20 Turn On Rpi Connect monitor, mouse, and keyboard
Turn on power and boot the Rpi Login and startx, open file mgr Create a projects directory Connect to internet or use thumb drive Hover over the “projects” directory and “open terminal window” Enter “git clone

21 Run the program Enter “cd servo_motors”
Enter “chmod +x servo-slider.py” to make it executable. Enter “sudo ./servo-slider.py” Use mouse to move slider, observe servo motor moving

22 DMA Controller Direct Memory Access (DMA)
Hardware used to perform memory transfers to/from memory or peripherals independent from CPU operation Very fast data transfers which are not interrupted by the CPU 16 DMA channels

23 Using the DMA engine to control the servo
joan2937 commented a day servoblaster and pi-blaster (and my pigpio) have been updated to work on the Pi2. The servoblaster github repository has not been updated. You can find a link to the updated software by searching for servoblaster on the rasperrypi.org forums.

24 Using the DMA engine This program does not use the DMA engine
Observe how the servo motor jitters Use Servoblaster, pi-blaster, or pigpio to implement the DMA servo controller

25 Switch to Continuous Rotation servo
Unplug the 180 degree servo and plug in the continuous rotation servo Observe the different behavior

26 Questions ? Done!


Download ppt "Raspberry Pi Hands-on Seminars"

Similar presentations


Ads by Google