Fluctuation for PWM reading

i currently have a project where i consisting of a Turnigy RC receiver, Arduino Mega and Naza Flight controller.
The Mega will act as a "relay" where it reads the PWM signal from the Turnigy RC receiver, and output it to the Naza flight controller.

when i use the pulseIn function to read the pulse duration, the value it shows is fluctuating. e.g. for the same control stick position, values can range from 1040-1056. this fluctuation caused my motors to have fluctuations too, where i could hear it some fluctuations in the motor spinning speed.

i have tried to connect the RC receiver direct to Naza and the motors spin fine.

is there any way to solve the fluctuation issue, yet not causing additional time delay (time taken from change in control stick position to change in motor spinning speed)?

Thanks.

(deleted)

forgot to attach my code..

#include <Servo.h>

Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;

const int pin1=31;
const int pin2=32;
const int pin3=33;
const int pin4=34;
const int pin5=35;

const int output1=3;
const int output2=4;
const int output3=5;
const int output4=6;
const int output5=7;

int duration1=0;
int duration2=0;
int duration3=0;
int duration4=0;
int duration5=0;

void setup()
{
pinMode(pin1,INPUT);
pinMode(pin2,INPUT);
pinMode(pin3,INPUT);
pinMode(pin4,INPUT);
pinMode(pin5,INPUT);

servo1.attach(output1);
servo2.attach(output2);
servo3.attach(output3);
servo4.attach(output4);
servo5.attach(output5);

Serial.begin(9600)
}

void loop()
{
duration1=pulseIn(pin1,HIGH);
duration2=pulseIn(pin2,HIGH);
duration3=pulseIn(pin3,HIGH);
duration4=pulseIn(pin4,HIGH);
duration5=pulseIn(pin5,HIGH);

Serial.println("Ch1 ch2 ch3 ch4 ch5");
Serial.print(duration1);
Serial.print(" ");
Serial.print(duration2);
Serial.print(" ");
Serial.print(duration3);
Serial.print(" ");
Serial.print(duration4);
Serial.print(" ");
Serial.print(duration5);
Serial.print(" ");
Serial.println(" ");

servo1.writeMicroseconds(duration1);
servo2.writeMicroseconds(duration2);
servo3.writeMicroseconds(duration3);
servo4.writeMicroseconds(duration4);
servo5.writeMicroseconds(duration5);

delay(100);

}

Have you tried the code without the print statements and without the delay(). A delay of 100 msecs is two full servo data cycles.

What happens if you comment out all the code except for a single servo (any one of them) ?

I'm just wondering if the succession of pulseIn()s interfere with each other.

...R

Robin2:
Have you tried the code without the print statements and without the delay(). A delay of 100 msecs is two full servo data cycles.

What happens if you comment out all the code except for a single servo (any one of them) ?

I'm just wondering if the succession of pulseIn()s interfere with each other.

...R

i have tried for only one servo, it gives the same problem... so i'm guessing its not the succession of pulseIn() that cause the problem.

I think the timing resolution of pulseIn() is ±4µs (please correct me if I'm wrong). The fluctuation you're getting is ±8µs. As you approach the lower limit of pulseIn(), the error due to timing resolution becomes more significant.

As a solution, you may need to average multiple readings. I think there's ample room to play here, because no matter how many coffees I have, I cant get my own response time better than 100000µs (0.1 sec).