Reading RC receiver

Hello,

I just bout an RC 6ch transmitter with receiver and I wanted to test it out with my Arduino Uno. I used the attachInterrupt method to read the pwm. From my results I was getting values from 18000 - 19000. Assuming the values are in micro seconds. Based from what I have researched and my understanding, the pulse width should be from 1000 - 2000 micro seconds.

I double checked my connections. + - wires from receiver go to 5v and ground pin on Uno board. Signal wire goes to D3.

I appreciate any help to the right direction.

Thanks, BP

Here is the code I used to print the pwm values for testing.

volatile int pwm_value = 0;
volatile int prev_time = 0;

void setup() {
  Serial.begin(115200);
  attachInterrupt(1, update, CHANGE);
}

void loop() { 
    Serial.println(pwm_value); 
    delay(100);
}

void update() {
  if (digitalRead(3) == LOW){
    prev_time = micros();
  } 
  else
  {
    int now = micros();
    pwm_value = now - prev_time;
  }
}

Looks like your'e calculating the LOW time, rather than HIGH time.

Here's a working example for you to compare with . . .

Camel - Yes indeed. I have fixed my issue. The values go from 1000 to 2000 usec now.

Thanks for the help! BP

Camel: Here's a working example for you to compare with . . .

Not too long ago I compared a couple different methods of reading in pulses from a RC receiver.

I found many methods missed a lot of the incoming pulses. I added some code to count how many pulses were received in a given amount of time and found the PinChangeInt library did a great job of catching all the pulses.

Do you know if the method you're using catches all the pulses?

Next time I have my gear out, I'll try out the method you suggest to see how it does. Thanks for linking to your page.

DuaneDegn:
Not too long ago I compared a couple different methods of reading in pulses from a RC receiver.

I found many methods missed a lot of the incoming pulses. I added some code to count how many pulses were received in a given amount of time and found the PinChangeInt library did a great job of catching all the pulses.

Do you know if the method you’re using catches all the pulses?

Next time I have my gear out, I’ll try out the method you suggest to see how it does. Thanks for linking to your page.

Well, in theory it should catches all pulses but to be honest I’ve only tested it on ARM processors (Due, Teensy3.1 and STM32 boards). I’d be surprised if it missed a noticeable number of pulses.