An advanced flight control pad made with an atmega32u4 pro micro (leonardo architecture)
This idea is the evolution of the first FlyBox a pad to be used with a joystick to control all the operation with the hand free from the axis flight controls. FlyBox2 bring the basic idea to a new level. To keep low prices is possible to use two Arduino and a multiplexer to have multiple interrupt pins for encoders and many push button. The main Arduino will collect signal from the other and will send to the PC using the HID driver.
For better performance remember to use interrupt pins for encoder.
Interrupt pins are 0,1,2,3,7.
VS Studio Visual Studio Code
I build a small module to fit the MC14490P a debouncer signal chip. The delay can be changed by changing the cap impedance. Bigger value = bigger delay. The hardware approach help the software debounce, anyway is just an optional.
You can find the board ready to print on OSHPark
Unfortunately the Pro Micro has only 5 interrupt (pins: 0,1,2,3,7). If we wire the encoder output pins to not-external interrupt pins of Arduino, the encoder will become very imprecise showing movement in the both directions during one side turn of the knob. This happen because classic pins can be read every loop, instead an external interrupt is catch immediately, so we can say like is "over the loop". Every encoder need 2 interrupts so we do not have enough pins available for 3 or more knobs.
To solve this issue I decide to build an additional module to attach to this board: The FlyBox2_encoder_module
The multiplexer give the possibility, as the name say, to have many output from few inputs. This can be done by using a reading input pin and a function that connect all the multiplexed pin to this input one by one. The switch is done by using a truth table.
One easier solution should be using a button matrix having less pins but in this case I cannot press multiple button at the same time.
- 1x Arduino pro micro atmega32u4 (native USB port not like Arduino nano)
- 3x 10k slide potentiometers
- 3x rotary encoders
- 1x CD74HC4067 16-Channel Analog Digital Multiplexers
- 1x MC14490P hardware debouncer
- 1x 10nf capacitor(change capacitor change delay)
- 16X push buttons
Here you can find the documentations written in Doxygen
- upload the code of Flybox2 to the main arduino
- unplug the usb from this arduino and plug to the second one
- upload the code of the Flybox2_encoder_module to the second arduino
- unplug usb and plug again to the first one to play
NOTE: DO NOT PLUG TWO USB AT THE SAME TIME. 5V+ AND GND ARE IN COMMON ON BOTH ARDUINO ALTHOUGH NOTHING BAD SHOULD HAPPEN IS NOT RECOMMENDED TO HAVE TWO POWER SOURCES.
For people who like Intellj CLion IDE
- install PlatformIO plug in
- search
Cmake
inSettings
and click+
button to addDebug
,leonardo
andDefault
- install python3
- autogenerate
CmakeList.txt
if not present - add PlatformIO configuration on the top dropdown list (build/play section)
- remove build execution from the configuration list of this new configuration
- play the configuration with leonardo selected
PlatformIO Upload|leonardo
some links:
Some sim like DCS are more sensible to potentiometer flickering. As you may notice classic hobbyist use pot slide and not, due to their cheap building are not keeping constant resistance in some position. You will see the throttle of your plane vibrate and changing speed. This problem can be solved by adding a capacitor (same concept as button debouncing) or via software. Speaking about the software way, I found a solution online that involve a moving average algorithm. Even though look like very professional, I thought something much more simple. my code has a
- pot map function (from Arduino library)
- joystick function top set the axis scale (from Joystick.h)
With the first I can map the slider following the arduino library suggestions and with the second I can choose how many axis positions the joystick can take (read by the operating system). If I map a bigger range of int numbers in one smaller I will have multiple numbers in input assigned to the same number in output. This magically will remove the vibration!.... so much math saved :)
In Altium design folder you can find the design for
- FlyBox2 Main Board
- 16 Push Button Pad
- Breakout module for encoders
- Breakout module for potentiometer
- Debounce signal module
Gerbers file are generated by .OutJob file. This file need to be configured in different why depending by the format accepted by the printer service. Altium using the job file is able to generate the gerber file in the specified folder. You need just to zip the output in a single file and upload it on your favorite printing web site service.
I tried
OSH Park unfortunately seem to be the most problematic accepting files. Is possible you need to customize the .zip file. The others are fine.
Always write directly to the customer service to check if the design is fine before ordering. Every service interpret gerber files in different ways.
I tried to design the box using cardboard and unfortunately the result wasn't so good. I made the template using Adobe Illustrator because is able to manage svg files. Here you can find the project.
Looking for a better solution, I made a box using Fusion 360 here.
Now is the time for printing and if you live in Poland you can look at this site. I still have to try them but price are amazing!
- video on youtube (to show how much I'm cool 😎)
- improve encoder functionality (when it turn fast is recognize as single click)
- refurbish the design using a Teensy (it has multiple interrupt pins and bigger frequency)
- try using a fpga board (push buttons operation and encoding can be hardwired to save CPU)