using a a raspberry pi 4, an "Adafruit 16-Channel PWM / Servo HAT for Raspberry Pi", and 3 of the mg92b micro servos. Using a 4Amp 5v power supply from adafruit as well.
File: Test.py
- Code: Select all | TOGGLE FULL SIZE
import time
from adafruit_servokit import ServoKit
kit = ServoKit(channels=16)
servo1open=180
servo1close=165
time.sleep(3)
kit.servo[1].angle=servo1open
time.sleep(1)
kit.servo[1].angle=servo1close
If i run this code in a while loop via bash:
- Code: Select all | TOGGLE FULL SIZE
x=0; while true; do echo $x; python3 Test.py; x=$((x+1)); done
my servo will randomly go towards zero degrees (i only want it operating between 165 and 180) when the script is first initialized, but ONLY intermittently. Sometimes it happens the first time the script is run, sometimes it happens the 20th time it's run or any times in between.
Whenever the servo moves too far outside of the parameters I have set it breaks the 3d printed mounts I have the servos in, which then take like 6 hours to reprint. What's going on here?
here's the version of all my adafruit python libs
- Code: Select all | TOGGLE FULL SIZE
Adafruit-Blinka 6.4.0
adafruit-circuitpython-busdevice 5.0.6
adafruit-circuitpython-motor 3.2.8
adafruit-circuitpython-motorkit 1.6.2
adafruit-circuitpython-pca9685 3.3.5
adafruit-circuitpython-register 1.9.5
adafruit-circuitpython-servokit 1.3.3
Adafruit-PlatformDetect 3.3.0
Adafruit-PureIO 1.1.8
adafruit-python-shell 1.3.1
If i do a while loop within python I haven't detected any issues yet of the servo moving to a 'random pos'. Only seems to be when i initialize the python script.
I tried setting the servo to a close position at the start of the script (before the first leep) then running my script, and i was still getting intermittent wacky behavior.