5 minute read

I got interested recently into some USB to PPM devices and related devices, that let you generate PPM signal from your computer. What’s PPM (Pulse Position Modulation) you say? That’s a more or less standard signal many RC Radios output for “buddy boxing” for example.

This means one RC Radio controls the other one. Chances are that you also use it, when you plug your RC Radio on your computer to fly your simulator.

These devices are expensive. However, a PPM signal can travel very well over an audio channel at high rate and high precision.

I first proposed this solution on a well known RC forum, where I got a usual warm reception “it can’t work”. Somehow, as a weak human I decided they know better and left it out.

Few weeks later, I got myself one of these USB2PPM cable for $1 as part as a cheap developer program. However this cable cannot yet work on my Spektrum DX7 due to a different PPM signal. I notified the author so this might be fixed. :)

However, it was a good occasion for my PPM over audio idea to re-surface. You know, this kind of: “but of course it’s going to work, what was I thinking?!”. I thus bring to you a small open source PPM generator, that should work with most RC Radios and computers and will cost you nothing.

Requirements

  • An RC Radio with a trainer port supporting PPM (I use a Spektrum DX7)
  • A mono or stereo audio cable male-male or stereo/mono male plugs
  • A pair of hands and preferably 10 fingers (your own will do.)

Plugs

While this is UNTESTED with other than Spektrum radios, this should work for your own radio, if you’re willing to solder and program a little bit. So DO THIS AT YOUR OWN RISKS. Now that you’re warned, let’s go..

I’ll link several times to the excellent SmartPropoPlus, which does just the opposite of what we’re going here, sending PPM from the RC Radio to the computer using an audio cable. (In case you did not get it yet, we send PPM from the computer to the RC Radio instead).

Spektrum/JR

Easiest, if you don’t feel like you need to protect your sound card you can use a regular stereo or mono male-male wire - i’m doing just that!):

  • http://www.smartpropoplus.com/dnn/Hardware/Spektrum/tabid/94/Default.aspx

Futaba Square

  • http://www.smartpropoplus.com/dnn/Hardware/FutabaRect/tabid/75/Default.aspx

Others

  • http://www.smartpropoplus.com/dnn/Hardware/tabid/57/Default.aspx

Note: PCM probably works very well too, but you’ll need to modify the program, I don’t have a PCM Radio yet. We’re only dealing with PPM today!

The Spektrum DX7 PPM signal

The PPM frame is 22.5 milliseconds.

It starts with a PPM “stop”, negative signal of 0.4 milliseconds.

Each channel (8 channels, no matter how many the transmitter supports) is a positive signal of 0.7 milliseconds to 1.5 milliseconds. This means, 0.7 milliseconds is “full left” servo position, 1.5 milliseconds is “full right” servo position and 1.1 milliseconds is “middle” or neutral position (default stick position, except for throttle).

Channels are:

  • Throttle
  • Ailerons
  • Vertical stabilizer
  • Rudder
  • Aux2 or Gear
  • Aux2 or Gear
  • Usually a mix
  • Unused on the DX7

After a channel signal, a 0.4 millisecond “stop” is inserted.

Once all channels and stop have been stored into the PPM frame, a leading “blank” (flat signal) is inserted so that the complete signal is 22.5 milliseconds (so the size of the flat signal depends on servos positions, that’s why it’s calculated at the end.. even if its put at the start of the signal).

The amplitude is important. It depends on your sound card. In reality, it’s 1.3volts. If the amplitude is incorrect, the Spektrum DX7 just won’t understand the PPM signal!

image-center

Program

Currently, this is only a Linux program using ALSA as audio output. This is basically a demo program.

You’ll need pygtk, gtk, alsa-lib, pyalsaaudio to run the program. Please excuse the code, it’s only used as a working proof of concept, and may help you code your own! Here is the PPM generation extract only:

#!/usr/bin/python

# Licensed under the terms of the GPL version 3.
# http://www.gnu.org/licenses/gpl-3.0.html
# Copyright kang@insecure.ws

class GenSignal:
        signal = ""
        duration = 0.0225 # seconds
        mmdiv = 4.4 #0.1ms
        samplerate = 44100 # Hz
        samples = int(duration*samplerate) #992.25 - python rounds up but its ok, our signal is still way more precise than others
#       amplitude = 32760 #max volume.. change it for your sound card or it wont work.
        amplitude = 20262

        channels = {1: 0.0, #throttle
                2: 0.0,
                3: 0.0,
                4: 0.0,
                5: 0.0,
                6: 0.0,
                7: 0.0,
                8: 0.0,
        }

        def generate(self):
                clist = []
                #start with a stop
                clist += [-self.amplitude]*int(self.mmdiv*4)
                for i in self.channels:
                        #ppm base (0.7ms)
                        clist += [self.amplitude]*int(self.mmdiv*7)
                        #ppm signal (on spektrum, its from 0.7ms to 1.5ms max)
                        servo = self.channels[i]*0.75/100
                        signal = (self.mmdiv*10)*servo
                        clist += [self.amplitude]*int( signal )
                        #on spektrum, the stop is fixed size
                        clist += [-self.amplitude]*int(self.mmdiv*4)

                #complete the ppm signal with a starting null signal that fill in the 22.5ms frame (here f.ex 992 self.samples)
                list = []
                for i in range(0, self.samples-len(clist)):
                        list += [0]

                #add our ppm channels
                list += clist

                s=pack('<'+self.samples*'l',*list)
                #s is a raw PCM/wav signal, you can save it to wave or send it over PCM compatible interfaces,
                #like ALSA (not to confuse with RC PCM, similar but different.)

The full program is available here (again, Linux only!)

Future

I plan to port this program to Windows (in fact, it might become Windows only for a while as my video capture USB stick has only Windows drivers and I can’t be bothered to reverse them on Linux. Then I can fly my stuff using a joystick while looking at the video feed :). Feel free to make your own program tho. I’ll appreciate if there’s a mention of where you got the idea from :P

The Windows program will interface with Windows joysticks so you can use your joystick to control your RC aircraft. With luck, someone will improve it later to support PCM and maybe trims/mixing. I do not currently plan to implement it as my Spektrum DX7 takes care of this (P-LINK mode), but I might upon request.

Updated:

Comments