Reading RC Receiver values

Hi,

Using a RC transmitter to be able to control aspects of a circuit controlled by an Arduino is a very nice feature. The first thing that comes to my mind is controlling stepper motors instead of servos, as they are way more precise. An easier example, but cool nonetheless, is mapping the input to a PWM signal for diming LEDs.

Reading the values of the channels of your RC receiver is not as complicated as I first thought.
That is, if you have a receiver that is able to output a PPM sumsignal.
I recently bought a RC set, the mx-10 of the HoTT series from Graupner.
The receiver GR-12 coming along with it is able to provide you with up to 16 channels! However, the mx-10 has 5 channels, so setting it to a higher value makes no sense in this case.

In order to use the following code example you have to adjust the receiver settings to output the sum signal.
I did this using the SMART-BOX attached to the transmitter and scrolling to the menu

RX SERVO TEST->CH OUT TYPE:

The value needs to be set to

SUMO XX

where XX is the number of channels to be included in the output signal. With the following code you can then read the receiver values, if you have the S pin of the receiver attached to Pin 9 of the Arduino. Note that I set the number of channels to six, as I was curious to see what the default values are for an unused channel. Turns out to be a constant 0.5, which makes sense, as this is the value of a transmitter stick in middle position.

Note also that I had to check for the Pin to be HIGH instead of LOW, being the inverse of what other examples in the internet state. I haven't quite figured why this is the case. My first guess would be that the internal resistors are set to a different default state on the Arduino, compared to other ATMEL Atmega boards.

#define channumber 6
 
#define SignalPin 9
 
int value[channumber];
double ValueNormalized[channumber];
 
void setup() {
  Serial.begin(57600); //Serial Begin
  pinMode(SignalPin, INPUT); //Pin 3 as input
 
}
 
void loop() {
  if(pulseIn(SignalPin, HIGH) > 5000) {
    for(int x=0; x < channumber; x++) {
      //Loop to store all the channel position
      value[x]=pulseIn(SignalPin, HIGH);
      ValueNormalized[x] = value[x] - 500;
      ValueNormalized[x] /= 1000;
    }
 
    Serial.print(ValueNormalized[2]); //gas
    Serial.print(" ");
    Serial.print(ValueNormalized[3]); //yaw
    Serial.print(" ");
    Serial.print(ValueNormalized[0]); //pitch
    Serial.print(" ");
    Serial.print(ValueNormalized[1]); //roll
    Serial.print(" ");
    Serial.print(ValueNormalized[4]); //switch
    Serial.print(" ");
    Serial.print(ValueNormalized[5]); //not used
    Serial.println(""); //Start a new line
  }
 
}

[edit]

After using this code in some projects now, I realized there is a major flaw in this approach that I wasn't aware of at first. the pulseln(...) method seems to be blocking until the state of the measure line changes. For my setup this seems to be a long time, resulting a low update rate. In most applications this does not really matter, but what if I want to also read the values from the IMU? With this approach it wouldn't work. Currently I am looking for a solution for this and I will let you know if a found anything

Share on Google+Share on RedditTweet about this on TwitterShare on Facebook

One thought on “Reading RC Receiver values”

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.