Sorry but i dont have scope.
I have made this code (made from different code parts around this forum)
It works 95%, the only thing is that every time i connect pin 4 (pulsein) the servos start to jitter. It seems like the pulsein measurement is not very precise. Or perhaps i'm doing something wrong ?
I have tried with different timeout values on the pulsein instruction, but without any luck 
Any ideas how to get rid of the jittering ?
#include <math.h>
#include <Servo.h>
int Chan0Interrupt = 0; // pin 2
int Chan1Interrupt = 1; // pin 3
int Chan2Signal = 4; // pin 4
//float Chan0_scaled, Chan1_scaled, Chan2_scaled;
unsigned long Chan0_startPulse, Chan1_startPulse, servo0_value, servo1_value;
volatile double Chan0_val, Chan1_val, Chan2_val;
volatile double Chan0_val_last, Chan1_val_last, Chan2_val_last;
long StartMillis=0;
long FrameCounter=0;
long pulsemin=900;
long pulsecenter=1500;
long pulsemax=2100;
boolean led;
Servo ServoArray[2];
void setup()
{
attachInterrupt(Chan0Interrupt, Chan0_begin, RISING);
attachInterrupt(Chan1Interrupt, Chan1_begin, RISING);
Chan0_val_last = pulsecenter;
Chan1_val_last = pulsecenter;
Chan2_val_last = pulsecenter;
for (uint8_t i=0;i<2;i++)
ServoArray*.attach(5+i, pulsemin, pulsemax);
Serial.begin(115200);
StartMillis = millis();
}
void loop()
{
long LocalMillis;
long LocalFrameCounter;
LocalMillis = millis();
Chan2_val = pulseIn(Chan2Signal, HIGH,15000);
if (Chan2_val < pulsemin || Chan2_val > pulsemax) { Chan2_val = Chan2_val_last;}
else {Chan2_val_last = Chan2_val;}
servo0_value = Chan0_val + (Chan2_val - pulsecenter);
if (servo0_value < pulsemin) {servo0_value = pulsemin;}
if (servo0_value > pulsemax) {servo0_value = pulsemax;}
servo1_value = Chan1_val - (Chan2_val - pulsecenter);
if (servo1_value < pulsemin) {servo1_value = pulsemin;}
if (servo1_value > pulsemax) {servo1_value = pulsemax;}
LocalFrameCounter = (LocalMillis - StartMillis) / 20; // Update servo positionevery 20msec*
* if (LocalFrameCounter > FrameCounter)
{
FrameCounter = LocalFrameCounter;
ServoArray[0].writeMicroseconds(servo0_value);
ServoArray[1].writeMicroseconds(servo1_value);
digitalWrite(13,led); // Flash led for every cycle*
* led=!led;
}
}
void Chan0_begin() // enter Chan1_begin when interrupt pin goes HIGH.
{
Chan0_startPulse = micros(); // record microseconds() value as Chan1_startPulse*
* detachInterrupt(Chan0Interrupt); // after recording the value, detach the interrupt from Chan1_begin*
* attachInterrupt(Chan0Interrupt, Chan0_end, FALLING); // re-attach the interrupt as Chan1_end, so we can record the value when it goes low*
* }
void Chan0_end()
{
Chan0_val = micros() - Chan0_startPulse; // when interrupt pin goes LOW, record the total pulse length by subtracting previous start value from current micros() vlaue.
detachInterrupt(Chan0Interrupt); // detach and get ready to go HIGH again*
* attachInterrupt(Chan0Interrupt, Chan0_begin, RISING);
if (Chan0_val < pulsemin || Chan0_val > pulsemax) { Chan0_val = Chan0_val_last;}
else {Chan0_val_last = Chan0_val;}
}
void Chan1_begin() // enter Chan2_begin when interrupt pin goes HIGH.
{
Chan1_startPulse = micros(); // record microseconds() value as Chan2_startPulse*
* detachInterrupt(Chan1Interrupt); // after recording the value, detach the interrupt from Chan2_begin*
* attachInterrupt(Chan1Interrupt, Chan1_end, FALLING); // re-attach the interrupt as Chan2_end, so we can record the value when it goes low*
* }
void Chan1_end()
{
Chan1_val = micros() - Chan1_startPulse; // when interrupt pin goes LOW, record the total pulse length by subtracting previous start value from current micros() vlaue.
detachInterrupt(Chan1Interrupt); // detach and get ready to go HIGH again*
* attachInterrupt(Chan1Interrupt, Chan1_begin, RISING);
if (Chan1_val < pulsemin || Chan1_val > pulsemax) { Chan1_val = Chan1_val_last;}
else {Chan1_val_last = Chan1_val;}
}[/sup]*