Raspberry Pi 3
I have a camera mounted in an Adafruit pan-tilt mini kit with 2 servos (SG92R).
PCA9685 board.
Installed python-smbus and i2c-tools.
From raspi-config I enabled 5 Interfacing options P5 I2C.
Also installed Adafruit_Python_PCA9685.
Executing a python script I position the camera.
I only use pan-tilt to fine tune the camera position just at startup for timelapse.
I found that despite I added a @reboot line in crontab to run that script with the same two parameters (horizontal and vertical servo positions) I used the first time, just in case of restart after power failure or manual reboot, the position of the camera is slightly different than the original one.
I tried disabling I2C interface option but the result is far away the original position of the camera.
Then only way I guess I can accomplish that is to disconnect the power of the pan-tilt controller ( PCA9685 ) after getting the best position but this could be a mess for me.
I asked if is there another way to get servos quiet in case of reboot.
Here's the script to manage both servos.
- Code: Select all | TOGGLE FULL SIZE
from __future__ import division
import time
import sys
import subprocess
import Adafruit_PCA9685
pwm = Adafruit_PCA9685.PCA9685()
servo_min0 = 160
servo_max0 = 166
servo_min1 = 444
servo_max1 = 450
if len(sys.argv)==1:
servo_H = 360
servo_V = 380
elif len(sys.argv)==2:
servo_H = int(sys.argv[1])
servo_V = 380
else:
servo_H = int(sys.argv[1])
servo_V = int(sys.argv[2])
def set_servo_pulse(channel, pulse):
pulse_length = 1000000
pulse_length //= 60
print('{0}us per period'.format(pulse_length))
pulse_length //= 4096
print('{0}us per bit'.format(pulse_length))
pulse *= 1000
pulse //= pulse_length
pwm.set_pwm(channel, 0, pulse)
pwm.set_pwm_freq(60)
pwm.set_pwm(0, 0, servo_H)
pwm.set_pwm(1, 0, servo_V)
1) Is there something I can change here to get the servos fixed in the same position after rebooting?
2) An answer I got was to use "expensive" servos.
I found one larger assembly structure (metal) compatible with these servos: MG995 or HS322,HS422,Hitec,Parallax,Futaba, etc 40×20×36mm. I don't know if they would serve my needs (stay in a fixed position despite reboot). They also must be compatible with my PCA9685 module. Would they?
Thank you