Balloon Collaboration

Projects => 2015 Balloon Projects => Topic started by: Larry on May 27, 2015, 02:35:43 AM



Title: Servo Control
Post by: Larry 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()


Title: Re: Servo Control
Post by: Larry 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.


Title: Re: Servo Control
Post by: Larry 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...