Howto:Use Arduino with FlightGear

Revision as of 20:12, 19 April 2013 by Rubdos (talk | contribs) (Display/Generic protocol Example by rubdos)
Arduino LCD panel displaying speed, heading and altitude.

Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. FlightGear's IO interface allows easy development of hardware that can improve the immersion and realism of the simulation. The output protocols allow hardware to response to simulation data (like shown in the image on the right), while the input protocol allows FlightGear to reply to hardware events (eg. on the press of a button).

Display/Generic protocol Example by rubdos

Rubdos (Ruben De Smet) has built an example using the Generic Protocol and an Arduino Mega 2560. The code used to control the Arduino with generic protocol was:

<?xml version="1.0"?>
<PropertyList>
   <generic>
       <output>
           <binary_mode>false</binary_mode>
           <line_separator>newline</line_separator>
           <var_separator>newline</var_separator>
           <preamble></preamble>
           <postamble></postamble>
           <chunk>
               <name>Altitude</name>
               <node>/position/altitude-ft</node>
               <type>integer</type>
               <format>altitude=%i</format>
           </chunk>
           <chunk>
               <name>RPM</name>
               <node>/engines/engine/rpm</node>
               <type>integer</type>
               <format>rpm=%i</format>
           </chunk>
       </output>
   </generic>
</PropertyList>

It is a simple plaintext protocol, which can easily be parsed by an Arduino. The code used on the Arduino is available on github as a gist: [1]

As hardware, five seven segment displays were used, multiplexed straight on the Arduino device. In production, you'd rather use some 74HC595 or other shift register chips to drive them, to unload the Arduino and have more current. A demo is uploaded to youtube, with voiceover in which the display shows the RPM of the first engine of (the single engine) DR400: [2]

Related content

External links