||| ArdSimX Articles/Guides Project Archive SimVim Panel Baron-58 sim Forum

XPData Library for X-Plane data Input/Output ( up to 2015)

CLOSED project, not updated, next ARDref and ArdSim projects was developed as replacement of XPData.

Successor of XPData/ARDref Libraries and ArdSim is ArdSimX Interface

The XPlaneData a Library (later XPDat) project was started (in 2014) to unificate of all our previous X-plane interface code samples.

The XPlaneData library provides network interaction between Arduino and X-Plane and includes functions for easy assignment different types of input, including common buttons, switches, encoders to each Arduino pins and functions for transmission of control data to X-Plane.

You can use library functions to assign specific commands or datarefs for chosen pins as arguments of the control functions in your Arduino code. This makes the Arduino programming for users quite simple - you need to write down specific function (button, switch, encoder, axes, LED output, etc.) and add pin number and dataref/command as arguments.

No other software and plugin is needed! All data is transmitted directly to X-Plane using its built-in UDP protocol.

You can use as many Arduino boards with XPData input library as you need to. All boards should have an Ethernet shield (or module) connected to your LAN.

About X-Plane

All parameters that X-Plane can send using inbuilt UDP protocol you can find in the X-Plane menu "Settings->Data Input & Output. Currently there are 133 groups, each of them may contain up to 8 parameters, in form of 4-byte float numbers.

To find out what parameters each group includes, you can select some groups for output to the Cockpit View when flying. For this check the right box in this group. Using the Datarefs Editor plugin, you can correlate parameters that you want to check with corresponding datarefs.

For example, you need to receive gear positions for your indicators. These parameters are located in data group #67 named "landing gear deployment".
To start sending this group's data over network you need to check the left box in this group. Check the right box to output these parameters to the Cockpit View and watch how they are changing during operations.

svglobe svglobe

Network settings

To receive the values of controlled parameters from X-Plane, you need to tell X-Plane where to send the data ..
You can do this in the "Net Connections -- >> Data" preferences screen:


X-Plane Data format

The size of the UDP packet that X-Plane will send is determined by the number of selected data groups. Each UDP packet transmitted by X-Plane begins with a 5-byte header (DATA<), in decimal code. The next four bytes contain the number of the group from 0 to 133 (actually only the first byte does, as the other 3 are "0"). For example, group #67 - Landing gear deployment ratio.

And the next 32 bytes represent the data of 8 parameters (4 bytes x8 ). Each 4-byte block is a floating point value of one parameter.

HeaderIndex32 bytes of Data - 8 sim parameters in the format of 4-byte floating point numbersIndexNext data

As we can see, often we have to receive many excessive data from X-Plane, when we need only one parameter in given group, but X-Plane can send the whole data group only. XPData library function process incoming UDP packet, find the group number and position index of the chosen parameter.

To read the value of incoming data, for example the "Flaps actual position" (fifth byte in the group #13) using XPData Library call the "ReadData(n, m)" function, where the "n" argument is the group number, and the "m" is the number of the parameter inside the group:

       Flaps = ReadData ( 13, 5 );

Some functions can use data to directly send values on the output devices :
			LEDout (13, 127, 6);   // Control the LED on the pin #13 by data from group #127/6 ("Gear Warning")

© Copyright 2012-2016 - SimVim