Software

Simchair MKIII I2C latest software on GitHub

Summary

Simchair MKIII uses the I2C bus for communication between the master controller and peripherals. That means that every controls piece contains a separate Arduino inside. Why is that necessary?

  • we can use device-specific configuration: a lot of nice features are already there
  • we can use external I2C ADCs that provide MUCH more precision
  • we can have more than six analog axes and all the buttons we need
  • we can use filtering when it is necessary without slowing the master controller down
  •  we can extend our controller’s ports more than we’ll ever need
  • unified interface for everything, buttons or axes
  • Leo board allows us to use a nice Joystick library by MHeironimus, which simplifies things like ten times; no more pain with USB descriptors
  • easy flashing; need to change sensitivity setting for an aircraft? turn the AP on and flash the controller in flight!

Arduino Pro mini is used for all peripherals. It doesn’t have a USB port on it, so you will need a USB- UART converter to flash them. Why use a board with no USB?  They are small and cheap, and the converter costs literally nothing. I use a PL2303 based converter:

 

 

 

 

 

You can opt for using another Arduino board, like nano, everywhere except the B8 stick grip at the moment. Basically, all you need to do is flash all the boards with their corresponding software and wire everything as written in manuals of the peripherals. Note that the master controller software is frequently updated, so remember to check GitHub for updates. Software for peripherals is only updated when there are some severe bugs in it, or some major upgrade is needed to adopt new functionality (I understand no one wants to disassemble stuff to upgrade it). With this in mind, you will only need to change something in peripherals’ software if you wired stuff differently.

Libraries

At the moment, master controller sketch uses two libraries:

You will need to install them to your IDE to compile the software.

Configuration

All adjustments are made in the master controller sketch in the <CONFIGURATION> section. Let us look at it.

//<CONFIGURATION>
//———————————————————————————————

#define B8_POT_MODE “HAT_SW” // HAT_SW or ANALOG

#define SENS_ADJ_METHOD “LINEAR”

#define ADS1115_RESOLUTION 15 //bits, min 12, max 15

// use a button on cyclic to switch sensitivity in flight.
// this kind of functionality is not available in a real aircraft, however
// it may somewhat resemble simulated force trim.

#define SENS_DEVICE “b8_stick”
#define SENS_SWITCH_ENABLED 1
#define SENS_SWITCH_BUTTON 0 //0 is the first button

// sens. switch behavior available options: “FORCE_TRIM” or “TOGGLE”
// FORCE_TRIM will reduce sensitivity to CYCLIC_SENS and RUDDER_SENS
// while SENSITIVITY_SWITCH_BUTTON is pressed, “TOGGLE” will act
// as a regular switch

#define SENS_SWITCH_MODE “TOGGLE”

// if SENS_SWITCH is disabled, these values will be used;
// set to 100 for full axis range
#define CUSTOM_CYCLIC_SENS 80
#define CUSTOM_RUDDER_SENS 80

#define XY_FILTERING_ENABLED 0
#define RUDDER_FILTERING_ENABLED 0

#define PTT_KEYBOARD_PRESS 0 // set to 1 to enable keyboard combination press instead of a joystick button
#define PTT_BUTTON 4 //1st button is 0, 4 should be PTT trigger position

// this should press CTRL + Q
#define PTT_KEYBOARD_KEY ‘q’
char PTT_KEYBOARD_KEY_MOD = KEY_LEFT_CTRL;
//———————————————————————————————
//</CONFIGURATION>

Now lets see what every option is for.

B8_POT_MODE – can be “HAT_SW” or “ANALOG” – hat switch (default) or 2 8-bit  axes on the thumbstick.

SENS_ADJ_METHOD “LINEAR” – sensitivity adjustment method, linear is the only option for now.

ADS1115_RESOLUTION – choose to your liking from 12 to 15 bits. Larger values may introduce a bit of jitter; it wouldn’t affect the controls most likely though.

SENS_DEVICE – which device to use for sensitivity switching.

SENS_SWITCH_ENABLED – enable or disable sensitivity switching. If disabled, CUSTOM_SENS values will be used.

SENS_SWITCH_BUTTON – which button to use as a SENS_SWITCH, starting from 0.

SENS_SWITCH_MODE – “FORCE_TRIM” or “TOGGLE”. FORCE_TRIM mode will increase the resolution while holding the force trim button on the stick (it will be removed from the joystick). This allows emulating pilot actions when hovering with force trim on. TOGGLE mode will simply switch between sensitivity settings on button press.

CUSTOM_(CYCLIC/RUDDER)_SENS – map full ADC range to a reduced number of axis points. Will increase precision, but limit an axis travel with the given value. It depends on the stick length and how the sim handles sensitivity settings. 80 is a good place to start.

(XY/RUDDER)_FILTERING_ENABLED – enable or disable filtering. The default setting is off, turn it on if you feel jitter in your controls affects flying. Will introduce a slight input lag. Try reducing ADS1115_RESOLUTION at first.

PTT_KEYBOARD_PRESS – have the PTT button send a keyboard combination instead of a joystick button press. Useful if you need, e.g., Teamspeak for your comms.

PTT_BUTTON – which button is the PTT switch, a default for the B8 stick is 4

PTT_KEYBOARD_KEY – which key to send, the default is ‘q’.

PTT_KEYBOARD_KEY_MOD – which modifier key to use with PTT keyboard key, the default is ‘Ctrl’.

 
Simchair MKIII I2C latest software on GitHub

6 Replies to “Software”

  1. Hi Alexey – have an understanding problem with master controller software as it is split into several *.ino files numbered with a to z. What do I have to do to get one sketch to transfer to the Leonardo?

    1. Hi Guido! Just open any of them. Arduino IDE will load all of them (as tabs) and merge into a single file (in alphabetical order, that’s why the letters are there) during compilation. The whole thing with splitting the config to multiple files is just for a better readability (there’s a quite lot of code now). Do not forget to install joystick library (https://github.com/MHeironimus/ArduinoJoystickLibrary) and ADS1x15 library (https://github.com/adafruit/Adafruit_ADS1X15).

      An important thing is to select Leonardo in boards menu and choose the right COM port. After that, just press “flash” button.

      It will show up as 3 joysticks, the gimbal will work as X and Y axes of the 1st one =)

      1. Hi Alexey! To get the tabs in Arduino IDE it was necessary for me to download all files into one directory. In my case I named the directory into “master_controller” and opened the same ino file. Is this the right approach? I get then a lot of error messages, unfortunately too many to send here in the comment. I use Arduino IDE 1.8.7. Possible to send to you by PN?
        When I downloaded only one ino as you wrote above the lines of the other inos are loaded but not seperately in tabs. Error messages are then the same when conmpiling. I am lost now!

        Guido

        1. Oops, I thought you have downloaded the whole git repo (actually, the best thing to do).

          Yup, you need all files from master_controller directory (https://github.com/hc625ma/simchair_i2c/tree/master/master_controller) to be in one dir together. Then you open any one of them, and IDE will load them all as tabs. You need to install joystick and ADS1x15 (links above) libraries before compilation (download them, unzip and copy their folders to your Arduino/libraries folder, look at “Manual installation” part of this manual if unfamiliar with this process: https://www.arduino.cc/en/Guide/Libraries)

          What do you mean by PN? You can write to me by email (my username at gmail.com), but it’s better here in comments so other guys who may have similar questions could find an answer easier =)

          Cheers!

          1. Hi Alexey – with downloading the complete git repo it works – was not clear for me in the beginning.
            Many thanks!

            Guido

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.