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 a 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
  • Leonardo 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 (probably not 412 head as well) 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.

Download

Download simchair_i2c repo from GitHub.

Libraries

At the moment, the master controller sketch uses two libraries:

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

Configuration

The sketch is split into multiple files for better readability and easier navigation. Every peripheral device has its own file, and all stuff you need to calibrate it is in there (if there are any, steps that are needed to be done for calibration are described in peripheral’s assembly manual). When you open one of the files with Arduino firmware, it opens the whole project, and all the files are opened as tabs. When you compile it, these files are concatenated in alphabetical order.

All configurable parameters are under “configuration” tab (a_configuration.ino file), it’s documented right there in comments. ( lines, starting with // )

Extra

To install Lua script that adds collective head switches support key bindings to X-Plane 11 controls menu, please look at this post.

56 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

  2. Hi Alexey – wanted to calibrate the padels following your instructions in master-controler:

    …… uncomment the following line under “g_helicopter_pedals” tab:

    //Serial.println(rudder); //uncomment to calibrate pedals…..

    Doing this nothing happens on serial port. I am not an Arduino specialist, but isn´t there a “Serial.begin(9600);” missing?

    1. Glad to hear that! Serial.begin is actually under the “main” tab, so no magic there =)

      I can think of only 2 possible reasons for it to not work: either smth is wrong with an i2c connection, or with the device address (if you forgot to connect ADDR and SDA pins).

  3. Hello,

    Can you please do an detailed script for dummy’s how to get the Leonardo board switch to a joystick with flashing the board ?

    Thanks

    Iam waiting for my Leonardo board from Ali

    1. Hi! Nothing complex here, just a few steps:

      1) download the Arduino IDE (https://bit.ly/2VkhkSi), install it
      2) download libraries:
      https://github.com/adafruit/Adafruit_ADS1X15
      https://github.com/MHeironimus/ArduinoJoystickLibrary

      unzip them and copy to Arduino/libraries folder (e.g. C:\Program Files (x86)\Arduino\libraries)

      3) download the simchair_i2c repo:
      https://github.com/hc625ma/simchair_i2c
      4) go to the master_controller folder and open one of the files contained there; All these files should open as tabs in Arduino IDE
      5) select “Arduino Leonardo” from board menu
      5) press “Compile” to check if everything’s fine; you can try the process up to this point without having a physical board
      6) press “flash”, connect and try your peripheral (replug the board after you connect stuff to it, as it will only auto-detect what’s connected on startup), make necessary adjustments in configuration.ino file if any (it’s more or less documented right there in the sketch in comments) and reflash the board again. It should be fine by default, but you may want to reverse some axes or change the default force trim behavior, or maybe reconfigure switches for the head.

      Try doing it without the board, if it compiles, it will flash without any issues. Please let me know how it went for you.

      Cheers and happy New Year!

  4. Hi Alexey – wanted to calibrate the cyclic. You wrote in manual:
    // uncomment next 3 lines for cyclic calibration
    // Serial.print(x);
    // Serial.print(” “);
    // Serial.println(y);

    Last line I do not find in “c_flight_stick_gimbal.ino” – I find only “Serial.println(ftcr);”
    Is this a typing error or do I make an error using the wrong master software?

    Guido

  5. Oops, just change ftcr to y =) Force trim center reset button was added very recently, so I guess I changed the value for debugging and forgot to put it back. Btw, it’s quite a useful feature, just need to solder a button between 5v and A2 pins of the ADC to use it.

    1. Hi Greg! There’s the firmware on GitHub: https://github.com/hc625ma/simchair_i2c

      All peripherals except gimbals and pedals have a separate Arduino Pro Mini in them. You have to flash them with a corresponding firmware file from the repo. The master controller uses an Arduino Leonardo, which should be flashed with master controller firmware, that also contains all configurable options in it. Just open any of files under “master controller” directory, all files will be opened as tabs in Arduino IDE. Look at a_configuration.ino and see if you want to change something there, then install needed libraries (see above) and flash the board. Triple check that Leonardo is selected in boards menu!

      Cheers

      1. Thank you I discovered my problem today. I was launching the Game through Steam and I had to go to the game specific settings in steam and force off steam controller mapping. Once I did this everything showed up perfectly. Thanks for everything you do. All I have left is to assemble the pedals and then start testing.

        1. You’re welcome! Glad to hear you’ve sorted it out =)

          I will be releasing a modified rocker part for pedals on this weekend, if you want to use pedals with springs, it’s better to use the new part.

  6. I’m thinking of starting a facebook group for everyone who is actively working on this project or to show/share results – if anyone is interested please follow the link to facebook and connect with me! ( I don’t know where else to post this! But hope we can put together a group with your help!)

  7. Congratulations for this great project. The more visible part of this project is the mechanical and hardware, but you have done a great job with the code too. I think that your idea of a master controller and several devices, all of them interconnected by I2C, is very nice. And finally implement it as joystick is the best way to use the device in a flight simulator.

    I have reviewed the code and I would like to make you some suggestions to improve it. I think that, while maintaining the core code, the design can be improved to gain modularization, maintainability and easy reading. I have experience programming C/C++, Arduino and AVR microcontrollers. There are also some improvements that could be implemented to increase speed and reduce latency (critical for input devices like joysticks).

    That’s why I would like to contact you by email and tell you some ideas more deeply. Can I ask you, please, to contact me by email?

    Thank you again and regards.

  8. Hi Alexey!

    I was just trying out the flight stick, when I noticed the force-trim button is the one next to the thumbstick. I want to change it, so it is the middle button, like it is in the Bell 407.

    I suppose I have to change this line?
    #define PSEUDO_FORCE_TRIM_BUTTON 1

    I tried to set it to button 3, but nothing worked afterwards.

    Thanks!

    1. Nevermind, I got it to work! =)
      Seems like I have to unplug the USB connection and plug it in again to see the changes in joy.cpl !

      1. Oops, sorry, missed your comment somehow! I am happy you have sorted it out =) Let me know if you need help with configuring stuff!

        Its a bit strange though, as technically the board is reset during the flashing process, so should work right after reflash. Then, things sometimes go differently and you may need to replug manually =) Note that you need to replug USB every time new peripherals are connected or changed, except for B8 stick grip.

  9. I have trouble flashing Arduino Pro Mini for AB412 Collective Head Switch Controller. I receive:
    Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: “Arduino Pro or Pro Mini, ATmega328P (5V, 16 MHz)”

    Sketch uses 2954 bytes (9%) of program storage space. Maximum is 30720 bytes.
    Global variables use 367 bytes (17%) of dynamic memory, leaving 1681 bytes for local variables. Maximum is 2048 bytes.
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x16
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x16
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x16
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x16
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x16
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x16
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x16
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x16
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x16
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x16
    Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

    This report would have more information with
    “Show verbose output during compilation”
    option enabled in File -> Preferences.

    I had no trouble uploading code before I unsoldered the LED next to PIN 9.
    https://pasteboard.co/la1jUH4.jpg

    1. The problem is most likely due to the DTR pin is often not connected on Pro Mini’s or cheap USB – UART boards, or both. Just press the reset button manually right after it says

      Sketch uses 2954 bytes (9%) of program storage space. Maximum is 30720 bytes.
      Global variables use 367 bytes (17%) of dynamic memory, leaving 1681 bytes for local variables. Maximum is 2048 bytes.

  10. alexey,
    I am having a lot of fun building simchair, but hit a problem.
    I built the master controller and programmed it with your most recent code. i built the gimbal head for the cyclic and am in the process of orienting the magnets as described in your tutorial.

    trouble is, i can get the gimbal X axis to range from 32780 to zero just fine (full 15 bit range). but the Y axis only varies from about 137 to 140 over a 8 bit range (255) no matter how the magnet is positioned. part swapping and experimenting tells me the problem is not with the gimbal head, adc or hall effect sensors

    unplugging the gimbal completely and letting the master controller run with the serial monitor on shows “4294934528 255”

    do you have any advice for me?
    thank you,
    mike

    1. oh, got it! it was the typo in the serial print line in c_flight-stick_gimbal that Guldo pointed out.

      I am back on track thanks.

      mike

  11. I know about reset button, but it turned out I had some problems on converter Pro Mini connection. I soldered wires between them and uploaded sketch without problems.

  12. Hello.

    How to connect the uart usb convert to the pro mini. I got only a 4 cables and on the uart are 5 Pins to the pro mini
    Uart. Pro mini
    vcc Vcc
    gnd Gnd
    r/d R/d
    txd. Txd
    3/3 Dtr

    Is this right?

    Thanks

  13. I connected the pro mini like described above. But windows don’t identify the pro mini but the uart alone. When I connect the board with the uart the led on the uart is blinking short and went off after 2s. One led on the pro mini is on and another is blinking. I tried to connect another pro mini but same result.
    Any suggestions?
    Thakns

    1. This is all fine, except you have to connect TX of the UART to RX of the Pro Mini and vice versa. DTR pin is a reset pin, if your Arduino board does not have one, no problem, just reset it manually.

      Your PC will only see the board as a COM port. It’s totally fine. Select the Pro Mini from the board type menu in Arduino IDE and press the flash button. When the lines will stop running, briefly press the reset button on the board. After that, you should see 2 progress bars, and voila, it’s flashed!

      The blinking led just shows you a blink example sketch is loaded, so the board itself is working fine =)

  14. Okay

    I don’t understand. I wired the board like you mentioned and Windows now got the uart with the pro mini on port 6. Why flashing the board? I thought I should load the single collective ino to the board. I choose the pro mini board 5v 16Mhz At 328 and the respective comport which I checked in the device manager. Afterwards I hit the arrow button for loading the file. The file were compiled and after I hit the reset button on the pro mini. I got a black message that 9% of the memory were used but no progress bars. How to flash the board – sorry Iam behind the game.

  15. Now I saw that that after the green bar vanished the same message like magma duck wrote is shown. I pressed the resset button but no reaction. How long should I press the button?

    1. You have to press the reset button exactly when orange lines stop running, after a message like this:

      avrdude: Version 6.3, compiled on Dec 16 2016 at 13:33:19
      Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
      Copyright (c) 2007-2014 Joerg Wunsch

      System wide configuration file is “C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf”

      Using Port : COM40
      Using Programmer : arduino
      Overriding Baud Rate : 115200

      The timing is important. If nothing happens, try pressing reset again with some interval between presses (IDE actually does a few retries).

  16. Sketch uses 2954 bytes (9%) of program storage space. Maximum is 30720 bytes.
    Global variables use 367 bytes (17%) of dynamic memory, leaving 1681 bytes for local variables. Maximum is 2048 bytes.
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x16
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x16
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x16
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x16
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x16
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x16
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x16
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x16
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x16
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x16
    Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

    After this I pressed the button

    1. You have to press the button before the first line like this:

      avrdude: stk500_recv(): programmer is not responding

      This means you’re too late!

      Press it after that line:

      Global variables use 367 bytes (17%) of dynamic memory, leaving 1681 bytes for local variables. Maximum is 2048 bytes.

  17. Now it seems to work. How can I check that the sketch is on the board?

    This time I pressed the button before the orange lines and the green bar vanished and only this text is printed.

    Sketch uses 2954 bytes (9%) of program storage space. Maximum is 30720 bytes.
    Global variables use 367 bytes (17%) of dynamic memory, leaving 1681 bytes for local variables. Maximum is 2048 bytes.

    1. It should show 2 orange progress bars. Uncomment Serial.print and Serial.begin calls in the code (remove trailing \\ ), and press the looking glass button in IDE. You should see some output.

  18. Thank you very much for your support and time. I understand now nothing. I’m not new to Arduino and load some stuff on Megas and unos. Iwill give up on that for awhile.
    I don’t see the orange progress bars I didn’t notice these before. I un commented the serial lines and checked the monitor but no sign of any data.

    Thank you very much but Iam frustrated all the which went in to the build and now I am don’t get it running. What a pity

    Kind regards and keep up your work

    1. Hmm please download Anydesk (https://anydesk.com), let’s look at it together =)

      Have you reflashed the firmware after uncommenting the Serial.print calls?

      Also, if nothing helps, you can always use Arduino Nano instead of the Pro Mini for the collective without any issues.

  19. Yes I reflashed the the firmware. After the Easter holiday I would come back to your kind offer with any desk. But now I have only a edge internet connection. 🙏

    1. Okay! If you’re eager to get it running right now, just use a Nano if you’re comfortable with it. Same thing, but with USB. It may be a bit harder to pack it into the collective head, but for the lever itself, should work pretty good!

      Also, are you sure you have an atmega 328 board, not the 168 one?

    1. https://www.youtube.com/watch?v=kecsB87cT74

      This guy here says to press reset as soon as you see the word “uploading…” in the IDE, try it.

      Most likely you’re just pressing it in the wrong time – please look at the video =) Also, try connecting the DTR pins if your USB – UART board has one – it should reset the board automatically.
      Again, please make sure your Rx pin of the Arduino is connected to Tx of the USB- UART and vice versa (not rx to rx and tx to tx)!

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.