Interesting Tech Projects
Open Radio Control
Want to control a radio-controlled aircraft from your own PC software? How about using a Wii Nunchuk to fly a RC aircraft one-handed (great for stroke victims)? Now you can with this open-source project!
Overview
The Open Radio Control system has several components:
- The hardware that sits between your PC and a Wii Nunchuk and an RC aircraft
- A .NET assembly for easy software development
- A PC application for configuration of the hardware
The system may be used in two different ways, as a Nunchuk controller or as a PC to RC aircraft interface.
Some of the features include:
- Stores the configuration of eight aircraft
- Each aircraft can be given a unique name
- Each aircraft can have one to eight channels
- Each channel can have the following settings made: trim, reverse, travel volume
All of these settings are configured using a simple PC application which runs on Windows but should also run on Linux using Mono.
Quick Start
- Purchase a LPC1768 mbed board (see also mbed.org)
- Add an EEPROM, power regulator and connectors as shown in the schematic diagram
- Install the mbed serial driver
- Connect the mbed, copy the desired binary file onto the mbed and reset it. The current versions are:
Nunchuk to Aircraft (should be suitable for Futaba)
Nunchuk to Aircraft with PPM Inverted
PC to Aircraft (should be suitable for Futaba)
PC to Aircraft with PPM Inverted - Run the Open Radio Control software and click on “Read”. Single click on an aircraft to select it. Double-click on an aircraft to configure it.
- If using the Nunchuk option connect the Nunchuk to the board. Warning: make sure to use a genuine Wii Nunchuk, not a cheap clone!
- Connect the board to the trainer port of your RC transmitter. Use the power out from the transmitter to power the board.
- Press and hold the Master button (or equivalent on your RC transmitter to allow the Open Radio Control system to control the RC aircraft.
Note: the PPM waveform generated has been tested with a 6-channel Futaba transmitter.
Flight Simulators
Because the output from the Open Radio Control system is a PPM signal, which is widely used, it is possible to send this to a flight simulator such as FMS. I have tested it using a PIC-based serial cable. Don’t forget to run the calibration process in the flight simulator. I recommend using a flight simulator to practice using the Nunchuk.
Nunchuk Controls
A Wii Nunchuk can control the RC aircraft as follows:
- Joystick up and down is the elevators
- Joystick side to side is the rudder
- Roll the Nunchuk left and right to control the ailerons. Note that there is a large dead-space in the middle of the range to make stopping the roll easy
- Press the Z button (the large button) and move the Nunchuk back towards you or away from you for the throttle
- Pressing the C button (the small button) and performing any of the above operations trims that channel. For example pressing the C button and the joystick left will trim the rudder to the left. Press the C button and the Z button to trim the throttle.
Serial Interface
The Open Radio Control system can be used to control a RC aircraft from a PC. At the lowest level this is a serial interface with ASCII commands. When connected the board appears as a COM port even though USB is being used. Connect at 57600 baud, eight bits, no parity, one stop bit, no flow control. All commands and responses are terminated with a carriage return and a line feed. Each parameter must have exactly one space between them. The command parser is very strict on the input requirements.
Commands are sent and received in ASCII.
All values sent and received are an ASCII representation of decimal integers.
<command> <direction> [<parameter] [<parameter>] … CR+LF
Command is two letters.
Direction is S for set or G for get.
The number of parameters and their contents vary depending on the command.
Commands and responses are terminated with a carriage return and a line feed.
Set commands return “ERROR” or “OK”.
Get commands return a value or “ERROR”.
Invalid parameters return “ERROR” for the command.
Commands don’t return until the operation has completed.
SE S aircraftnum
Select aircraft (1 – 7)
Applied immediately
SE G
Get the currently selected aircraft (1 – 7)
CH S aircraftnum channelnum
Set the number of channels ( 1 – 8 )
Requires a reset to be applied
CH G aircraftnum
Get the number of channels ( 1 – 8 )
NA S aircraftnum name
Set the name of an aircraft (max 31 ASCII characters)
NA G aircraftnum
Get the name of an aircraft (max 31 ASCII characters)
RE S aircraftnum channelnum state
Sets the channel reversing. If state = 1 then reversed, 0 = not reversed
If changing current aircraft then the change is applied immediately
RE G aircraftnum channelnum
Gets the channel reversing. Returns 1 = reversed, 0 = not reversed
TR S aircraftnum channelnum
Sets the channel trim value (-100 – 100)
If changing current aircraft then the change is applied immediately
TR G aircraftnum channelnum
Gets the channel trim value (-100 – 100)
LD S aircraftnum channelnum
Sets the left/down travel volume (10 – 120)
If changing current aircraft then the change is applied immediately
LD G aircraftnum channelnum
Gets the left/down travel volume (10 – 120)
RU S aircraftnum channelnum
Sets the right/up travel volume (10 – 120)
If changing current aircraft then the change is applied immediately
RU G aircraftnum channelnum
Gets the right/up travel volume (10 – 120)
PO S channelnum postion
Sets the channel stick position (-100 – 100)
Applied immediately
PO G channelnum
Gets the channel stick position (-100 – 100)
CA S aircraftnum throttlechannelnum aileronschannelnum rudderchannelnum elevatorschannelnum
Sets the channel assignments for the aircraft
Requires a reset to be applied
CA G aircraftnum
Gets the channel assignments for the aircraft Returned as a space separated list:
throttlechannelnum aileronschannelnum rudderchannelnum elevatorschannelnum
AS S
Apply current settings
Hardware & Firmware Technical Details
Download the firmware source code
The hardware is based around the mbed module from ARM featuring the LPC1768 Cortex-M3 microcontroller from NXP. This is a nice system to use as the device can be connected with USB and appears as a mass storage device plus allows serial communication. To program the board a .bin file is simply copied over and the board reset.
The firmware was developed with the RealView compiler from ARM using Keil uVision4 for the editor. There is an evaluation version limited to 32kb available. This project compiles to 14kb so it should be usable, but I haven’t tried it.
It is possible to port the code to other microcontrollers and compilers and to help the source code is divided into folders. The “startup” folder contains all the files from ARM and NXP that are used to initialize the microcontroller. These can be replaced with alternatives for other microcontrollers. The “hardware” folder contains the microcontroller-specific drivers for I2C, timers, watchdog and PPM signal generation. The .h files are generic but the .c files would need to be re-written for a different microcontroller.
An important aspect of the firmware is the watchdog. If the software crashes for some reason (and hopefully it never will) the microcontroller will reset within 100ms and that should resolve the problem. When this happens the last known throttle position is restored allowing the user to continue flying the aircraft. It’s important that any microcontoller used has a watchdog capability and firmware can detect if the last reset was caused by the watchdog or not.
The firmware has some configuration options and these can be found in the file config.h. Currently the PPM signal can be inverted (required for some transmitters) and the Nunchuk functionality can be enabled or disabled.
The PPM generation is essentially separate from the rest of the firmware. A timer interrupt is used and it is set to the highest priority. An array holds the PPM timing values and this is the only interface to the rest of the firmware. The code was structured this way to try to ensure that no matter what PPM pulse generation continues and won’t be delayed or corrupted by low priority features such as accessing the EEPROM or responding to serial commands.
The PPM waveform has an 18ms period.
Why not use an Arduino? Because I feel that a high performance 32-bit microcontroller with a flexible interrupt controller running at 72MHz and using the RealView compiler would give the best performance, reliability and flexibility. If you want to port this to the Arduino please feel free. 😉
PC Software Technical Details
The PC software is divided into two parts. There is a low level .NET assembly used for communicating with the hardware, and a high level user interface. This allows you to take the .NET assembly and build your own application on top of it, using C#, Java, Visual Basic or even Python.
Both parts were developed using Visual Studio 2010 using C# and a C# Express version is available for free.
Although I haven’t tried it, it should be possible to execute the application and the .NET assembly using Mono on Linux and OS X.
The .NET assembly provides a class called “Interface” which provides low level access to the hardware. The methods generally map one to one with the serial commands listed above. The assembly also provides classes called “Aircraft” and “Channel”. These are at a slightly higher level and allow you to interact with the hardware by creating aircraft and channel objects and reading/writing all the settings in one go from/to the hardware.
Project Future
I developed this project to get my father back into radio controlled flying after he suffered a stroke. He lost the use of one hand so the Wii Nunchuk seemed like the perfect solution. After extensive searching I didn’t find much that I liked in terms of solutions so I developed this solution for him. Now that it is “finished” I am releasing it as open source so that others can use it and adapt it to their needs. Unfortunately I have limited spare time so unless my father encounters bugs or ways of improving the system I won’t be making any changes. This is a “take it or leave it” approach. If you like it and are able to use it then I would love to hear from you. If you want to request changes then please find someone to help you out as I am unable to do that. I used industry-standard tools and technologies, nothing strange.
License
All files except for the ones from NXP are individually licensed using the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Please follow the link for details of what you can and can’t do.
Disclaimer
THIS WORK IS PROVIDED “AS IS”. NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. BRITISHIDEAS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
IF YOU DO NOT AGREE THEN DO NOT USE ANY FILES OR INFORMATION RELATING TO THIS WORK
Comments are closed.
about 8 years ago
I’m trying to get this to run but I think I somehow need to initalize the EEProm. I can get the LED to come on if I put this:
NumberofChannels = 8;
on line 85 of main.c
That will let me run the pc application but I get garbage when I try to access the values for each plane (or sometimes I get Value of ‘-2’ is not valid for ‘SelectedIndex’
Is there a way to force the airplanes to have default values at the beginning?
about 8 years ago
It’s been too long for me to recall, sorry. The EEPROM should be blank if it is new. You could try writing a little piece of code to wipe it – that might help.
about 8 years ago
Ok, I can do that. Is there a part of the code that sets some default values that I can write to the EEProm the first time I run the program?