Balloon Collaboration
November 20, 2019, 08:14:35 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Hosting for barntek.net has been extended for another 3 years
 
   Home   Help Search gallery Calendar Login Register  
Pages: [1]
  Print  
Author Topic: Servo Control  (Read 1529 times)
Larry
Administrator
Hero Member
*****
Posts: 1167



View Profile
« on: May 27, 2015, 02:35:43 AM »

Well, I dug in and found an easy way to PWM from any pin on the Pi.  It uses GPIO commands, but I don't know if they are standard or part of the WiringPi library I installed. Anyway here is the test code I wrote.  I am currently driving an LED, but it is working great.  I foresee no reason for it to not work with a servo.  I will have to establish limits, or definite positions for up/out/and down positions.

Quote
#!/usr/bin/python

### General Info ####################################
### tstServo.py
### Servo Driver program for driving a single servo
### ...by Larry Barnes
### ...will make any pin drive a servo

import time

### Setup GPIO/PWM ##################################
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
pwm = GPIO.PWM(18, 100)
pwm.start(5)

### Main Program ####################################
try:
  while 1:
    for duty in range(0,100):
      pwm.ChangeDutyCycle(duty)
      time.sleep(.01)

    for duty in range(100,0,-1):
      pwm.ChangeDutyCycle(duty)
      time.sleep(.01)
except KeyboardInterrupt:
  print
  print "Exiting..."
  GPIO.output(18,False)
  GPIO.cleanup()
Logged
Larry
Administrator
Hero Member
*****
Posts: 1167



View Profile
« Reply #1 on: May 30, 2015, 11:50:25 PM »

Well, I hooked up the servo and found that I had to run 5% to 22% duty cycle to get a full 180 degree sweep of the servo.  I also found out that it is not very consistent doing it this way.  I would hate to turn it to the balloon to video the pop, and have it point somewhere else altogether.

I think, therefore, that I will just do a single camera, looking at the horizon to take cloud shots.  I will also look at Wal-Mart to see if I can find one of those $30 video cameras Danny was talking about.  We can dedicate it to looking at the balloon, watching for the pop.

I will continue to try to find a better way to drive the servo, but I am not expecting much.
Logged
Larry
Administrator
Hero Member
*****
Posts: 1167



View Profile
« Reply #2 on: June 03, 2015, 03:30:22 AM »

Ok, disregard the last post...  I changed from RPi_GPIO to RPIO and the servo runs great.  The program is back on track.  The next major thing is to mount the hardware...  somehow...
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!