Hello,
Recently, I have tried to install a servo into my operant boxes to make my levers extendable and retractable. But sometimes the servo tends to underextend, underretract, and overretract than the desired angle provided in the code. All the servos are properly callibrated and although it works most of the time, there are times where it messes up and I can't have this at all. Any suggestions on how to manipulate the software to prevent this from happening. I looked into almost everything possible to do with hardware and I believe it is a software bug.
Here is the servo I use, to power it I connect it to a different power supply to ensure I don't fry the pi:
https://www.amazon.com/ANNIMOS-Digital- ... 838&sr=8-4
Here is some of the code I have written for it, will messing with any of these parameters help fix this issue?
--
# -*- coding: utf-8 -*-
import gpiozero as io
from picamera import PiCamera
import CameraEncoder
from gpiozero import AngularServo ## 3.01
import threading ##3.04
## settings
feeder_trig_pulse=.05 # trigger pulse duration for feeder in ms
digout_active_high=True # for LEDs, rev v2.09
feeder_active_high=False # for feeder
bounce_s=.05
## 3.01
SERVO={'on_angle':-72, 'off_angle':-18, 'min_angle':-90,'max_angle':90, 'min_pulse':0.0005, 'max_pulse':0.0025, 'ini_angle':-18}
SERVO_ON_TIME=0.065 ## 3.03, servo on 20 ms then stop to solve the jitter
##3.04, to avoid jitter, turn on the servo, then delay, then turn it off
def motor_on_off(mtr,angle):
if angle!=None:
mtr.angle=angle
threading.Timer( SERVO_ON_TIME, lambda: motor_on_off( mtr, None)).start()
else:
mtr.angle=None
--
Let me know if you can think of a potential fix for this as I have been struggling with this for a couple of months now.
Thanks!
Recently, I have tried to install a servo into my operant boxes to make my levers extendable and retractable. But sometimes the servo tends to underextend, underretract, and overretract than the desired angle provided in the code. All the servos are properly callibrated and although it works most of the time, there are times where it messes up and I can't have this at all. Any suggestions on how to manipulate the software to prevent this from happening. I looked into almost everything possible to do with hardware and I believe it is a software bug.
Here is the servo I use, to power it I connect it to a different power supply to ensure I don't fry the pi:
https://www.amazon.com/ANNIMOS-Digital- ... 838&sr=8-4
Here is some of the code I have written for it, will messing with any of these parameters help fix this issue?
--
# -*- coding: utf-8 -*-
import gpiozero as io
from picamera import PiCamera
import CameraEncoder
from gpiozero import AngularServo ## 3.01
import threading ##3.04
## settings
feeder_trig_pulse=.05 # trigger pulse duration for feeder in ms
digout_active_high=True # for LEDs, rev v2.09
feeder_active_high=False # for feeder
bounce_s=.05
## 3.01
SERVO={'on_angle':-72, 'off_angle':-18, 'min_angle':-90,'max_angle':90, 'min_pulse':0.0005, 'max_pulse':0.0025, 'ini_angle':-18}
SERVO_ON_TIME=0.065 ## 3.03, servo on 20 ms then stop to solve the jitter
##3.04, to avoid jitter, turn on the servo, then delay, then turn it off
def motor_on_off(mtr,angle):
if angle!=None:
mtr.angle=angle
threading.Timer( SERVO_ON_TIME, lambda: motor_on_off( mtr, None)).start()
else:
mtr.angle=None
--
Let me know if you can think of a potential fix for this as I have been struggling with this for a couple of months now.
Thanks!
Statistics: Posted by Operantboxhelp — Fri Oct 04, 2024 7:50 pm