The Transponder

One of the more complex tasks for a seemingly simple device is the Transponder. The four-digit code can be tuned using four individual controls or a single rotary control with an integrated pushbutton.

This article covers using a single rotary encoder with an integrated pushbutton.

Typical Conventions:

Text In Bold Blue Usable EPL Code
Text In Bold Red
User-Replaceable Values. These are values that you should replace with your own. As every epic system is wired differently, your particular switches, displays, rotaries, etc will be wired to locations different than mine.

As usual, always include initialization lines in the EPL code. They only need to be included once and should go at the beginning of your EPL code file. First, include the EPIC95 package from Peter Dowson. If you aren't using Peter Dowson's EPIC95 Package, you should be! It's pretty much a necessity to realize the true potential of your EPIC system.

 

  #include EPICVXD.INC
#include MACROS.HPL

Now we'll define the display numbers. My Transponder displays just happen to be the first 4 digit on my 32-digit display card, which are labeled 0 thru 3, respectively.

  #define XPDR0_DSP 0
#define XPDR1_DSP 1
#define XPDR2_DSP 2
#define XPDR3_DSP 3

The following lines indicate that the display module is '2', the first digit is physical digit '0', which is an absolute value according to the 32-digit display card. Lastly, each display will use only '1' digit. The '0b00000001' turns off the decimal point for each digit.

 

  definedisplay(XPDR0_DSP, 2, 0, 1, 0,0,FALSE, 0b00000001)
definedisplay(XPDR1_DSP, 2, 1, 1, 0,0,FALSE, 0b00000001)
definedisplay(XPDR2_DSP, 2, 2, 1, 0,0,FALSE, 0b00000001)
definedisplay(XPDR3_DSP, 2, 3, 1, 0,0,FALSE, 0b00000001)

The pigeonhole call ensures that every time the transponder value changes within the flight sim engine, the 'Transponder' routine is called, thereby updating the display. Pigeonhole 5 is where the transponder values reside.

  DefinePH(5, Transponder, 0,0,0,0) ;Transponder

Flags required for the math used in deriving certain values

  Var16(Remdr)
var16(temp16)
var(Temp)
var(temp8)
These flags will track which is the 'Active' digit, so the program can keep track of which digit is being tuned FLAG(XPDR0_FLAG, FALSE)
FLAG(XPDR1_FLAG, FALSE)
FLAG(XPDR2_FLAG, FALSE)
FLAG(XPDR3_FLAG, TRUE)
;BE SURE YOU SET THIS TO TRUE!

THe INIT{} section merely initializes the rotary card (Provided you have one) and sets the Transponder digits to a -DASH-. This is for nothing more than being fancy but is also a good way to determine if your EPIC card has intialized correctly.

The statement SENDDATA(2,0,0x0b) can be explained as: Send a -DASH- to Digit '0' on Module 2, which happens to be the display module. (Physical Digits are numbered 0 thru 31) Likewise, SENDDATA(2,0,0x1b) means send a -DASH- to Digit '1' on Module 2.

 

:init{

;Rotary Module Stuff
Senddata(7,0,0b11111111)
Senddata(7,1,0b11111111)

;BEGIN ROW 0
senddata(2,0,0x0b) ;Digit 0 of XPDR
senddata(2,0,0x1b) ;Digit 1 of XPDR
senddata(2,0,0x2b) ;Digit 2 of XPDR
senddata(2,0,0x3b) ;Digit 3 of XPDR

}

I'll be the first to admit I'm not happy that the code in red didn't workk and I have no idea as other than perhaps it's a compiler limit. There seems to be a limitation in the EPIC compiler that allows up to 3 IF statements, but not 4.

Originally, this is what it looked like...

Don't Use!!!

:XPDR_Chk

{
IF(XPDR3_FLAG){Jump(XPDR3_SET)}
IF(XPDR2_FLAG){Jump(XPDR2_SET)}
IF(XPDR1_FLAG){Jump(XPDR1_SET)}
IF(XPDR0_FLAG){Jump(XPDR0_SET)}
}

Because of the Compiler limitation, I had to rewrite the code above like this: It's a little clumsy, but still gets the job done.

 

 

 

:XPDR_Chk

{
IF(XPDR3_FLAG){Jump(XPDR3_SET)} Else{Jump(XPDR_Chk210)}}
:XPDR_CHK210
{IF(XPDR2_FLAG){Jump(XPDR2_SET)} Else{Jump(XPDR_Chk10)}}
:XPDR_CHK10
{IF(XPDR1_FLAG){Jump(XPDR1_SET)} Else{Jump(XPDR0_SET)}
}

Set FLAGS according to which digit was last tuned and which one should be tuned next. It sends a -DASH- to the digit that will be tuned.

:XPDR0_SET{
CLEARFLAG(XPDR0_FLAG) SETFLAG(XPDR3_FLAG)
Senddata(2,0,0x3A)}

:XPDR3_SET{
CLEARFLAG(XPDR3_FLAG) SETFLAG(XPDR2_FLAG)
Senddata(2,0,0x2A)}

:XPDR2_SET{
CLEARFLAG(XPDR2_FLAG) SETFLAG(XPDR1_FLAG)
Senddata(2,0,0x1A)}

:XPDR1_SET{
CLEARFLAG(XPDR1_FLAG) SETFLAG(XPDR0_FLAG)
Senddata(2,0,0x0A)}

This routine is in charge of sending joystick button events to the simulator depending on which flag is currently set. I'm curious that this routine works and :XPDR_CHK doesn't, considering it also contains 4 separate IF statements. The joystick events are interpreted in the FS2000.CFG file, which is a separate article.

:XPDR_CHG

{
IF(XPDR3_FLAG) {ENQUE16(BTNPULSE, 6)}
IF(XPDR2_FLAG) {ENQUE16(BTNPULSE, 5)}
IF(XPDR1_FLAG) {ENQUE16(BTNPULSE, 4)}
IF(XPDR0_FLAG) {ENQUE16(BTNPULSE, 3)}
}
The BTNPULSE calls are joystick button press events

Finally, the button events: Button 150 (Which is most likely different on your EPIC system) sets the digit to be tuned, while button 180 tunes the digit.
DefineButton(150, Off, XPDR_CHK)
DefineButton(180, ON, XPDR_CHG)
DefineButton(180, OFF, XPDR_CHG)
Lastly, here's the new Transponder section in the FS2000.CFG  

[JOYSTICK_00]
...
BUTTON_DOWN_EVENT_03=XPNDR_1_INC
BUTTON_DOWN_EVENT_04=XPNDR_10_INC
BUTTON_DOWN_EVENT_05=XPNDR_100_INC
BUTTON_DOWN_EVENT_06=XPNDR_1000_INC