HobbyKing.com New Products Flash Sale
Reply
Thread Tools
Old Mar 09, 2010, 02:23 PM
Registered User
Joined Aug 2009
1,530 Posts
Cool
Control your plane via your computer - no expensive cable needed

After some discussion in the FPV threads I decided to show it's possible to generate perfectly good PPM with a computer and feed the Spektrum DX7 with it.

Actually, the PPM generated is much higher quality and precise than most of the USB devices you'll find. It cost barely nothing: just a stereo or mono audio cable (or a trainer cable for JR/Spektrum.. they're audio cables)

Note that the final quality depends on your sound card, but most sound cards can produce this signal perfectly well.
The PPM can be adapted to other brands if you modify the cable, I'll provide at least Futaba support when I get the time. Contributions welcome.

A demo, open source, Linux program is available here, with complete explanation and Spektrum DX7 PPM signal specifications:
http://www.insecure.ws/2010/03/09/co...computer-for-0

A Windows program with joystick interface (basically, control your plane with a joystick) will be available later, I have yet to program it.

Here's a proof and demo:

PPM over audio demo (4 min 32 sec)


Enjoy
jimbob00 is offline Find More Posts by jimbob00
Reply With Quote
Sign up now
to remove ads between posts
Old Mar 09, 2010, 03:10 PM
glider pilot in training
webdragon's Avatar
United States, AR, Searcy
Joined Aug 2006
647 Posts
think it'll work with a Spektrum DX5e?
webdragon is offline Find More Posts by webdragon
Reply With Quote
Old Mar 09, 2010, 04:57 PM
Registered User
Joined Feb 2006
65 Posts
nice project!
looking forward to see the futaba/windows version.

thanks for sharing!
fern is online now Find More Posts by fern
Reply With Quote
Old Mar 09, 2010, 05:57 PM
Registered User
Joined Aug 2009
1,530 Posts
Quote:
Originally Posted by webdragon View Post
think it'll work with a Spektrum DX5e?
yes probably if it supports master mode
(edit: just found the manual and it says it does. it defaults to PLINK, meaning rates/trims are set on the DX5e which is good for this application)

if you want to see your PPM signal supported, the easiest is to make a sound capture of it.
Make the cable as specified on smartpropoplus website ( http://www.smartpropoplus.com/dnn/Ha...7/Default.aspx )
Check it works for sending PPM (you can install Smartpropoplus and use the PPM monitor e.g., when your RC Radio is connected to the sound input)

When that works, use your favorite sound recorder (even sndrec32 should be ok i think), set 16bit and 44100hz, stereo, leave all stick centered except throttle to zero and record.
while recording, after a few secs, put full throttle, wait 1 or 2 sec and stop recording. then host the recording somewhere.
if the quality is good enough i'll try to figure out the PPM signal and include it. Same for PCM if the radio does not support PPM.
jimbob00 is offline Find More Posts by jimbob00
Reply With Quote
Old Mar 09, 2010, 08:29 PM
$#|+
mkmkmk13's Avatar
United States, CA, Orange
Joined May 2007
1,605 Posts
jimbob00 great news
i used smartpropplus and ppjoy for years and i knew someone someday will be able to reverse it
cant wait for the windows version!
mkmkmk13 is offline Find More Posts by mkmkmk13
Reply With Quote
Old Mar 10, 2010, 02:27 AM
iPhly R/C with iPhone
iter's Avatar
Silicon Valley, Calif
Joined Jan 2005
1,723 Posts
Thank you for sharing your success and your code.

Quote:
Originally Posted by jimbob00 View Post
Actually, the PPM generated is much higher quality and precise than most of the USB devices you'll find.
I wonder if you can quantify this claim.

A PPM pulse is between 0.5msec and 1.5msec wide: 1msec end-to-end. I notice that your Python code uses a 44100 sampling rate: 44,100 samples per second or 44 samples per millisecond. Your sampling rate limits your resolution to 44 steps per channel. By way of contrast, the USB device you link to advertises 10-bit resolution (1024 steps per channel). 44.1kHz is close to the maximum you can get with standard sound hardware; some cards support 48kHz, not a meaningful improvement.

I went through this exercise 4 years ago after I wrote a Python program to generate PCM modulation for AeroAce: http://www.rcgroups.com/forums/showthread.php?t=508749. The AA modulator worked well. PPM generation ran into hardware framerate limitations.

Ari.
iter is offline Find More Posts by iter
Reply With Quote
Old Mar 10, 2010, 04:24 AM
Registered User
Joined Aug 2009
1,530 Posts
that's why i say "most"
lets say the one i tested wasnt as precise. some could be, but i know of none. you can also have up to 96000 samples per second but its not necessary for regular flying. Most cards are supporting 48 i think. Bad/old cards could be a problem. My code is precise enough at 44100 to produce nearly 0.00001s precision which is just fine At 96000, its producing "real" nearly perfect 0.1ms precision. You'll notice values are sometimes rounded up so its not "100% perfect precision" but you won't notice it while moving the sliders, its still higher resolution than most. (i used 44100 in the sample in case people just try it with cards that don't have high enough resolution since it works fine - even my laptop supports higher)

the big difference with the usb devices, is that they usually have some electronic interface generating an analog signal, which is nowhere near as clean as the audio signal we're sending. Even the signal from your link is much cleaner than the PPM signal the DX7 itself produces.

here is the dx7 signal (its not too bad):


the usb interface i have:

theres no timing but it gives a good idea how clean the signal is (because its what important in fact, see near the bottom of this post)

i'll record the soundcard output a bit later (im at work), via a cheapo AC97 it looks jsut a lil better than the DX7 signal, via hd audio it looks quite clean.

Edit: did not type everything i wanted, kinda had to work so here goes :P

so, at high sampling rate with good audio you get a really nice signal, but of course i wanted, like you, to have PPM over cheapo cards and at 44100. The PPM the program i uploaded produce precise enough PPM in theory, but not as good while going through audio out. This depends a lot on the soundcard. That's why there's a setting to change the audio output power.
I used my laptop because its the "worse" sound card I have. It even have some noise cause it's not shielded properly

So the key to have it working properly (on a soundcard!) is to play with the sound output power. Pretty sure you can get your own program to work that way.

Note that this same problem can occur while using smartpropoplus (reverse way), changing the mic volume/gain can fix the signal.
The easiest is to link your mic to your speakers and watch the signal (try wavesurfer, its more precise than xoscope), so you can watch the resulting signal, play on the gain until the signal looks "better".
When you can't do that, you can just play around until your RC radio recognise the PPM signal (won't be as good but good enough for regular RC flying. For 3D heli pilots, probably they're better off with PCM or direct radio anyway, but that's waaaaaaay beyond the scope of the project, as the radios induce too much latency during the "buddy box" conversion anyway)


I hope that clear it up / helps you
jimbob00 is offline Find More Posts by jimbob00
Last edited by jimbob00; Mar 10, 2010 at 05:16 AM.
Reply With Quote
Old Mar 10, 2010, 01:56 PM
Registered User
Joined Aug 2009
1,530 Posts
haven't took the samples from the python program yet i've been busy looking up stuff
most pcs uses Intel HD Audio audio nowadays
Intel HD Audio audio boards support 192khz 16 and 24Bit audio
so most pc actually support the high precision "mode" (then again it works fine in 44100 for most uses)

Suppose i'll just make the windows program detect that at some point.

see:
http://en.wikipedia.org/wiki/Intel_H...finition_Audio
jimbob00 is offline Find More Posts by jimbob00
Reply With Quote
Old Mar 10, 2010, 02:44 PM
どうもありがとうミスターロボット
Wrend's Avatar
United States, IL
Joined Jul 2009
3,063 Posts
Sounds pretty cool. I have a converter to use either Spektrum or Futaba radios with my controller for the RealFlight G5 R/C simulator. I wonder if that would work with this setup.

Now they just need to make a Futaba FASST 2.4GHz to USB receiver (or the equivalent for other brands), and we'll have computers controlling on-board computers. I guess at that point it might just be better to use 802.11 wireless networking. But, who knows?
Wrend is offline Find More Posts by Wrend
Last edited by Wrend; Mar 10, 2010 at 03:10 PM.
Reply With Quote
Old Mar 10, 2010, 03:46 PM
Registered User
Joined Aug 2009
1,530 Posts
to use your radio as controller for a simulator, its going to the other way around (radio=>pc) this already exists with a pretty good solution: http://www.smartpropoplus.com/dnn/

for RealFlight you need additional software so that RealFlight recognizes your controller, this is not legal in countries with a DMCA or similar law afaik. that's because RF uses the USB converter/controller as dongle and integrate the joystick signal into this. (probably a forced "vendor lock-in" to sell more hardware....)
Look on torrent search sites for it, you'll find it.

the solution above does the opposite anyway, its computer=>radio (so your computer flies the rc thingies, via joystick e.g. or preprogrammed, or whatever u like)
jimbob00 is offline Find More Posts by jimbob00
Reply With Quote
Old Mar 10, 2010, 03:54 PM
iPhly R/C with iPhone
iter's Avatar
Silicon Valley, Calif
Joined Jan 2005
1,723 Posts
Thank you for the Wikipedia link Jim.

I don't recall seeing any of these high-resolution audio devices in the wild. It's possible I've not looked hard enough.

You get 44 steps when you generate your signal. When you sample your input, you by definition get at most half that.

Again, I congratulate you on your success. I encourage you to clarify your goals and acceptance criteria for this project.

Ari
iter is offline Find More Posts by iter
Reply With Quote
Old Mar 10, 2010, 04:26 PM
どうもありがとうミスターロボット
Wrend's Avatar
United States, IL
Joined Jul 2009
3,063 Posts
Quote:
Originally Posted by jimbob00 View Post
...
Sorry, I wasn't very specific.

I was just wondering if the adapter plug from my Futaba transmitter to the proprietary RealFlight controller (which also converts to the headphone style plug for use with other brands of radios) would work to connect the sound output on a sound card to my transmitter. I don't know if it's backwards compatible.

I guess I could try recording the output from my transmitter to a sound file, then playing the sound file back to it.
Wrend is offline Find More Posts by Wrend
Last edited by Wrend; Mar 10, 2010 at 04:52 PM.
Reply With Quote
Old Mar 10, 2010, 06:02 PM
Registered User
Joined Aug 2009
1,530 Posts
Quote:
Originally Posted by iter View Post
Thank you for the Wikipedia link Jim.

I don't recall seeing any of these high-resolution audio devices in the wild. It's possible I've not looked hard enough.

You get 44 steps when you generate your signal. When you sample your input, you by definition get at most half that.

Again, I congratulate you on your success. I encourage you to clarify your goals and acceptance criteria for this project.

Ari
i set my own input at 192 which is quite higher. the demo video is at 44.1 (well, compat)
the HD audio chips were just starting around 2006 i think, now they're getting quite widespread (as much as AC97 was)

however, i do not lose half my samples, where do you get that from?


Quote:
Originally Posted by Wrend View Post
Sorry, I wasn't very specific.

I was just wondering if the adapter plug from my Futaba transmitter to the proprietary RealFlight controller (which also converts to the headphone style plug for use with other brands of radios) would work to connect the sound output on a sound card to my transmitter. I don't know if it's backwards compatible.

I guess I could try recording the output from my transmitter to a sound file, then playing the sound file back to it.
i doubt it can damage the soundcard with that cable but be careful
otherwise it should work
jimbob00 is offline Find More Posts by jimbob00
Reply With Quote
Old Mar 10, 2010, 10:00 PM
iPhly R/C with iPhone
iter's Avatar
Silicon Valley, Calif
Joined Jan 2005
1,723 Posts
Quote:
Originally Posted by jimbob00 View Post
i set my own input at 192 which is quite higher. the demo video is at 44.1 (well, compat)
You can set your stream's sample rate to anything you want and the ALSA driver resamples it to fit the actual rate your audio device supports.

Quote:
Originally Posted by jimbob00 View Post
however, i do not lose half my samples, where do you get that from?k
You don't lose any samples, it's just that you need twice as many samples to reconstruct the signal at any given frequency (resolution). You may wish to look up Nyquist–Shannon sampling theorem.

Ari.
iter is offline Find More Posts by iter
Reply With Quote
Old Mar 11, 2010, 06:15 AM
Registered User
Joined Aug 2009
1,530 Posts
Quote:
Originally Posted by iter View Post
You can set your stream's sample rate to anything you want and the ALSA driver resamples it to fit the actual rate your audio device supports.
erm, intel audio hd (driver) supports 192khz/24bit native. hardware supports 192khz/32bits.
If you didn't read my previous link, read that one then http://developer.intel.com/design/chipsets/hdaudio.htm
this is the most common audio chipset on recent pc. older pcs have AC97.
I'm repeating myself now

192khz already gives nearly twice as many samples than necessary to achieve a resolution which the DX7 cannot actually read, but likely some JR/Futaba would read them.

are you another hardware reseller or smth like that? Declaring that intel hd audio is resampled in software is quite wrong in my world its called FUD :P

Note that the theorem you provide here is different. I will dumb it down a lot:

it is applied when you eg sample analog audio to digital and back to analog.
what happens, is that analog has "infinite" resolution while digital has finite resolution.
This is a problem for e.g. music, as the digital signal will represent the shape from one point to another as a straight line. At this point you're already losing definition. By doubling the sampling rate, you get a more accurate definition, which is close to the original, this is what the theorem states.
If you reproduce the digital to analog again, without doubling the sampling rate, all these "shortcuts" the digital signal takes will be converted back to "wave like" (or "sinus like") and you'll have lost enough definition that the audio won't sound quite the same.

However, we're only generating analog from digital, so we're actually losing definition once. Additionally, we're generating a signal that's going to be digitally interpreted, we actually only need the "front" or "up/down" part of the signal to be at the exact correct position, the rest of the signal can be slightly incorrect, it will no difference.

This will give you a proper, visual idea of what's happening here:

http://www2.egr.uh.edu/~glover/apple.../Sampling.html

set the applet original analog frequency at 100hz
set the sampling at 200hz

you'll be getting approximilatly what happens in our PPM case, except that we're only doing digital to analog (high precision here)

at 44.1khz the signal is more like the one with settings at 100 and 100, slightly better tho (one conversion only) and is enough for the PPM to work reliably at good precision.

Feel free to point me wrong, but at some point you'll just be able to plug it in your PC and check by yourself (granted that I work around window's Xaudio2 limitations, or make something with ASIO drivers instead :P)
jimbob00 is offline Find More Posts by jimbob00
Reply With Quote
Reply


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Help! Pats brakes outer cable needed! elkay31 Motorcycles 35 Mar 04, 2010 07:53 PM
Mini-HowTo Using your computer to make templates for painting flyrcehelis Painting and Finishing Tips 0 Mar 01, 2010 01:16 PM
Help! Control your RC Via your PC dasc Electric Motor Design and Construction 3 Mar 03, 2009 08:40 PM
Discussion RC control via a computer perfectdark111 Power Systems 3 Oct 30, 2007 04:51 PM
Help! T6XAsuper DLG flap control via throttle stick (channel 3) help needed slowracing Radios 1 Jan 09, 2006 11:35 AM