Turnigy 9x RC and 8ch receiver


hi, building own quadrocopter, have 1 problem. when connect receiver directly regulator , control rc, works normally. if connect via arduino, start rotate when shouldn't rotate or rotate 1s breaks. searched on google can't find basic receiving , sending ppm regulators , don't want completed solution because want create code according needs. , using arduino mega 2560 r3.

my basic code receiving ppm , sending 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);
 
  esc1.attach(esc1_pin);
  esc2.attach(esc2_pin);
  esc3.attach(esc3_pin);
  esc4.attach(esc4_pin);

  delay(1000);

//serial.begin(115200);
}

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);

  esc1.writemicroseconds(ch3);
  esc2.writemicroseconds(ch3);
  esc3.writemicroseconds(ch3);
  esc4.writemicroseconds(ch3);
  delay(20);
}


this basic program receiving , sending pulses wrote above. know, problem? tried simulate via sending data serial port instead of regulators , checking in console , ok. suppose there may problem delay changed , didn't helped. unfortunatelly don't have osciloscope can't check output pulses. if problem helpful, other code isn't problem, receiving , sending signals doesn't work.

hi kyong.

i'm not sure can read 8 channels pulsein() function.
i think pulsein(pin, high, time) waits high low. read channel 1, when channel 1 goes low read channel 2 in these moment channel 2 high already. pulsein() channel 2 waiting low , arrives 1 cycle (about 20 ms) later. reading every channel every 8 cycles.

also servo library uses interrupts , think causes errors in pulsein() readings.

you can read info blog http://cuadricopterodiyarduino.blogspot.com.es
but i'm sorry, it's in spanish.


Arduino Forum > Topics > Robotics (Moderator: fabioc84) > Turnigy 9x RC and 8ch receiver


arduino

Comments

Popular posts from this blog

Convierte tu Raspberry en un NAS. Firmware fvdw-sl 15.3 - Raspberry Pi Forums

How to format a Get Request

avrdude: verification error, first mismatch at byte 0x0000 0x0c != 0x62