Decoding Radio Control signal pulses

I just thought it would be fun to get PCM out or PPM receiver. But PPM works great and I don't want to spend time working on PCM if will eat up too much arduino processing power, though your interrupt method could probably be adopted to read the bits of PCM transmission too?

By the way the library works with inverted signals too. For some reason my GWS receiver had it inverted and the only problem i noticed first channel had very high numbers (around 10,000 or so) but the rest of the channels were fine.

In my opinion, PCM would be a lot of work for no benefit. There are many more productive and fun things to do with your time.

BTW, if you want to use the library with a receiver with an inverted output, in ServorDecode.cpp change: volatile byte pulseEnd = PULSE_START_ON_RISING_EDGE ; // default value to volatile byte pulseEnd = PULSE_START_ON_FALLING_EDGE; // inverted pulses

then recompile the library (by deleting ServoDecode.o and rebuilding your sketch)

Bummer, should have asked earlier about the inverted. I already soldered a simple amplifier/inverter right on to GWS R4PII/H :( Well, it needed amplifier though - only had 2.5V impulses without it and was getting very noisy feedback from arduino controller back into the receiver. But with this code change i could have gotten away with just one transistor... Thanks for the info! ;)

I would have thought that the transistor and resistor would have been enough to invert the signal with the 2.5 volt pulses and drive the Arduino input. But no worries if you now have something that works.

Hi, I have a suggestion for the code, instead of using "TCNT1 = 0;", why not remember the previous value of ICR1 and keep track of overflows, this way you can get an unlimited value for the pulse width, also it's more accurate since it takes a few clock cycles to clear TCNT1

http://code.google.com/p/circle-of-current/source/browse/vex_ppm_reader/main.c

The only thing that can go wrong is if the capture event happens when TCNT1 is 0 and the capture interrupt executes before the overflow interrupt

Hi Frank, resetting TCNT to 0 takes 250 nanoseconds on a 16Mhz Arduino. Because the timer is counting in 500 nanosecond ticks I don't think this delay makes any difference. Indeed I would be surprised to hear if any of the radio control equipment that would be used with this kind of application would notice differences in timing of less than a microsecond.

I am not clear if the ability to detect unlimited values for the pulse width are something one would would use in radio control or if you have another application for the code.

Many thanks for taking the time to share your comments, its always interesting to see the different ways people approach things.

oh i totally agree that it's overkill, the RC radio would need a 16 bit ADC for the joystick if it wants to make the accuracy worthwhile, i'm not dividing my timer so i'm getting 0.05 microsecond resolution if i run my chip at 20 MHz

You connect the PPM stream to arduino pin 8.

Hi all, mem.... could you tell me what would be the designation for the pin 8, i´m using an Arduino Duemilinove board with an atmega 328 and i think pin 8 is not the indicated one for this board . ::)

thanks in advance

All the pin assignments are the same for the 328 and the 168. have you tried it on pin 8?

Hi again, i think you mean pin 8 at the top board, i haven´t tried yet…i ment IC pin 8(atmega), so i understand now,…i´ve loaded the code and i could visualize the data stream on the arduino serial monitor.
One more dumb question, what are the pin´s used for the outputs ? :slight_smile:

regards

If you are using Arduino (and most compatibles) , digital pin 8 is clearly marked on the board. http://arduino.cc/en/Main/ArduinoBoardDuemilanove

If you have built your own board, the pin assignments can be found here: http://www.arduino.cc/en/Hacking/PinMapping168

Thanks again mem . ;)

gmv

I have the ServoDecode_pde sketch working with my chepo VEX transmitter. When I attach my scope probe to the ppm pin to view the pulses while it's going to the arduino it switches to Failsafe mode the moment I touch the pin.

Any ideas what would cause this? The scopes input impedance is 1M ohm. Not sure why this would effect anything. I can see the pulses fine on the scope but the arduino goes immediately into failsafe.

Edit: I just noticed that if I touch the pull-up resistor with my finger it also goes into failsafe mode.... I'm confused!

Also when I have the sticks centered the values displayed are ~1500. The pulses when viewed on the scope are ~1ms so I would have expected the values to be around 1000 instead of 1500. (or is it 2 ticks per us so then it would be 2000)

Most transmitters send 1.5ms pulses with the stick centered. When was the last time you had your scope calibrated? ;)

How are you connecting the signal to arduino – are you sure you need pull-ups?

thanks for the reply the details of the ppm signal from the vex are listed here http://www.allelectronics.com/mas_assets/spec/JS-6.pdf As you can see the total range for the pulses is 0.5ms - 1.5ms and 1ms is the center position.

And yes you do need a pull up in order to see the pulses.

You would need to change MIN_IN_PULSE_WIDTH and MAX_IN_PULSE_WIDTH constants to lower values to work with the vex. It looks like the space betwen pulses is the same as valid pulse width so some of the error checking wont work.

Does the vex support 12 channels?

I don't have a vex so may not be much help if you run into problems. I suggest you keep things simple at first and try to get it working with 6 channels.

Thanks mem will try that when I get home....I forgot about the min pulse widths.... The vex only supports 6 channels (4 analog, 2 digital)

Also it is the low portion of the pulse that changes not the high the high pulses are always 500us. Is this different than most transmitters?

It is correct that the Vex transmitter has 6 channels, but I read (after doing a Google search for this transmitter) that you can connect an extra transmitter and have 12 channels.

I don't know the details, but those that are interested can look it up.

Most transmitters start a channel on the rising edge, but You can easily change it by making a small mod to the library.

in ServoDecode.cpp, change:

volatile byte pulseEnd = PULSE_START_ON_RISING_EDGE ; // default value
to
volatile byte pulseEnd = PULSE_START_ON_FALLING_EDGE; // inverted pulses