Reading signal from my quadcopter transmitter


hello mates,

i trying read signals form transmitter. (graupner mx-12 , orona cr8d)

right have done
code: [select]

#include <servo.h>

servo aileronservo;
servo elevatorservo;
servo throttleservo;
servo rudderservo;

servo ailerontarget;
servo elevatortarget;
servo throttletarget;
servo ruddertarget;



unsigned long pwmin;
int throttle=0;
int elevator=0;
void setup() {
serial.println("initializing motors...");
serial.begin(9600);

        aileronservo.attach(9);
elevatorservo.attach(10);
        throttleservo.attach(6);
        rudderservo.attach(11);
     
        ailerontarget.attach(4);
elevatortarget.attach(3);
        throttletarget.attach(5);
        ruddertarget.attach(2);
       
throttletarget.writemicroseconds(1000);  // min throttle
        ruddertarget.writemicroseconds(2000);  // full left rudder (use 2000 full right rudder)
        delay(4000); // wait flight controller recognize arm command
        ruddertarget.writemicroseconds(1500);  // return rudder center position.
       
serial.println("sync completed...");
}

void loop() {
        pwmin = pulsein(5, high, 20000);     
        serial.println(pwmin);
        /*throttle = throttleservo.read();
        serial.println(throttle);
        elevator = elevatorservo.read();
        serial.println(elevator);*/
}


and output in serial monitor 981 or 982.

the basic idea read signals, read throttle give left stick , stuff controlling it, advance algorithms stability etc. ill appreciate if me out :/

thank you,
billy

i used following program change pulse length going naze32 flight controller putting arduino between rc receiver rudder , throttle outputs , naze rudder , throttle inputs.
code: [select]
const byte yawinpin = 7;
const byte yawoutpin = 8;
unsigned long yawduration;

const byte thrinpin = 9;
const byte throutpin = 10;
unsigned long thrduration;

void setup()
{
  serial.begin(115200);
  pinmode(yawinpin, input);
  pinmode(yawoutpin, output);

  pinmode(thrinpin, input);
  pinmode(throutpin, output);
}

void loop()
{
  yawduration = pulsein(yawinpin, high);
  yawduration = map(yawduration, 1000, 1800, 980, 2020);
  digitalwrite(yawoutpin, high);
  delaymicroseconds(yawduration);
  digitalwrite(yawoutpin, low);  

  thrduration = pulsein(thrinpin, high);
  thrduration = map(thrduration, 1000, 2000, 980, 2020);
  digitalwrite(throutpin, high);
  delaymicroseconds(thrduration);
  digitalwrite(throutpin, low);  
}

as happened found out how set naze parameters not needed, worked.

for more comprehensive code @ arducopter site.  apm uses arduino mega based board provide control of multirotors , software open source.


Arduino Forum > Using Arduino > Programming Questions > Reading signal from my quadcopter transmitter


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code