Skip to content

MSFS2020 Transponder Keypad and Display on 7 Segment Module

Jaime Leon edited this page Jan 6, 2022 · 43 revisions

How to Mimic the FBW A320 ATC Keypad and Display

WORK IN PROGRESS - PLEASE COME BACK LATER

In this tutorial we will configure Mobiflight to mimic the operation of the ATC (Transponder) panel keypad of the FlyByWire A320 mod airplane. Our focus will be only on mimicking the behavior of the keypad and display, using RPN code in both input and output configurations. We will not cover the other knobs and buttons in the ATC panel.

The A320 ATC Panel

The keypad has 9 keys, 8 numeric (numbers 0 to 7) plus a CLR key. The display shows the four octal digits transponder code. In normal operation, the numeric keys are disabled and the CLR key is pressed once or twice, depending on the action needed. Press CLR once to delete and reenter the last number, or press twice to delete the four digits and reenter the entire code. The led display will show the transponder code in normal operation or each new digit from left to right, when entering a new transponder code. The CLR key can be pressed at any time during entering a new code to delete the last number entered, or press twice to restart the code entry. If there is a delay of 7 seconds or more at any time during the entry of the code prior to completing the four digits, the unit resets the display back to the previously used code. This is the behavior we intend to reproduce in our external ATC panel keypad and display.

A320 ATC panel

Preparations

We will need to have a

  • Any supported Arduino board (Mega, Pro Micro, Uno, Nano)
  • One MAX7219 eight digit 7-Segment LED display module (we will only use four digits),
  • Nine buttons for the keypad
  • Working installation of MSFS2020 and Mobiflight

We assume that you know how to wire the 7-segment display module and buttons to your Arduino board. If not, please pause this tutorial and refer to more basic tutorials already available on how to wire and configure devices with Arduino and Mobiflight. Please take note of the pin numbers used by the LED module display and the nine buttons. Once the hardware is wired to the arduino, please create the corresponding devices in your Mobiflight board configuration. Again, we assume that adding device configurations to your Mobiflight board is known by you. Be sure to upload the board configuration once you have completed the device configurations. Also save this configuration to a mfmc file.

Next, you need to create nine input configurations for the nine buttons and one output configuration for the LED display module.

Button Configuration

Let's start with the button for "1". Name this configuration "ATC Btn 1". In the input tab select the board and corresponding button, which you have already created. In the On Press tab, select "MSFS2020-Custom Input" and enter the following code:

KEY 1 (L:XPNDR_clr) 0 > if{ 1 (>L:XPNDR_key) 1 (>L:XPNDR_act,bool) (>H:A320_Neo_ATC_BTN_1) }

image

Notes on the code:

XPNDR_clr is a user-defined control variable used to flag when the CLR key has been pressed. The CLR key should be pressed in order to activate entering numbers on the keypad, therefore we first check if this variable is not zero. If false, we do nothing. If true, we enter a "1" in variable XPNDR_key. This variable holds the value of the last key pressed to be used later. We then set the XPNDR_act variable to 1, signalling that a keypad key has been pressed. To maintain the sim in sync with our key press, we call the A320 H: event for the same key press.

All 8 keys from 0 to 7 will be treated in the same way. The only difference in the code for each key press will be the value entered in XPNDR_key and the corresponding H: event to maintain the sim display in sync with ours.

Following is the list of code to be entered in the Custom Input box for each subsequent button configuration. Please proceed to create the additional button configuration in the same way as the configuration for the "1" Key.

KEY 2 (L:XPNDR_clr) 0 > if{ 2 (>L:XPNDR_key) 1 (>L:XPNDR_act,bool) (>H:A320_Neo_ATC_BTN_2) }

KEY 3 (L:XPNDR_clr) 0 > if{ 3 (>L:XPNDR_key) 1 (>L:XPNDR_act,bool) (>H:A320_Neo_ATC_BTN_3) }

KEY 4 (L:XPNDR_clr) 0 > if{ 4 (>L:XPNDR_key) 1 (>L:XPNDR_act,bool) (>H:A320_Neo_ATC_BTN_4) }

KEY 5 (L:XPNDR_clr) 0 > if{ 5 (>L:XPNDR_key) 1 (>L:XPNDR_act,bool) (>H:A320_Neo_ATC_BTN_5) }

KEY 6 (L:XPNDR_clr) 0 > if{ 6 (>L:XPNDR_key) 1 (>L:XPNDR_act,bool) (>H:A320_Neo_ATC_BTN_6) }

KEY 7 (L:XPNDR_clr) 0 > if{ 7 (>L:XPNDR_key) 1 (>L:XPNDR_act,bool) (>H:A320_Neo_ATC_BTN_7) }

KEY 0 (L:XPNDR_clr) 0 > if{ 0 (>L:XPNDR_key) 1 (>L:XPNDR_act,bool) (>H:A320_Neo_ATC_BTN_0) }

The CLR Key

The CLR Key is very important in this setup. Remember, the keypad remains inactive until the CLR is pressed. The first press of the CLR key is to delete and reenter the last key pressed. To enter a new transponder code, the CLR key needs to be pressed twice. This requires some special treatment in the code in order to detect this second key press.

Create the button configuration in the same way we did for the number buttons. The code for the CLR key is a bit more complicated

KEY CLR (L:XPNDR_clr) s1 2 < if{ (L:XPNDR_pos) -- s0 0 < if{ 3 } els{ l0 } (>L:XPNDR_pos) l1 0 == if{ (A:TRANSPONDER CODE:1,number) } els{ (L:XPNDR_temp) } 10 div (>L:XPNDR_temp) 2 (>L:XPNDR_clr) } els{ 0 (>L:XPNDR_temp) 0 (>L:XPNDR_pos) } (>H:A320_Neo_ATC_BTN_CLR) (E:SIMULATION TIME,second) 7 + (>L:XPNDR_timeout)

image

Notes on the CLR key code:

The first thing we need to check is to see if this is the first or second press of this key. XPNDR_clr is zero when there is no action pending. Therefore if the value of XPNDR_clear is equal to 0 or 1, we have the first press. To backspace one digit in the code we take either the current Transponder code (if no partial code has been entered yet) or the partial code being entered in XPNDR_temp and do integer division by 10. In effect, this shifts the code one position to the right. In the first press, the variable XPNDR_pos is decreased by one (to edit the last entered number) and XPNDR_clr is set to 2.

If the CLR key is pressed again, it will have a value of 2 and the code will set for entering the entire Transponder code. To that effect, the variables XPNDR_temp and XPNDR_pos are both set to 0

We now call the H: event for the CLR key to maintain the in sim display in sync.

Lastly, we take care of the key timeout. The simulator has this variable "SIMULATION TIME" which keeps count of the time elapsed since the sim started to run. The timeout works by reading this variable (now time), adding 7 seconds and storing this in XPNDR_timeout. This adding of 7 seconds is done each time any key is pressed. We will see later how the timeout check code uses this information.

Output Config - Numeric Key Press Handler

OUTPUT CONFIG 1 - NUM KEY PRESS HANDLER - 7 SEGMENT DISPLAYS THE CODE WHILE EDITING (SPACE NO PAD) (L:XPNDR_act,bool) if{ 0 (>L:XPNDR_act) (L:XPNDR_clr) 2 == if{ 1 (>L:XPNDR_clr) } (L:XPNDR_key) (L:XPNDR_temp,number) 10 * + (>L:XPNDR_temp,number) (L:XPNDR_pos) ++ 4 min s0 (>L:XPNDR_pos) l0 4 == if{ (L:XPNDR_temp,bco16) (>K:XPNDR_SET) 0 (>L:XPNDR_timeout) 0 (>L:XPNDR_temp,number) 0 (>L:XPNDR_pos) 0 (>L:XPNDR_clr) } (E:SIMULATION TIME,second) 7 + (>L:XPNDR_timeout) } (L:XPNDR_clr) 0 > if{ (L:XPNDR_temp) } els{ (A:TRANSPONDER CODE:1,enum) }

OUTPUT CONFIG 2 - 7 SEGMENT DISPLAYS THE TRANSPONDER CODE (ZERO LEFT PAD)

OUTPUT CONFIG 2 - 7 SEC TIMEOUT HANDLER (L:XPNDR_timeout) 0 != if{ (E:SIMULATION TIME,second) (L:XPNDR_timeout) > if{ 0 s0 (>L:XPNDR_timeout) l0 (>L:XPNDR_temp) l0 (>L:XPNDR_pos) l0 (>L:XPNDR_clr) } }

Installation

User Interface

Examples and tutorials

MSFS2020

X-Plane

Workshops

Community Boards & Devices

Additional Information

Firmware

Clone this wiki locally