I finally got my i2c servo driver from Adafruit working beautifully and I can use to control both a micro servo and a larger one. But I have several questions about automating or writing a calibration script for the various types.
1. I'd like to write a calibration script that I can run to convert degrees (0-180 for normal and I don't know what for Continuous rotation) I enter into a physical servo position for a pan/tilt system.
2. Figure out how to set-up the continuous rotation servos with this i2c chip.
1. Servo driver 16 Channel Ada controller.
2. micro servos I can't find the frequency on the docs btw
3. 3-d printed pan tilt
4. Pi Camera Module of course :) with the video4linux drivers up and running
So I wrote some initial code (below) to run the servos by providing an angle and "hoping" it goes there. Just some slight modifications of the Servo code provided by Ada (shown below). I would really love to get some feedback on how others are doing their calibration of the servos so that I can become more precise. I'm eventually going to use this system both for the pan/tilt gimbal of a quad copter and for a wheeled robot so I'd like to control by angle first and then just by clicking on an area in the field of view.
I'm having some difficulty correlating angle/with position though and that's where I would like some help if possible
max is :
Currently the angle input is -40 to about 300 which correlates to a physical 0 - 180. How would you calibrate this or adjust my values to work with this.:
- Code: Select all | TOGGLE FULL SIZE
pulseAngle = float(1.0/180.0)
return ((pulseAngle * angle) + 1.0)
# 1ms / 180o .. you will have to add this to 1ms to get total.
# so say you want 90o you do (pulseAngle * 90) + 1
def setPulseDegree(channel, freq, angle):
sec = float(1000000)
pulseLength = (sec / float(freq)) # period / pulse
print "%.3f us per period" % pulseLength
pulseLength /= totalTicks # us / tick
print "%.2f us per bit" % pulseLength
pulse = angleToms(angle)
print "%.2f pulse for 90 angle" % pulse
ticksOn = (pulse * 1000) / pulseLength
print "%.2f ticksOn for 90 angle" % ticksOn
pwm.setPWM(channel, 0, int(ticksOn))