Go Down

Topic: Turnigy 9x RC and 8ch receiver (Read 2483 times) previous topic - next topic


Hi, I am building my own quadrocopter, but I have one problem. When I connect receiver directly to regulator and control it with RC, it works normally. But if I connect it via Arduino, then it sometimes start to rotate when it shouldn't rotate or rotate with about 1s breaks. I searched on google but I can't find the basic receiving and sending PPM to regulators and I don't want any completed solution because I want to create my code according to my needs. And I am using Arduino Mega 2560 R3.

My basic code for receiving PPM and sending to regulators:

Code: [Select]
#include <Servo.h>

Servo esc1;
Servo esc2;
Servo esc3;
Servo esc4;

int esc1_pin = 10;
int esc2_pin = 11;
int esc3_pin = 12;
int esc4_pin = 13;

int ch1;
int ch2;
int ch3;
int ch4;
int ch5;
int ch6;
int ch7;
int ch8;

void setup() {
  pinMode(2, INPUT);
  pinMode(3, INPUT);
  pinMode(4, INPUT);
  pinMode(5, INPUT);
  pinMode(6, INPUT);
  pinMode(7, INPUT);
  pinMode(8, INPUT);
  pinMode(9, INPUT);



void loop() {

  ch1 = pulseIn(2, HIGH, 25000);
  ch2 = pulseIn(3, HIGH, 25000);
  ch3 = pulseIn(4, HIGH, 25000);
  ch4 = pulseIn(5, HIGH, 25000);
  ch5 = pulseIn(6, HIGH, 25000);
  ch6 = pulseIn(7, HIGH, 25000);
  ch7 = pulseIn(8, HIGH, 25000);
  ch8 = pulseIn(9, HIGH, 25000);


This is my basic program for just receiving and sending pulses but it does I wrote above. Does anybody know, where is the problem? I tried to simulate it via sending data to serial port instead of to regulators and checking in console and it was ok. I suppose that there may be problem with delay but I changed it and didn't helped. Unfortunatelly I don't have osciloscope so I can't check the output pulses. So if anybody where is the problem it would be helpful, other code isn't problem, just the receiving and sending signals doesn't work.


Hi Kyong.

I'm not sure you can read the 8 channels with pulseIn() function.
I think pulseIn(pin, HIGH, time) waits a HIGH from a LOW. You read channel 1, when channel 1 goes to LOW you read channel 2 but in these moment channel 2 is HIGH already. Then pulseIn() for channel 2 is waiting for a LOW and it arrives one cycle (about 20 ms) later. So you are reading every channel every 8 cycles.

Also servo library uses interrupts and I think it causes errors in pulseIn() readings.

You can read some info from my blog http://cuadricopterodiyarduino.blogspot.com.es
But I'm sorry, it's in spanish.


Thanks for info unfortunatelly I don't understand spanish. I will try to use a translator on it. If the interrupts are problems how to solve it? Is it possible to solve it without parsing the whole PPM from receiver?


I don't know how people solve it or even if they have or not this problem. I think a lot of people have this problem with interrupts but they don't know they have it.

Although my project of quadcopter isn't finished I have developed a preliminary solution for this. Besides use a translator to understand all entries you can download the codes for it from




Go Up