Adafruit 16-Channel PWM / Servo HAT with PiGPIOFactory

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
User avatar
JSmith85
 
Posts: 3
Joined: Wed Sep 02, 2020 1:02 am

Adafruit 16-Channel PWM / Servo HAT with PiGPIOFactory

Post by JSmith85 »

I bought the Adafruit 16-Channel PWM / Servo HAT for a raspberry pi 3b. I have been using the adafruit-circuitpython-servokiit library, but there too much servo jitter. Is it possible to use the Servo HAT with the PiGPIOFactory instead? and if so how? I have seen that this library reduces the jitter that I am getting with the adafruit library. Also, I want to use a PIR sensor with the servo hat. It is my understanding that servo hat doesn't use all the pins so I was thinking of using a long stacking header to connect the servo hat and the pir sensor. Would this work? and if so what pins should I use?

User avatar
edgjr
 
Posts: 143
Joined: Mon Jan 16, 2012 6:18 pm

Re: Adafruit 16-Channel PWM / Servo HAT with PiGPIOFactory

Post by edgjr »

It should be possible to use the PiGPIOFactory for the servo, but you won't be able to use any of the CircuitPython code. Because the board uses I2C, all of the Pi's other pins are usable - but you may need to think about how you're going to get to them: it looks like the header supplied with the hat isn't "through hole" so you'd probably need to re-solder (not I'm not a soldering/board expert, so this is speculation on my part).

User avatar
JSmith85
 
Posts: 3
Joined: Wed Sep 02, 2020 1:02 am

Re: Adafruit 16-Channel PWM / Servo HAT with PiGPIOFactory

Post by JSmith85 »

Thank you edjr.

Regarding the jittering, I realized that the servos are not jittering they are actually moving past the intended angle by about 15 degrees then adjusting to the correct angle. Based on this I am assuming the pmw pulse is too strong and is causing initial turn overshoots by around 15 degrees. It is my understanding that this could be fixed by adjust the pulse width, but haven't been able to figure this out using the adafruit_servokit library. Does anyone know if I can correct this using adafruit_servokit library.

User avatar
adafruit_support_bill
 
Posts: 88037
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit 16-Channel PWM / Servo HAT with PiGPIOFactory

Post by adafruit_support_bill »

The PWM pulse width simply defines the final target position for the servo. Any overshoot is a function of the position control algorithm built into the servo circuit board.

Common RC servos typically use a PID or similar algorithm. Since most do not support tuning of the PID parameters, the board is 'pre-tuned' for some 'typical' case. If the typical case does not match the physical properties of your system, you can end up with problems such as overshoot or oscillations. Some higher-end digital servos do support tuning of the PID parameters.

If your servos do not support tuning, the only remedies for overshoot are to modify the physical properties of your mechanism or to use code to incrementally approach the setpoint.

User avatar
JSmith85
 
Posts: 3
Joined: Wed Sep 02, 2020 1:02 am

Re: Adafruit 16-Channel PWM / Servo HAT with PiGPIOFactory

Post by JSmith85 »

Can I incrementally approach the setpoint using adafruit_servokit? and if so how?

User avatar
adafruit_support_bill
 
Posts: 88037
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit 16-Channel PWM / Servo HAT with PiGPIOFactory

Post by adafruit_support_bill »

The code would be something like:

Code: Select all

for angle in range(0, 180, 5):  # 0 - 180 degrees, in 5 degrees increments.
    kit.servo[0].angle = angle
    time.sleep(0.05)
You can adjust the increment and/or the sleep time to change the sweep speed.

User avatar
edgjr
 
Posts: 143
Joined: Mon Jan 16, 2012 6:18 pm

Re: Adafruit 16-Channel PWM / Servo HAT with PiGPIOFactory

Post by edgjr »

I've not heard of servos "over-shooting" and then making a correction -- that sounds like you may not have set the pulse_width_range on the servo? (If you're using SG90's, to get 180 degrees you need to use 500, 2400)

User avatar
adafruit_support_bill
 
Posts: 88037
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit 16-Channel PWM / Servo HAT with PiGPIOFactory

Post by adafruit_support_bill »

I've not heard of servos "over-shooting" and then making a correction
It is quite common. Since most hobby grade servos are not tunable, the generic tuning provided may be over-damped or under-damped for a particular load. Simply changing the pulse-width range does not alter the response of the control algorithm.

https://www.motioncontroltips.com/how-t ... o-control/

User avatar
edgjr
 
Posts: 143
Joined: Mon Jan 16, 2012 6:18 pm

Re: Adafruit 16-Channel PWM / Servo HAT with PiGPIOFactory

Post by edgjr »

TIL - thank you!!!

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”