Home Input/Output Guide SimVim Panel Baron-58 Sim Tech Tips/Manuals Forum

ArdSim Interface for home cockpit builders


Here is the latest current supported version of ArdSim LAN/USB Interface (the predecessor of new ArdSimX interface that has a completely different method of input/output configuration, without additional functions in Arduino code using).

ArdSim is easy to use and requires minimum Arduino coding skills. You can configure any Arduino pin as input control linking it with specific X-Plane command or dataref to send data, or for use it as output getting dataref values through ArdSim plugin.

To configure ArdSim input controls for X-Plane or get data from X-Plane for outputs ArdSim library has a set of functions that you can use to setup some controls or to assign specific action (switch, encoder, LED etc.) for any Arduino pin.

With one Mega board you can have 40-70 digital input controls (buttons, switches, encoders). To extend number of inputs several Arduino boards can be used in your system. Also, the number of inputs for one Arduino can be extended using a "key-matrix" for switches.

ArdSim plugin automatically connects all Arduino boards with X-Plane, and then it uses a simple input/output configuration files to control data exchange between them. Each connected Arduino board can have at least one config file (input, output or both). To create configuration files you can use online configurators for inputs and outputs (or edit them manually).



Download: Universal single LAN/USB interface
- v5.1 - Reduced memory usage for smaller boards (such as Nano) allowing them to work correctly with ENC28J60 module. Fixed the static reading mode of ReadInput() function.
- v5.0 - #include ArdSim.h is replaced by #include ArdSim_Interface.h (see comments here)
- v4.9 - Added support of "Counter Button" for any pins number.


... all previous versions changelog

ArdSim 4.x changes:

ArdSim library v4.xx is the same as v3.xx concerning its functionality.
  • The main difference in ArdSim Library v4.xx is that it's now a single, universal library for LAN and USB communication (previous 3.xx versions had two separate libraries for LAN and USB).
  • Either LAN or USB communication can be easily selected for any single Arduino by changing one line in your Arduino sketch.
  • The usage of "BOARD_TYPE" is eliminated, now you only need to set the board number, the type of Arduino is detected automatically.
  • The set of funtions is the same as in the ArdSim ver. 3.xx, excluding some deprecated ones and initial "ArdSimStart" function. You can use your config files without changes, but since the base code for Arduino is different, you need to change all ArdSim headers in your sketches.

ArdSim features:

  • Most of the configuration is done with input/output config files located in the plugin folder.
  • You don't need to write custom Arduino code for most input (and some output) controls, as you can use simple functions provided by ArdSim library for them.
  • As an option, you can extend the number of inputs for one Arduino using "matrix" connection.
  • Up to 9 different boards can be used for one system, with LAN and USB in any combination..
  • Each board may have additional "slave" boards connected to it with I2C and used as OUTPUT extentions.
  • Up to 25 rotary encoders can be used on one Arduino.
  • You can configure Analog input precision (sensitivity) and input range.
  • Analog input, in addition to its standard functionality, can be used as a digital multi-position switch.
  • The library includes some output functions for direct LEDs, analog Gauge, Servo, Stepper control (with pre-assigned datarefs).
  • Otherwise, you can get any dataref value from X-Plane and use it in your specific program code for output (with additional external libraries)



Connection

ArdSim plugin since v2.0 supports both LAN and USB connection and it scans all USB ports ( if USB connection is enabled in ArdSim menu) along with LAN addresses, to find all Arduino boards connected to LAN (and/or USB).

LAN connection

This is a stable and fast interface that requires no network configuration if you have a router with DHCP in your LAN. Just connect Arduino with Ethernet shield to any free socket in your router. You don't need to define IP address for Arduino manually, becase your router will assign it and the plugin will determine it automatically. In case of direct connection without router (Arduino-to-PC with a cross-link cable) you may need to assign an IP Address in the sketch.


USB connection

With ArdSimUSB you don't need to have Ethernet Shield for Arduino and network connections. Take care about each Arduino board powering and USB cable quality. It's desirable to use an external power supply, especially when several boards are connected.

You can combine both connection methods and connect up to 9 Arduino boards with ArdSim library to an X-Plane PC using a router and additional LAN switches or/and USB sockets.





Getting started


Take one Arduino board, (and EthernetShield for network connection if LAN is used), a switch button to test digital inputs, install ArdSim library and X-Plane ArdSim Plugin.

For LAN connection you can use Ethernet Shield W5100 (or its small W5100 module version) or ENC28J60 Ethernet module. Attach Ethernet Shield/Module to your Arduino, connect your Arduino to USB port for uplading code (and for powering if no external power is used), and connect the Ethernet Shield/Module to your LAN with ethernet cable.

For USB communication just connect your Arduino to USB port of the main X-Plane PC.


Testing the communication for ArdSim Library

  1. Connect switch to the pin #5 of your Arduino. Use input config file "in_1.cfg" and output file "out_1.cfg"
  2. In X-Plane open ArdSimX plugin "Status" screen and disable USB (checkbox) before uploading library to Arduino.
  3. In Arduino IDE open the "base" sketch (in the menu "File -> Examples -> ArdSim_Interface -> ArdSim_BASE")
  4. Select a method of connection (LAN/USB):
    • - for version >4.1 just comment or uncomment the line with #include <Ethernet.h>
    • - for version 4.02 use either the LAN or USB keyword after the ArdSimConnect function.
    • - for earlier versions 3.xx - use separate Libraries
  5. Upload code to Arduino (first, chose a correct model of Arduino board in IDE menu!).
  6. If USB is used enable USB in the plugin's "Status" screen. Otherwise the plugin will not scan USB ports.
  7. You will see connection status and a rotating bar during the search process (the plugin scans the IPs or USB ports if enabled).
  8. When Arduino responds and configured you should see the message "Connected to" and the list of Arduino boards.
    (including the number of inputs/outputs configured for each board numuber).
  9. On connection you can see a quick change of input numbers in the line "Last message received from..." while Arduino sends its initial state to the plugin.
  10. When you press a button (or throw a switch) connected to pin #5 you should see a message from this Arduino #1 in the status screen: D5+ (D5- when you release the button).
  11. Also, you should see how the Pitot switch toggles in X-Plane panel and the on-board LED of your Arduino switches ON/off.
  12. In this screenshots you can see the board with LAN connection only and two boards connected with USB and LAN:

    On this screenshot you can see two boards connected with USB and LAN:

    Note: If an Arduino board configured for USB communication has been physically connected to USB port while X-Plane was already running,
    you need to use "Plugins---> ArdSimX---> Reconnect", to find newly connected USB.

    Please note: having USB enabled in ArdSimX can prevent you from uploading a program to your Arduino. To upload code without exiting X-Plane, disable USB in ArdSimX "Status" window. After uploading the code to Arduino, you can enable USB again.


When you've made sure that your ArdSimX is working with your Arduino, you can start configuring it for your own inputs and outputs.


Reconnection:
  • When you reset Arduino (or upload new code) the library function sends the initial sequence (in response to the plugin's regular ping) and the plugin renews the current state of controls.
  • When you restart the plugin it reconnects to all the Arduinos and receives the current state of controls.
  • If you have changed config file when X-Plane is running you should reconnect the plugin (X-Plane Menu --> Plugins --> ArdSim --> "Reconnect") to read the new config.


If you see "Connection status - Awaiting connection" message and a rotating bar in the ArdSim Status window for a too long time (more than 30 sec) try to make "Reconnect" in the ArdSim plugin menu and wait for connection or reset Arduino with "reset" button and wait for connection.

If the plugin still didn't find your Arduino board, see troubleshooting below.



Troubleshooting


1. For LAN:

  • Check your LAN connections (if you're using direct connection without a router, make sure you're using a cross-link cable).
  • Check your firewall settings to make sure the communication isn't being blocked (see port 5080) or admin settings and access rights.
  • By default, ArdSim library works with the "classic" Ethernet Shield based on the W5100 chip. If you have other Ethernet modules, please follow the instructions as described here.
  • If your computer has more than 1 active network connections (uses more than one net-card), make sure Arduino is connected to the same network that the plugin detects. Open ArdSim "Status" screen (X-Plane menu --> Plugins --> ArdSim --> "Status" ) where you can see the current connection status and IP address of your X-Plane PC.
  • If your Ethernet shield has a sticker with MAC address, use it adding the line in the setup section of your Arduino code:
    MAC_ADDR ( 0xXX, 0xXX, 0xXX, 0xXX, 0xXX, 0xXX )   // -- where 0xXX is the number as 0xDE etc.
    
    If it is not labeled, just use the code as is, ArdSim will assign a unique MAC address for each board.
IP adresses setting

By default you don't need to know and set your X-Plane PC IP-address, ArdSim should correctly detect both X-Plane PC and your Arduino IP adresses..

If you still have some problems with auto-connection you can try to define your Arduino IP and/or X-Plane IP addresses (one of them or both can be defined at your choice). Add a line or two lines in the setup section of your sketch:

ARDUINO_IP  (192,168,0,3);          // -- IP of this Arduino ( Just use any free IP address in the network segment by your choice)

XPLANE_IP   (192,168,0,104);         // -- X-Plane PC IP that you should know ( see in the ArdSim "Status" screen the current IP address of your PC).

The numbers above are given for exmple, write your oun correct adresses.

Note: In case if you want to assign the X-Plane IP in Arduino code, your X-Plane computer IP has to be preferable set as fixed/static. If your router is set to define address for your PC with DHCP you can see that last (4th) number of your IP address can be changed occasionally, depending on the number of computers and other devices connected to this network. Thus, if you want the other devices on the network can reliably send data to your PC, use fixed IP address rather than deal with IP that can change every few days. ( How to set fixed IP for your X-Plane PC )


2. For USB:

  • The length and quality of USB cables can be a problem for fast data transfer to and work with one devices but don't work with another sometimes.
  • Also, on some machine or a laptop, the power it supplies to USB ports may not be enough if you use USB as power supply for Arduino (especially if you have some output devices connected to your board). Try to use external power supply.
  • Make sure you don't have another copy of (previous) ArdSim plugin in your X-Plane.
  • Make sure you don't use "Serial.begin(xxxx)" function in the sketch (you don't need to start this function, it's already present in the ArdSimUSB library and the Serial protocol is used for communication with plugin).
  • In your Arduino IDE, check the name of the port your Arduino uses. ArdSim for Mac supports port names starting with "/dev/tty.usb..." and "/dev/tty.wchusb...", for Linux supports port names starting with "/dev/ttyUSB" or "/dev/ttyACM". ArdSim for Windows checks ports from COM1 to COM64. If your Arduino is using a different port name, please contact us and tell us the port name so we can make the appropriate changes in the plugin.
About Serial Monitor using

If you need to use "Serial.print" for debugging, you should be advised that it may cause errors, due to the ArdSim uses Serial to communicate with plugin. To use it, first set rate of serial communication to 115200 baud in your Arduino Serial Monitor screen and use the code below for monitoring instead of simple Serial.print():


if  (millis() - t > 100 )   {   Serial.println( ... );    t = millis();   }
thus serial output will not be executed in every program loop - you will see the difference, comfortable output with a frequency of 10 times per second instead of thousands. ( First assign the variable "unsigned long t; " in the head ).

Also, you can use LAN connection when you need to debug your code with serial monitor. After that detach Ethernet shield and use USB.




© Copyright 2012-2016 - SimVim Design