After a couple of months with hardly any time to work on my personal projects, it feels great to be developing again! This is a screenshot of XPDisplay, showing the new airport information display on the map tab:

The airport information is read from the same apt.dat file that XPlane uses, so everything is kept nice and consistent.

The scenery covers most of the main objects on the airfield, although there is always room for improvement (in particular the main hangar needs remodelling from scratch). Bengeo water tower is included, as it is a prominent local feature that pilots sometimes use for navigation.

This is a little project that I’ve been working on over the last month or so. (I completed it several weeks back, but I’ve been having too much fun with it to write up this blog post) It is a physical control panel for the XPlane flight simulator – i.e. when I move a slider (in the real world), the flaps begin to deploy (in the simulator). I flick another switch, some lights start to flash (in the real world) and in the simulator the landing gear start to rumble their way down into place. What the switches/sliders do is arbitrary – they can be reprogrammed whenever I feel like it.

There are three components: 1) the x-plane simulator 2) the physical box itself, with switches and LEDs wired to inputs/outputs on an Arduino Uno 3) some software running on the PC, which talks to the Arduino (over serial / USB) and to the simulator (sending and receiving UDP packets).

Building the box

The box is made from offcuts of MDF (about 3mm thick), laboriously measured, cut with a saw and drilled with a Dremel. (To cut the slots, I drilled lots of holes in a row and used the Dremel’s circular saw attachment).

The sides of the box were epoxied together (with a little help from some scrap blocks of wood in the corners) so that the back section could be removed, and the gaps filled with ordinary DIY filler. I sanded the whole thing and painted it with a clear primer (to stop the MDF from soaking up the paint and getting a bit soggy) then painted with two coats of a satin black paint (in hindsight, I wish I’d used matt rather than satin as it shows up the imperfections more than I’d like). The labels were printed on my ordinary inkjet printer, white text on a black background & attached with a little spot of glue so that I can rip them off and attach new labels if I reprogram the switches to do something different.

Electronics

The panel has six switches, two linear potentiometers (I accidentally ordered audio ones, which are logarithmic, and had to work around this in the Arduino sketch code to convert to near-linear values), three 5mm red LEDs and three 5mm green LEDs (plus a resistor for each set of LEDs). Inside the box there is an Arduino Uno, a breadboard and quite a few jumper wires.

The USB port of the Arduino sticks out through a square hold in the side of the box. The Arduino is screwed to some chipboard (with some bubblewrap between the PCB and the wood, just to cushion the circuit a little.

The inside is rather messy. With hindsight I would’ve spent longer finding a way to make this a lot tidier and probably not needed the breadboard. In most cases, I ended up snipping a jumper wire in half, soldering one end to a component and pressing the pointy end into the breadboard.

I didn’t use all the ports on the Arduino Uno – if I made a version 2, I could probably have 6 more lights or switches and 4 more sliders, or possibly include a buzzer to serve as stall / warning indicator.

Arduino sketch code

This is the Arduino sketch that is currently running inside the control panel. In a nutshell, in a loop, it checks the state of each switch and writes a string to the serial port (really it’s serial over USB), which looks something like this:

A^ Bv Cv Dv Ev F^ P1022 Q1019

This indicates that switch A is up, B is down, etc. P and Q are the values of the sliders (from 0 to 1023).

The code also reads from the serial port to receive one of the letters U, D, R, F or N to indicate the current state of the landing gear in the simulator (Up, Down, Rising, Falling or No idea!). If the gear is up, the red LEDs go on, if the gear is down, the green LEDs go on. If it’s rising, the red LEDs are flashed, falling = green LEDs are flashed.

Note the logToLin function which I needed because I’d accidentally ordered logarithmic scale potentiometers rather than linear ones. The magic numbers you see in that function came from experimentation.

I found the Arduino serial monitor very helpful to watch what the box was sending over the serial port.

PC software

The code to send/receive UDP packets to/from XPlane is written in Java and based on XPDisplay but using the RXTX library for serial port communication. If I’m honest it’s a bit of a shambles at the moment and I’m hoping to rewrite it, so samples are available on request.

Conclusions

All in all, this was an easy project to pick up for an hour, do a little bit, then put down again (which is important when you’ve got young kids). Although it’s definitely amateurish, the end result is better than I hoped for at the beginning, and as this was my first arduino project it was very much a case of discovering the right way to do things as I went along.

The total cost of materials & electronics was about £30 (from RS, Farnell, Oomlout):