Jump to content

Recommended Posts

Posted (edited)

I loooove flying the Northrop F-5E in DCS. 😊

As I am purely in VR, input of controls with my mouse is often too slow and clumsy. While using the MOZA MTP throttle and MTLP panel with a Rhino FFB base and WinWing ViperAce stick I found that I still lack certain controls to enjoy flying and fighting in the F-5. Looking around I found nothing really satisfying to solve my problem.

Finally, I decided to find a solution on my own.

The plan:

Build a button box for

·       TACAN modes, tens, ones, X/Y

·       UHF modes, presets

·       HSI input HDG & CRS

·       Stations select 7 stations

·       Interval setting 3 positions

·       Bomb fuse 3 positions

·       Weapon mode selector

·       GUN on and off

My take on this was to use

·       TACAN:           one 5-position selector, two rotary encoder

·       UHF:                two rotary encoders

·       HSI:                 two rotary encoders

·       Stations:         seven ON/OFF rocker switches

·       Interval:          one ON/OFF/ON rocker switch

·       Fuse:               one ON/OFF/ON rocker switch

·       WP mode        one rotary encoder

·       GUN:               one ON/OFF rocker switch

Two Arduino Leonardo controllers to emulate two USB game controllers for Windows.

 

Overall split across 2x Arduino Leonardo

So that all inputs fit comfortably on the pins (and you avoid serial conflicts), I choose this distribution:

Leonardo A (Hardy’s F-5E ButtonBox A):

5 rotary encoders with pushbutton 5×(A/B) = 10 lines + 5×Push = 5 lines 15 pins.

1× 5-position selector switch, 1 analog pin (via resistor network)

 

Leonardo B (Hardy’s F-5E ButtonBox B):

2 rotary encoders with push, 6 pins

8× ON-OFF rocker, 8 pins

2× ON-OFF-ON rocker, 4 pins

 

 

The Box

The box needed to be printed on my Anycubic Kobra 2PRO and Photon Mono 2.

So, I drafted the Box and panels with fusion, to export stl files and slice them.

Box1.png

Box2.png

My filament printer caused some heat deformation of the box and the base plate. Therefore, I had to split the large bodies to obtain separate STL files for four bodies of the base plate and two bodies of the box. The plates were also split, with the lower part printed using the FDM process and the upper part printed using the resin process for better resolution. The parts were glued together.

 

Panel one:
bomb interval, fuse setting, external stores rotary switch, gun/cam switch with cover

armament.png

Panel two:
armament position selector switches

Stations.png

Panel three:
HSI heading and CRS, AN/ARC-164 UHF mode and frequency mode

HSIUHF.png

 

Panel four:
TACAN tens, ones, X/Y, modes

image.png

 

Wiring

General wiring diagram (for all buttons/switches)

One side of each switch to GND,

the other side to an input with INPUT_PULLUP. Logic: LOW = active, HIGH = inactive.

 

Also connected encoder A/B to GND (A and B each to inputs with INPUT_PULLUP), common ground of the encoder to GND.

 

Ground routing: one clean star ground (GND bus) per board.

No need to ground the two boards together - both have a common ground via USB anyway.

 

5-position selector switch as analog value. Instead of 5 individual inputs, I used a single analog pin with resistors:

Connect the analog pin with a 10 kΩ pull-down to GND.

The common contact of the 5-position switch goes to +5 V via one position resistor each to analog pin. Resistors (R+5 V): 1 kΩ, 2.2 kΩ, 3.9 kΩ, 6.8 kΩ, 12 kΩ.

Each position contact then supplies a unique voltage at A0 (the sketch assigns the ADC values to 5 “bands”).

 

Pinout & Button Mapping

Arduino Leonardo A

Encoders 1-5

Encoder

Pin A

Pin B

Push

Button

Enc1

D2

D3

D4

1 (+), 2 (), 3 (Push)

Enc2

D5

D6

D7

4 (+), 5 (), 6 (Push)

Enc3

D8

D9

D10

7 (+), 8 (), 9 (Push)

Enc4

D11

D12

D13

10 (+), 11 (), 12 (Push)

Enc5

A2

A3

A1

13 (+), 14 (), 15 (Push)

 

5-position Analog Selector

Function

Pin

Button

5-position analog selector

A0 (resistor ladder, 10k pulldown)

19–23 (one held active)

Notes: Button numbers are 1-based (human-friendly); HID reports them 0-based internally. Buttons 16–18 are intentionally left unused (reserved block). Encoders use Timer1 @1 kHz, LatchMode=FOUR3, with non-blocking pulse queue (~25 ms pulses). Selector uses resistor ladder on A0; adjust bands in firmware if resistor tolerances differ.

 

Arduino Leonardo B

Encoder 6-7

Encoder

Pin A

Pin B

Push

Button

Enc6

D2

D3

D4

1 (+), 2 (), 3 (Push)

Enc7

D5

D6

D7

4 (+), 5 (), 6 (Push)

  

ON–OFF Rockers

Pin

Button (Up)

Button (Down)

D0

26

25

D1

24

23

D8

22

21

D9

20

19

D10

18

17

D11

16

15

D12

14

13

D13

12

11

 

3-position Rockers

Rocker

Up Pin

Down Pin

Button (Up/Down/Mid)

A

A1

A2

27 / 28 / 29

B

A3

A4

30 / 31 / 32

 image.png

+5V from board to top of resistor R1-R5.

R1-R5 output to 5 position rotary switch ports 1-5

Common port of rotary switch to board A0

R6 from board GND (ground) to A0

 

Clear voltages at A0 (at 5.00 V supply & 10 kΩ pull-down)

Position Ri VA0 (V) ADC raw value (01023)

1           1 kΩ                 4.55 V              930

2          2.2 kΩ             4.10 V               839

3          3.9 kΩ              3.60 V              736

4          6.8 kΩ              2.98 V              609

5          12 kΩ               2.27 V              465

(Tolerances of resistors and 5 V rail cause slight deviations – that's why we use bands around these target values in the sketch.)

Wiring in words (position assignment)

·       Pos. 1 pad 1 kΩ            +5 V

·       Pos. 2 pad 2.2 kΩ         +5 V

·       Pos. 3 pad 3.9 kΩ         +5 V

·       Pos. 4 pad 6.8 kΩ         +5 V

·       Pos. 5 pad 12 kΩ          +5 V

·       COM/wiper                         A0

·       A0             10 kΩ             GND

Tip for testing: Set the rotary switch to one position, hold the multimeter on A0 against GND – the table (voltage) above should be roughly correct. If your measurements are slightly off, extend/shift the posBands[] in the sketch accordingly.

Software:

Libraries

·       Rotary Encoder: RotaryEncoder by Matthias Hertel (polling based, works on any pins).

·       HID Joystick: Joystick by Matthew Heironimus (Leonardo/Micro friendly).

 

HID strategy (what the sim sees)

·       Treat each encoder as two momentary buttons:

o   CW step press & release Button X+

o   CCW step press & release Button X

·       Encoder pushes and rockers map to normal buttons.

·       ON-OFF-ON uses three buttons (UP MIDDLE DOWN).

·       ON-OFF uses 2 buttons (UP DOWN)

·       5-pos 1 analog axis with 5 bands (with resistor ladder).

If anybody is interested I will be able to provide .stl files for filament and resin print, a bill of material with sample merchants delivering them and the sketch files for both Arduinos, just drop me a line.

Hope this will either find some builders using my plan or inspires to create their own box.

Edited by MFG62 Joker
  • Like 1
Posted

Interesting project!

Are the two Arduinos automatically recognized as two different Windows game controllers?

Until now, I have been using Leo Bodnar boards. However, these are quite a bit more expensive than the Arduino Leonardo boards...

Posted

sure thing, you can rename Arduino Leonardo to Rapti's ButtonBox, if you like ...😀

Needs to be done in Arduino Software and will be flashing the Arduino in question with the software sketch that you use to define your windows USB game controller.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...