Go Down

Topic: Trouble with Servo Jitter on the Mega (Read 15311 times) previous topic - next topic

Fandu


Cross post from: Google Code, Issue #170

I am using a Mega to control a UAV tracking antenna and I'm seeing some odd 'jitter' in the servos while holding them at a steady position.  Although I would describe the phenomenon as 'jitter', it is much larger in amplitude than your typical servo jitter.

Using Arduino Mega, tested with both MegaServo and Servo libraries.  Tested with multiple servos and seeing the same issue on all brands.

Running the Megaservo demo sketch works fine, the problem seems to be related to writing to the LCD screen.  My LCD is connected as follows:

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

And servo is connected as follows:
pan_servo.attach( 2, 720, 2283);

I am also using 3 of the serial ports for various things.  I am also using the TinyGPS library for NMEA decoding.

My main loop continuously writes data to the LCD screen and servo position.  This jitter is observed while sitting in the loop with the servo position being held constant.  Every 2-3 seconds the servo abruptly jumps a degree or two.  The direction of the jump seems random, although over time the same average servo position is maintained.

I'm fairly new to the arduino, but this seems like a timer conflict or interrupt issue.  My sketch does not disable interrupts, although one of the libraries may be.

Any ideas?

Ozybard

G'Day

I'm an RC Modeller of long standing and in my experience, jittering servos are mainly caused by the wiper of the inbuilt mechanical potentiometer being a little dirty thus varying the resistance slightly in response to ambient vibration.  The only cure that I know of is to disassemble the servo and carefully clean the pot' and reassemble. NOT an exercise for the faint hearted.  In fact, these days, I don't bother as servos are so cheap. Besides, I cant see the small parts anymore. ;)

mowcius

This problem occurs with the software serial library and others as well. I was writing to an LCD and had issues... It is apparently due to the interrupts or something. You can stop it happening by detaching the servo(s) when they are not doing anything and using servo.attach(); before you want to use them again. Probably not ideal for that setup but that is the problem...

Mowcius

Fandu

Quote
I'm an RC Modeller of long standing and in my experience, jittering servos are mainly caused by the wiper of the inbuilt mechanical potentiometer being a little dirty thus varying the resistance slightly in response to ambient vibration.  The only cure that I know of is to disassemble the servo and carefully clean the pot' and reassemble. NOT an exercise for the faint hearted.  In fact, these days, I don't bother as servos are so cheap. Besides, I cant see the small parts anymore.


Yeah that was my first thought too.  I tried a couple of misc Futaba servos that I had lying around and they exhibit the same behaviour, so I don't think it's a problem with the particular servos that I'm using.  With the standard Futaba servos, this jitter is pretty minor - their impulse response is so slow that they don't move very much when it occurs.

I'm using a Servo City a pan & tilt kit with external feedback pots with modified Hitec HS-985MG servos.  These things are both quick and powerful and this jitter is rather 'alarming'.  

I haven't put a scope on the servo pwm signal yet, but I'm pretty convinced that it's a problem with the pwm, not the servos them selves.

I will give the detach/reattach fix a try and see if that helps.  Does detaching the servo not also disable the pwm signal as well?

Fandu

As I suspected, detaching the servo disables the PWM output to the servo which makes this fix pretty useless.  

I've also noticed that this jitter occurs during servo movement as well, not just while holding position.  Every once in a while I'll see the servo jump while it's in motion.  

Is anyone else experiencing this?

retrolefty

#5
Feb 24, 2010, 06:39 pm Last Edit: Feb 24, 2010, 06:41 pm by retrolefty Reason: 1
Many times problems like this have to do with how you are supplying power to the servos. Using the Arduino boards +5vdc to power external servo is almost always a problem, either because of drawing too much current on not have enough power filtering.

As an experiment you might try and use 4 AA battery cells wired in series to power the servo's power and ground pins and be sure to wire a connection between the battery ground and an Arduino ground pin. Try that and see if your jitter decreases.

Lefty

Fandu

I am already powering the servos externally and I've connected the two grounds together.  I don't think it's a power issue, but I could be wrong.

keeper63@cox.net

It's probably a timing issue with all the other code running; the PWM isn't perfect, especially if there is other stuff going on in your code - also, I think sending/receiving serial data can cause the PWM to glitch every now and again.

Have you thought about using an independent servo controller board instead of using PWM to drive your servos? They are fairly inexpensive. I currently have a Pololu Micro Serial Servo controller that you communicate with using a couple of digital i/o lines (via a software serial line or a real hardware TTL serial port). Interfacing with it is dead simple.

Incidentally, I am ultimately going to use mine for a pan/tilt servo system for a camera; I am still working on the library code...
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

calfred

hey there, i had the jitter too.
i;m using s3v3 severino board.

external power supply for servo.
dc adapter 5.6V for severino.

i used the sweep program.
http://arduino.cc/en/Tutorial/Sweep

but i had to wait for 40secs before the servo rotates 0-180deg (back n forth) like it should.
during the 40secs, there were jitters every 10secs.

calfred

thing is, why do i have to wait for 40secs?!

Fandu

OK, so I've been looking into this a bit more.  My theory was that this jitter was being caused by an interrupt (serial, etc) which was causing the PWM interrupt to be delayed, and the signal to be skewed as a result.  

So I put the arduino on a scope and the problem is pretty obvious:



The short pulses are 1.5ms as they are supposed to be, then all of a sudden we get a ~25ms pulse.  Hu?

Now, taking a closer look at the beginning of that long pulse.  Right at 1.5ms the pulse actually drops back to 0 and then immediately comes back up again.  If it was an interrupt issue as I suspected, then it would not be dropping to zero and jumping back up again.



So, any ideas as to what is causing this to happen?

ulrichard

No idea about the jitter, but recently I saw an i2c servo controller:
http://dshop.ch/osc/product_info.php?products_id=109014


keeper63@cox.net

I wonder what would happen if you stuck a small capacitor between the servo pin and ground...? Just speculating here...

;)
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

GrooveFlotilla

#13
Mar 10, 2010, 09:35 am Last Edit: Mar 10, 2010, 09:35 am by GrooveFlotilla Reason: 1
Which version Arduino are you using?

(BTW, it's not PWM, it's PPM)
Some people are like Slinkies.

Not really good for anything, but they bring a smile to your face when pushed down the stairs.

cxevalo

look at the power supply pin and the ground pin on the processer at the time the out put is being reset. This problem smells like noise.

Go Up