RC Servo jitter frustration

Hello every one. Let me just start off by saying that I am pretty much brand-new to microcontrollers as well as to this form. I've been playing around with the Arduino for about a month now and have learned quite a bit. But now I have a problem that I can't solve, and I have become frustrated enough to ask.

What I am trying to do is control servos through the Arduino from an RC receiver and transmitter. I want to be able to move the stick my transmitter and have the Servo mimic the movement, for now at least. Later I want to be able to add mixing into the code so the servos move differently depending on the input of the stick.

I have written all the code and I am able to control a Servo from the Arduino. The only problem is that the Servo is jittery. I am pretty sure the problem is because the Arduino is only doing 8 bit resolution. Hobby servos need around 10 or 12 bit resolution. I know it is possible to change the timers on the arduino to increase the resolution but that is only for two pins on the arduino. I need to be able to do 5 inputs from the receiver and 4 Servo out puts.

Is there anyway to do this with an arduino microcontroller? Is there any unit in the world that can do this if not an arduino? And if so can I still put my own equations in to run the servos?

I am open to any suggestions or ideas, and I'm willing to learn.

Any help would be so greatly appreciated.

Hello Helinut,

it is possible, I've written something like that for flaps control.

The first thing to do is use the Servo Library to drive the servos. Any manual PWM is just junk, the library generates the pulses pretty cleanly with interrupts.

The second thing is reading the PWM signals from the rc receiver. Here you need to take special care that the pulse-length is measured properly. I ended up attaching the PWM-input to digital IO 2 or 3 to be able to attach interrupts at signal changes. You don't really want too big measuring errors, it can make the output servo jitter like crazy (sometimes only at some positions).

If you're using the ATmega328, measuring the incoming PWM pulse can be a little tricky. The 16-bit Timer1 is used by the servo library, the still free Timer2 is only 8bit and can't measure 1500µs precisely with a µs resolution and the function micros() offers you a maximum resolution of 4µs (8µs on 8 MHz CPU). You need to decide if that's good enough or if you want to start to become more tricky.

Let me know how things work out for you.

Korman

Korman,

I think I will have to become more tricky. Reason being is that I need five inputs. I think you are only using two inputs.

also are you saying that the problem is from reading the receiver not outputting to the servo?

I would be interested to see your code to better understand how this works. I have a hard time wrapping my head around the programming part, find it very confusing sometimes.

Regards

Before worrying about the output, spend some time to verify the numbers you get from the intput. In my case, the jitter came from unstable input values.

I tested it by setting the output to fixed values. If the jitter comes from the output PWM generation, even with a fixed value the servo will move.

Korman

ok i just did the quick test he suggested. I made the Servo hold a neutral position, no input from receiver. The Servo held perfectly.

Now how do I test to see if the receiver values are correct/ coming incorrectly?

Thanks so much.

Helinut, Did you ever get anywhere with this? I have run into the exact same problem. I can control servos reliably, but the input from my receiver is wiggling all over the place.

I set up a sketch to read the pulseIn and output to the serial monitor, and I can watch it happen in realtime. I have numbers between ~1100 and 1900 for each pin, and they fluctuate plus-or-minus about 10 microseconds (I think that's the unit) even when the transmitter sticks are still.

Let me know where you got with this, and maybe we can figure it out together.

I'm trying to make an on-board CCPM mixer based on a Nano so I can use my old radio with a new helicopter. I have the math working pretty well, it's just this jitter that's giving me trouble.

Thanks, Jeff

4µs variance come from the minimum time resolution of micros. Add to that the time your interrupts take when updating millis() or refreshing your servos when occusionally happening at an unfortunate moment, that's the jitter you end up with. The question is more how will you deal with this, there are various options.

Korman