|
|
|
Build Log
Blog #10: USB2PPM Interface for controlling a remote device from PC
I created an interface to control a remote device (e.g. a drone) from the PC via a radio link and I call the project USB2PPM.
The USB2PPM circuit gets the signal from PC over USB connection and converts it to Pulse-Position-Modulation (PPM) to be input e.g. over a trainer jack into a remote control transmitter. USB2PPM uses standard trainer port signal. Back in 2003, I did a similar project PC-to-R/C Interface V2.0, but it was much bigger than the current version and used RS-232 serial port that is deprecated today. You will find the project files in my GitHub: https://github.com/rotorman/USB2PPM I created a demo Visual Studio C# program to control the channel values: In my GitHub, you will also find a prebuilt PIC32 firmware HEX (to be loaded, e.g. with Microchip MPLAB X IPE onto the PIC microcontroller) and also a precompiled Windows binary for those who do not care to build from the sources themselves. I used OSHPark for PCB manufacturing, one just uploads the Eagle BRD file and they will take care the rest for just a few dollars. Behind the scenes, USB2PPM circuit connects via USB-port of the PC and communicates over virtual serial port. Where the control input stems, depends only on the software running on the PC that transmits this info to the USB2PPM device. In the C# .NET Visual Studio project, you can add as an input an arbitrary device you can access from Visual Studio, including joysticks, gamepads and so on. You are also not bound to use this software, you could use any other programming or scripting language that has access to serial ports. Especially when using e.g. Linux or Mac, you might not want to use the C# code. It also works for example with DJI Goggles RE (3,5mm audio jack is used for transmitter trainer input) that relays up to 8 servo channels to Ocusync unit in the model. Communication protocol The communication protocol is kept very simple. The connection with USB2PPM is with 115200 baud, 8N1. USB2PPM expects a constant 2 byte header (0xF0 0xC4) followed by eight uint16 (=unsigned integer, 16-bit wide) values, sent MSB first (big-endian). Each of these uint16 values corresponds to a servo channel, starting with servo 1. In the present firmware, the uint16 values code the servo channel pulse width in 200 ns resolution. The minimum accepted value is 1 ms (meaning value 5000 in decimal or 0x1388 in hex) and the maximum accepted value is 2 ms (meaning value 10000 or 0x2710 in hex). Inputs outside the limits are capped to the borders of these limits (e.g., if you accidentally send 15000, the PIC32 firmware limits this input to 10000). The USB2PPM echos the accepted input commands in human readable form (=ASCII) back. There is no need to read, parse or acknowledge this feedback. When sending the servo control telegram, you also do not need to adhere to any timing constraints or intervals when sending the data - after the telegram with new values has been accepted by USB2PPM, it continues to send out servo pulses with the commanded data until a new telegram with updated values is sent to it. Examples: 1) all 8 channels centered (1.5 ms) 0xF0 0xC4 0x1D 0x4C 0x1D 0x4C 0x1D 0x4C 0x1D 0x4C 0x1D 0x4C 0x1D 0x4C 0x1D 0x4C 0x1D 0x4C 2) all 8 channels minimum (1 ms): 0xF0 0xC4 0x13 0x88 0x13 0x88 0x13 0x88 0x13 0x88 0x13 0x88 0x13 0x88 0x13 0x88 0x13 0x88 3) all 8 channels maximum (2 ms): 0xF0 0xC4 0x27 0x10 0x27 0x10 0x27 0x10 0x27 0x10 0x27 0x10 0x27 0x10 0x27 0x10 0x27 0x10 4) channel 7 at 1.7 ms, rest at center: 0xF0 0xC4 0x1D 0x4C 0x1D 0x4C 0x1D 0x4C 0x1D 0x4C 0x1D 0x4C 0x1D 0x4C 0x21 0x34 0x1D 0x4C (1.7 ms in 200 ns steps is 8500 that is in hex 0x2134. The value 8500 stems from equation: Code:
pulse_width / step_size The first 1000 in the multiplication is to get from milliseconds to microseconds and the second multiplication with 1000 to get from microsecons to nanoseconds. You can continue reading how to disable all RF emissions on a DragonLink V3 WiFi+BT ESP32 module in my blog post #11 or return to the index of my blog posts. Appendix References
Repositories used in this post |
|
Last edited by Risto; Apr 02, 2021 at 02:35 PM.
|
|
|
|
|
This is exactly what I was looking for, nice work.
(note: Your forum blog has a lot of good info as well, it lead me to the Mavlink enhanced OpenTX) |
|
Last edited by Sightline_; Mar 29, 2021 at 11:59 AM.
|
|
|
|
As joystick seems to be a desired feature, I just added another C# demo in GitHub that demonstrates the usage of a joystick.
It uses SlimDX package for the joystick that can be added to Visual Studio projects using the Tools -> NuGet Package Manager. Glad to hear you find the information useful. Cheers! |
|
|
|
||
|
Quote:
|
|
|
||
Thread Tools | |
Similar Threads | |||||
Category | Thread | Thread Starter | Forum | Replies | Last Post |
Question | Can’t post video from my phone to my blog | xrx1113 | Site Suggestions / Complaints | 1 | May 22, 2020 06:38 AM |
Video | Bumblebee DLG Overview (for Geode's Blog) | Geode | Sailplane Talk | 0 | Feb 25, 2007 11:22 AM |