Created
October 5, 2014 11:00
-
-
Save treeherder/19aacbfe9730ab658074 to your computer and use it in GitHub Desktop.
walker notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from Adafruit_PWM_Servo_Driver import PWM | |
import time | |
# =========================================================================== | |
# Example Code | |
# =========================================================================== | |
# Initialise the PWM device using the default address | |
# bmp = PWM(0x40, debug=True) | |
pwm = PWM(0x40, debug=True) | |
servoMin = 150 # Min pulse length out of 4096 | |
servoMax = 600 # Max pulse length out of 4096 | |
def setServoPulse(channel, pulse): | |
pulseLength = 1000000 # 1,000,000 us per second | |
pulseLength /= 60 # 60 Hz | |
print "%d us per period" % pulseLength | |
pulseLength /= 4096 # 12 bits of resolution | |
print "%d us per bit" % pulseLength | |
pulse *= 1000 | |
pulse /= pulseLength | |
pwm.setPWM(channel, 0, pulse) | |
#foot A (12) out 600, in 200, standing 400 | |
#tibula A (0) max open 150, max close 450, 300 directly standing | |
#hip A (2) max close ~420 max open 650, straight at 500 | |
#foot B (3) mac close 700 max open 150 standing at 350? | |
#tibua b (4) max close 700 max opepen 300 standing 400 | |
#hip b (5) max open 500 max close 200 standning 300 | |
#foot c (6) maximum open 600 maximum close 200 standing 400 | |
#tiblula c (7) maximum close ~650 max open 150 standing 400 | |
#hip c (8) max open ~200 max close 500 standing 300 | |
#foot d (9) max open 200 max close 600 standing 350 | |
#tibia d(10) max open 650 max close 200 standing at 300 | |
#hip d (11) max close ~500 | |
pwm.setPWMFreq(60) # Set frequency to 60 Hz | |
#stand | |
#leg A --> | |
pwm.setPWM(0, 0, 300) | |
time.sleep(1) | |
pwm.setPWM(2, 0,500) | |
time.sleep(1) | |
pwm.setPWM(12, 0, 400) | |
#leg b --> | |
pwm.setPWM(3,0,400) | |
time.sleep(1) | |
pwm.setPWM(4,0,400) | |
time.sleep(1) | |
pwm.setPWM(5,0, 300) | |
time.sleep(1) | |
#leg c --> | |
pwm.setPWM(6,0, 400) | |
time.sleep(1) | |
pwm.setPWM(7,0, 400) | |
time.sleep(1) | |
pwm.setPWM(8,0, 400) | |
time.sleep(1) | |
#leg d ---> | |
pwm.setPWM(9,0,350) | |
time.sleep(1) | |
pwm.setPWM(10,0,300) | |
time.sleep(1) | |
pwm.setPWM(11,0, 300) | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment