Reading signal from my quadcopter transmitter

Hello mates,

I am trying to read some signals form the transmitter. (Graupner MX-12 and Orona CR8D)

Right now this is what i have done

#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 for Full Right Rudder)
        delay(4000); // Wait for the flight controller to recognize the ARM command
        RudderTarget.writeMicroseconds(1500);  // Return rudder to 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 the output in the serial monitor is 981 or 982.

The basic idea is to read the signals, read the throttle that i give with the left stick and then so some stuff like controlling it, some advance algorithms for stability etc. Ill appreciate if anyone could help me out :confused:

thank you,
Billy

I used the following program to change the pulse length going into a Naze32 Flight Controller by putting the Arduino between the RC receiver rudder and throttle outputs and the Naze rudder and throttle inputs.

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 it happened I then found out how to set the Naze parameters so it was not needed, but it worked.

For much more comprehensive code look at the ArduCopter site. APM uses an Arduino Mega based board to provide control of multirotors and the software is open source.

Thank you for you answer, do you have any idea what should i do to READ and not write to the FC? I just dont know if i must connect the Transmitter into PMW pin, Analog pin, tha only one TX pin etc...

What are you hoping to read from the FC ?

I am trying to READ from the transmitter and just pass the values to the FC. Read the signals eg. throttle 1100 throttle 1120 etc...

Look at the code that I posted. It reads data from 2 channels of the Rx, changes them and passes on the changed data to the FC.

I am trying to READ from the transmitter and just pass the values to the FC. Read the signals eg. throttle 1100 throttle 1120 etc...

If you don't want to change the values then either pass them on unchanged or connect the channels directly from the Rx to the FC.

However in your first post you said

The basic idea is to read the signals, read the throttle that i give with the left stick and then so some stuff like controlling it, some advance algorithms for stability etc.

Have you got a Flight Controller, if so which one, or are you aiming to use the Arduino as the FC ?

Hi, I have KK multicopter flight controller v5.5 i think. I am using right now a direct connection and everything is fine. However i want to have my arduino in the middle!!! :slight_smile: so...yep i was trying to just pass the values that i read and write them to the FC but i was not working.

You use pulseIn to read the duration of a pulse. Lets say a small throttle. I did the same, tried to read and the value that i have read is static. something like 98 i guess :confused: Any ideas?

if you only need to pass on the Rx's PWM signal, why don't you just split the signal from each channel you use?

say plug into throttle, then split that into two
connect one to your KK and the other into your arduino

even if i split i need to READ it with my arduino and the pulsein thing is not working :confused: also servo.read() does not work. :confused: Shall i plugin an analog pin?

You use pulseIn to read the duration of a pulse. Lets say a small throttle. I did the same, tried to read and the value that i have read is static. something like 98 i guess :confused: Any ideas?

Have the Rx and the Arduino got a common GND ?

Actually i have no idea what happen. Now its working :confused: Can you please explain me

thrDuration = pulseIn(thrInPin, HIGH);
  thrDuration = map(thrDuration, 1000, 2000, 980, 2020);
  digitalWrite(thrOutPin, HIGH);
  delayMicroseconds(thrDuration);
  digitalWrite(thrOutPin, LOW);

the above process? :confused: I mean i get it. You get the pulse...after that?

thank you very much and i appreciate your time...

looks like it..

grabs a HIGH duration value from thrInPin when it goes HIGH(size of PW)
remaps the value for thrDuration when it is a range of 1000-2000 it becomes 980-2020 instead
then it turns thrOutPin to a HIGH state
keeps it held high for the thrDuration
after the delay, it sets thrOutPin to LOW

That explanation is spot on.
My RC transmitter was not providing long or short enough pulses on throttle and rudder to arm the FC so I needed to extend the limits at both ends.