Recieving PPM signal and separating it into pins

Hi, I am building underwater ROV (remotly operated vehicle) and I have problems with program. Arduino is supposed to read PPM signal from RC controller (connected like "buddy"), separate (6) channels and send pulses into (6) pins to move servos (or brushless motors through ESC). Reading and separating is OK, but I have problems with sending it to servos. The servo is always kind of laggy, if you know what I mean. Any idea? I am starting to be hopeless... thank you very much for all replies.

Code please, otherwise how do we know what you have done ?
For instance, are you using pulseIn() or interrupts ?

This is it:

#include<Servo.h>
Servo channel1;
Servo channel2;
Servo channel3;
Servo channel4;
Servo channel5;
Servo channel6;
#define channumber 6 //Cuantos canales tiene tu radio???????/How many channels have your radio???
#define filter 10 // Filtro anti salto/ Glitch Filter
int channel[channumber]; //Valores de canales leidos/ readed Channel values
int lastReadChannel[channumber]; //Ultima lectura obtenida/ Last values readed
int conta=0; //Contador/couter
const int CH1 = 3;
const int CH2 = 5;
const int CH3 = 6;
const int CH4 = 9;
const int CH5 = 10;
const int CH6 = 11;

const int numReadings = 10;

int readings[numReadings][channumber]; // the readings from the analog input
int readIndex[channumber]; // the index of the current reading
int total[channumber]; // the running total
int average[channumber]; // the average
int thisReading[channumber];
int i =0;

void setup()
{
Serial.begin(9600); //Iniciamos com serial/ Serial Begin
pinMode(4, INPUT); //Patita 4 como entrada / Pin 4 as input
pinMode(13, OUTPUT); // Led pin 13
channel1.attach(CH1);
channel2.attach(CH2);
channel3.attach(CH3);
channel4.attach(CH4);
channel5.attach(CH5);
channel6.attach(CH6);
for (thisReading = 0; thisReading < numReadings; thisReading*++) {*
readings[thisReading_] = 0;
}
}
void loop()
{
//Serial.println("aaa");
if(pulseIn(4, HIGH) > 3000) //Si el pulso del pin 4 es > 3000 usegundos continua /If pulse > 3000 useconds, continues
{
* //Serial.println("bbb");
for(int i = 0; i <= channumber-1; i++) //lee los pulsos de los canales / Read the pulses of the channels*

* {
channel=pulseIn(4, HIGH);
//Serial.println("ccc");
}
for(int i = 0; i <= channumber-1; i++) //Promedia los pulsos/Average the pulses*

* {
//Serial.println("ddd");_

/ if((channel > 2100) || (channel <100))//Si se pasa del rango envia ultimo pulso/ If channel > max range, change the value to the last pulse

* {*
* // Serial.println("eee");*
channel_= lastReadChannel*;
}
else*

{ /
//Serial.println("eee");
//channel=(lastReadChannel+channel)/2; //Promedio el pulso pasado con el nuevo pulso/Average the last pulse eith the current pulse*

total = total - readings[readIndex];
* // read from the sensor:_
readings[readIndex] _= channel;
// add the reading to the total:
total = total + readings[readIndex];
// advance to the next position in the array:
readIndex = readIndex + 1;
// if we're at the end of the array...
if (readIndex >= numReadings) {
// ...wrap around to the beginning:
readIndex = 0;
}
//Serial.println("fff");
// calculate the average:
average = total / numReadings;
conta++; //Incrementa el contador/ increment counter*

* //}
}
}
//Serial.println("ggg");
if(conta > filter)//Si el contador es mayor al filtro imprime valores/ If counter is > than filter, then prints values*

* {
//Serial.println("hhh");
channel1.writeMicroseconds(channel[1]);
channel2.writeMicroseconds(channel[2]);
channel3.writeMicroseconds(channel[3]);
channel4.writeMicroseconds(channel[4]);
channel5.writeMicroseconds(channel[5]);
channel6.writeMicroseconds(channel[6]);
for(int i = 0; i <= channumber-1; i++) //Ciclo para imprimir valores/Cycle to print values*

* {
//Serial.println("iii");
Serial.print("CH"); //Canal/Channel*

* Serial.print(i+1); // Numero del canal / Channel number*
* Serial.print(": "); // que te importa*
Serial.println(channel*);
lastReadChannel=channel;
}
//Serial.println("jjj");
if(channel[4] > 1000) //si el canal 5 tiene un rango mayor a 500 enciende el LED/ If channel 5 is > than 500 turn on the led*

* {Serial.println("kkk");
digitalWrite(13, HIGH);
}
else*

* {
//Serial.println("lll");
digitalWrite(13, LOW);//Si no lo apaga/If not turn it off*

* }
// delay(400); //Delay*

* //Serial.println("mmm");
conta=0;//Reinicia el contador/ Restart couter.
}
//Serial.println("nnn");
}[/quote]*_

So, using pulseIn == yes, using code tags == no.

Have you looked at this?: Read-any-PPM-library

// Per.

What kind of range do you expect to get using RF underwater?

aarg:
What kind of range do you expect to get using RF underwater?

My best guess: "Connected like buddy" means that OP is using the "trainer"-port on the back of the RC-transmitter to get the raw PPM signal, which is then probably fed to the ROV via an umbilical-cord.

// Per.

Zapro:
My best guess: "Connected like buddy" means that OP is using the "trainer"-port on the back of the RC-transmitter to get the raw PPM signal, which is then probably fed to the ROV via an umbilical-cord.

// Per.

Yes, because it's hard to transmit radio signal under water, I have 12m long cable.

AWOL:
So, using pulseIn == yes, using code tags == no.

I am self-learner what exactly is code tag?

Azureta:
I am self-learner what exactly is code tag?

http://forum.arduino.cc/index.php?topic=148996.0

// Per.

Zapro:
How to use this forum - please read - Website and Forum - Arduino Forum

// Per.

thanks... bad english... sorry

I tried Read-any-PPM , but it doesn't work, it just print "ready" and nothing (I uncommented code in loop to print the values). When I wrote Serial.println("ready") behind setting timer, it didn't prin even "ready"

Discriminating a PPM signal from a radio control receiver to servos is done using a 74HC4017 plus a resistor and a couple of capacitors.