Problem reading the PPM signal form a RC rx :-(

I've hocked up a futaba rx to pin 3 and I'm executing the code below. But I only get "Duration: 0". I've also connected a oscilloscope to pin 3 and I can see the signal from the rx. But pulseIn can't seem to read it? What am I doing wrong here? :cry:

void setup() {   
  Serial.begin(9600);  
  pinMode(3, INPUT);
}
long i = 0;

void loop() {
    Serial.print("Duration: ");
    i = pulseIn(3, LOW);
    Serial.println(i);
}

How do you have it hooked up?

I haven't had experience with pulseIn, but make sure your grounds are connected! That seems to be one of the common mistakes.

I'm sure somebody else can come in and fix the code, if that's the problem! :smiley:

Best of luck.

You want to measure the duration of the high pulse, not the low – change LOW to HIGH in your code.
But you should get some kind of reading either way so do check that you have the receiver ground connected to arduino ground

I tried high I tried low ... still nothing, the ground is connected ok. My oscilloscope can se the signal, using same ground and same pin.

Any mote ideas? I really dont understand whats wrong? >:(

Can you see on the oscilloscope if the pulse is more than 2½ volts?

Perhaps try to test the input using a switch (with a pull-up or pull-down resistor as per one of the many switch tutorials) to see if you can get a pulseIn reading that way.

You may want to try another pin to see if pin 3 is defective.

Hmm, ok, so the voltage might be to low? that is probibaly correct. I only have 0.5 volts.

Is the receiver working with a normal servo? I would be surprised if you can get a servo to work on half a volt.

Its working perfekt with a servo ... hmm could the problem be that Im taking +5 from the arduino board to power the rx when Im trying to use the pulesIn? When I tried the servo now I use a esc with a buildin bec. Maybe the arduino +5 is to week to allow the rx to send a good signal?

The arduino should be capable of powering the receiver as long as you don't have any servos plugged in

Still no progress I tried a external BEC to the rx but still same result.

I also tried to attach a capacitor to the pin from the rx and doing a analog read instead of a pulsein, this works, so I assume the pin is ok.

But why wont pulseIn in work? Im running out of ideas ...

Ground is ok, and I can see the signal om my oscilloscope when I attatch it to same groung and same pin as the arduino. The arduino can read the pin with analogRead but not with pulseIn. ???

Any more sudgestions?

The level needs to be more than 2.5 volts for it to be read by digitalRead. AnalogRead can detect voltages as low as 5 millivolts but this is of no use for measuring pulse width.

Did you test pulseIn with a switch and resistor as suggested earlier?

Havent tried with a switch but if it needs 2.5 volts to be detected as a 1 thats the problem. Then I need to amplify the amplitude of the pulse ...

Can anyone verify that the PPM signal from a futaba rx only should have a ampltude of 0.5 volts?

Not sure if this will work but its worth a try – turn on the internal pull-up resistor on your input pin:
after setting pin 3 as input add: digitalWrite(3, HIGH);

See if that kicks it into life

Can anyone verify that the PPM signal from a futaba rx only should have a ampltude of 0.5 volts?

Depends how you measure it.
With a 'scope (good method), or with a multimeter (bad method) ?

A 1.5/20 duty cycle isn't going to read too well on a digital multimeter.

digitalWrite(3, HIGH); didnt work.

Im using a oscilloscope and have a very clear picture of the signal. :wink: Its amplitude is 0.5 volts. And I need above 2.5 to read it with pulseIn, thats my problem . :-/

Were you still only getting 0.5 volt pulse with the pull-up?

If you disconnect the receiver and connect a wire from the pin to Gnd, can you get a reading if you quickly disconnect and then reconnect the wire?

0.5 from RX no pullup involved.

This code give '0' as print out, even when I try with a cable from GND to the pin, plugging it in and out as fast as I can, I also tried to change pin ...

long i;
void setup() {   
  //analogReference(INTERNAL);
  Serial.begin(9600); 
  pinMode(0, INPUT); 
  digitalWrite(0, HIGH);
}
void loop() {
   i = pulseIn(0, HIGH);
   Serial.println(i);
}

Why did you change from using pin 3 to pin 0? Pin 0 is used by the serial hardware. Try it again using pin 4 if you want to test another pin.

If that doesn't work, replace the pulseIn command with code to light an LED and see if that works, the LED should turn off when you connect pin 4 to ground :

void setup() {  
  pinMode(4, INPUT);
  digitalWrite(4, HIGH);
  pinMode(13, OUTPUT);
}
void loop() {
   digitalWrite(13, digitalRead(4));  
}

D'OH!

This is almost ebarising. I had connected the signal from the rx to the ANALOG IN pin 0 and 3 ... won't get digital signal there ... Now at digital pin 2 it works PERFECT.

Thanks for all the help! :sunglasses: