Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Analog Feedback Servo Makes noise, inconsistent feedba
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Analog Feedback Servo Makes noise, inconsistent feedba

by bsautner on Mon Jun 15, 2020 12:20 pm

Hi

I have an analog feedback servo: https://www.adafruit.com/product/1404
connect to a Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface - PCA9685 https://www.adafruit.com/product/815
PCA9685 has a seperate 5v power source to drive the servo

In a RaspPi 3 I run this code to rotate the servo 180 degrees and back

Code: Select all | TOGGLE FULL SIZE
import time
import board
import pulseio
from adafruit_motor import servo
 
from adafruit_servokit import ServoKit
kit = ServoKit(channels=16)

kit.servo[0].set_pulse_width_range(500, 2500)
kit.servo[0].angle = 180
time.sleep(3)
kit.servo[0].angle = 0


which it does - i do notice the servo is vibrating slightly which makes me thing it's struggling for some reason

I have the feeback pin attached to an analog pin of an arduino and print the value - at 0 degrees i get numbers like: 86, 123,86,113

at 180 i get 350, 472, 475, 421....

I'm just outputing a read from
Code: Select all | TOGGLE FULL SIZE
analogRead(A0);


I'm not sure i'm calibrating the servo correctly, and that
Code: Select all | TOGGLE FULL SIZE
kit.servo[0].set_pulse_width_range(500, 2500)
are just numbers i made up because they seem to get the full sweep - i'm looking for some sort of guidence or doc on what that should be, or if i should set the pulse differently - i'm thinking the analog output should be stead when the servo isn't moving and it shouldn't be vibrating when idle

Thanks!

bsautner
 
Posts: 3
Joined: Tue Jul 19, 2016 3:04 pm

Re: Analog Feedback Servo Makes noise, inconsistent feedba

by adafruit_support_bill on Mon Jun 15, 2020 2:02 pm

What are you using for a power supply?
Servos do sometimes hum or jitter a bit while attempting to hold a position. The jitter can be worse due to load, insufficient power or signal interference.

adafruit_support_bill
 
Posts: 78736
Joined: Sat Feb 07, 2009 10:11 am

Re: Analog Feedback Servo Makes noise, inconsistent feedba

by bsautner on Mon Jun 15, 2020 4:58 pm

i'm powering the servos with a beefy battery TalentCell 12V 6000mAh/5V 12000mAh DC Output Lithium Ion Battery Pack and the Rasp Pi with a bacony Anker Astro E1 5200mAh External Battery Power Bank.

Those jumps in position from the POT in the servo don't make sense to me. I'd understand small noise but these are quite large which tells me the code i'm sharing in the OP is trying to push the servo past its normal sweep range - i'm moving to abandoning my idea of using the Pi / Python to control the servo and the arduino to just read the analog feeback and relay it to the Pi and just use the arduino to handle all servo control and the real computing happen on the pi.

It may help someone out there on coming up with a python example for calibrating and driving a servo like this so i'm open to keep working it out.

I can add that with the same power supply i'm able to calibrate the servos ok from arduino
Last edited by bsautner on Mon Jun 15, 2020 5:18 pm, edited 1 time in total.

bsautner
 
Posts: 3
Joined: Tue Jul 19, 2016 3:04 pm

Re: Analog Feedback Servo Makes noise, inconsistent feedba

by adafruit_support_bill on Mon Jun 15, 2020 5:17 pm

i'm powering the servos with a beefy battery TalentCell 12V 6000mAh/5V 12000mAh DC Output Lithium Ion Battery Pack

Which output are you using to power the servos - 12v or 5v? 12v would definitely make the servo jittery - if not a little smoky.

I'd understand small noise but these are quite large which tells me the code i'm sharing in the OP is trying to push the servo past its normal sweep range

That is possible. What happens if you pick a middle value? Do you still get jitter and noise?

I have the feeback pin attached to an analog pin of an arduino
Do you have a solid signal ground from the Arduino to the Servo too?

adafruit_support_bill
 
Posts: 78736
Joined: Sat Feb 07, 2009 10:11 am

Re: Analog Feedback Servo Makes noise, inconsistent feedba

by bsautner on Mon Jun 15, 2020 5:37 pm

Which output are you using to power the servos - 12v or 5v? 12v would definitely make the servo jittery - if not a little smoky.
5v for sure, house still standing :)

That is possible. What happens if you pick a middle value? Do you still get jitter and noise?
no, but i don't get the full sweep of 180 degrees, playing with those values i get anywhere between 0-140 degrees but not he full 180 degree sweep the servo can do

Do you have a solid signal ground from the Arduino to the Servo too?
yes, i'm powering the arduino from the usb off the pi so i think that should do it? Same config works ok with the arduino doing everything which makes me thing it's the python code not calibrating things right

bsautner
 
Posts: 3
Joined: Tue Jul 19, 2016 3:04 pm

Re: Analog Feedback Servo Makes noise, inconsistent feedba

by adafruit_support_bill on Mon Jun 15, 2020 6:01 pm

If you are not seeing jitter in the middle, then your theory about pushing the limits of the position range is probably right. If so, you might be able to eliminate the jitter by pulling in your limits a bit.

Pushing the limits tends to result in current surges which can cause 'ground bounce' as well as noise that can affect your analog readings.

i'm powering the arduino from the usb off the pi so i think that should do it?

That is 'a' ground path. But for analog measurements you want to have a direct low-impedance connection to the ground reference for the signal you are measuring - especially in a noisy environment. I'd try adding a jumper from the Arduino GND to the GND on the PCA9685 and see if your analog measurements improve any.

adafruit_support_bill
 
Posts: 78736
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.