0

Servo jitter
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Servo jitter

by Johnallenva on Wed Jan 11, 2017 10:36 am

I have been trying to solve a servo jitter problem for a few days now. I have tried using the servo libraries (myservo.write(pos) and myservo.writeMicroseconds(pos). I have tried writing my own pulses to the digital pin (e.g. digitalWrite(2, HIGH); delayMicroseconds(20000-pwm), etc.). I am using a 6V battery pack to power the servo. The servo still jitters with any pulse width from a minimum of 700 to a maximum of 2300.

Servos I have tried: TowerPro MG90D and MG92B.

Looking at the pulses on an oscilloscope they randomly go from 2.003 ms to 2.020 ms then back to 2.003.
IMG_4272.JPG
IMG_4272.JPG (208.53 KiB) Viewed 510 times

IMG_4271.JPG
IMG_4271.JPG (217.79 KiB) Viewed 510 times


I purchased the v2.3 motor/PWM/stepper shield because it had a PWM chip on-board, but I noticed that the servos are controlled by pins 9 & 10 anyways. Can I use the shield PWM to drive the servo?

Or do I have another issue here? Noise? Interrupts? This is my first use of a servo so I'm not sure what to try next. I can upload my code if needed, but it is a copy and paste from tutorials and examples on here.

Johnallenva
 
Posts: 4
Joined: Wed Jan 11, 2017 9:58 am

Re: Servo jitter

by adafruit_support_bill on Wed Jan 11, 2017 10:51 am

Physical jitter may or may not be due to the pulse width timing jitter. But let's look at the pulse width timing first:

I suspect that the control pulse width jitter is due to interrupt contention. The Arduino servo library is based on timer interrupts and the Arduino only has one level of interrupt handing.

The Motor Shield has a PCA9685 PWM chip on-board. But it is used for controlling motors and steppers. There are 4 spare PWM channels broken out on the board. You could use those for controlling servos - at the expense of the motor control. Motors don't run well using the 50-60Hz PWM rates needed for servo control.

The servo shield has all 16 channels dedicated to servo control: https://www.adafruit.com/products/1411

However, even with rock-solid pulse timing, you may still see some physical servo jitter. This is because servos are controlled with feedback, and if the tuning of the feedback loop is not ideal for the physical system it is controlling, the control loop will not be perfectly stable. Since servos are expected to operate over a wide range of loading conditions, the internal PID tuning is necessarily somewhat of a compromise. Some higher-end digital servos allow you to fine-tune the servo response to your application.

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

Re: Servo jitter

by Johnallenva on Wed Jan 11, 2017 11:40 am

That makes sense.

My application is going to need a motor (blower) and a servo. To do this with the v2.3 motor/servo/stepper shield PWM I'm going to have to switch the servo to a stepper motor; right?

There is also some "noise" on the corners of the pulses too. One of the RC forums suggested wrapping the motor leads 3x around a toroidal ferrite core. I figured I'd try this too to clean up the corners. Maybe a ferrite core and a capacitor? What capacitor should I use for this filtering?

Johnallenva
 
Posts: 4
Joined: Wed Jan 11, 2017 9:58 am

Re: Servo jitter

by adafruit_support_bill on Wed Jan 11, 2017 12:08 pm

Steppers tend to be more steady & precise than RC servos. But since there is no native feedback, you will probably need something like a limit switch to find the 'home' position at startup.

If you don't need to reverse your blower motor, you can control it with just a PWM pin and a power MOSFET, plus a kickback diode to protect the MOSFET.
https://www.adafruit.com/products/355
https://www.adafruit.com/products/755

Ferrites and capacitors will help filter high frequency noise. See the motor shield FAQ for details on how to install capacitors to tame DC motor brush noise.
https://learn.adafruit.com/adafruit-mot ... faq#faq-17

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

Please be positive and constructive with your questions and comments.