colt45
09-13-2010, 09:55 PM
Gents,
I am putting the finishing touches finally on my GA transponder and have run in to a small problem with my script which is included below. As you can see it starts by assigning the standard VFR squawk code 1200 to the transponder. I would expect that when I turn my "1's" encoder one detent the code would become 1201 or if I turn the "10's" encoder one detent the code would become 1210, etc.
However when I turn any one of my four encoders the 1200 code displayed on both my led display and the FS transponder becomes a totally random number. Any turn of any encoder after that behaves as expected. If I push my VFR button to return the code to 1200 it works fine. Then again with one trun of any of the encoders it displays a random number before settling in and changing digits propoerly.
//-------------------------------------------------------------------------------------------------------
// ** Transponder, similar to Bendix King KT-70 **
//-------------------------------------------------------------------------------------------------------
Var 0, value 0
{
&XPONDER_INIT = 10
&LED_INIT = 20
}
Var 0001, name XPONDER_INIT // used to initialize led to be unlit
Var 0002, name LED_INIT
{
IF &XPONDER_INIT = 10
{
&XPONDER_LED = 0
}
}
Var 0121, Value 1
{
CALL &XPNDRCALC
}
Var 0122, Value 2
{
CALL &XPNDRCALC
}
Var 0123, Value 0
{
CALL &XPNDRCALC
}
Var 0124, Value 0
{
CALL &XPNDRCALC
}
Var 0125, name INPXPNDR1000, Link IOCARD_ENCODER, Input 06, Aceleration 0, Type 2 // Input 1000
{
V0121 = V0121 + &INPXPNDR1000
V0121 = ROTATE 0 ,7 ,0
}
Var 0126, name INPXPNDR100, Link IOCARD_ENCODER, Input 04, Aceleration 0, Type 2 // Input 100
{
V0122 = V0122 + &INPXPNDR100
V0122 = ROTATE 0 ,7 ,0
}
Var 0127, name INPXPNDR10, Link IOCARD_ENCODER, Input 02, Aceleration 0, Type 2 // Input 10
{
V0123 = V0123 + &INPXPNDR10
V0123 = ROTATE 0 ,7 ,0
}
Var 0128, name INPXPNDR1, Link IOCARD_ENCODER, Input 00, Aceleration 0, Type 2 // Input 1
{
V0124 = V0124 + &INPXPNDR1
V0124 = ROTATE 0 ,7 ,0
}
Var 0129, Link IOCARD_SW, Input 09 // VFR button
{
&XPNDRDISP = 1200 // VFR Code (CH 7000, USA 1200, Germany 0021)
&XPNDRTOFS = TOBCD &XPNDRDISP
}
Var 0130, name XPNDRDISP, Link IOCARD_DISPLAY, Digit 12, Numbers 4 // Display
{
L0 = &XPNDRDISP
}
Var 0131, name XPNDRTOFS, Link FSUIPC_INOUT, Offset $0354, Length 2 // XPNDR
{
L0 = &XPNDRDISP
}
Var 0132, name XPNDRIN, Value 1200 // XPNDR Input from FS
Var 0133, Link FSUIPC_OUT, Offset $7b93, Length 1 // IDT button for Squawkbox
Var 0134, Link IOCARD_SW, Input 10 // IDT button
{
V0133 = V0134
}
Var 0304, Link IOCARD_SW, Input 11 // XPNDR Mode STBY
{
IF V0304 = 1
{
V0399 = 1
}
}
Var 0305, Link IOCARD_SW, Input 12 // XPNDR Mode Normal
{
IF V0305 = 1
{
V0399 = 0
}
}
Var 0399, Link FSUIPC_OUT, Offset $7B91, Length 1 // Squawkbox XPNDR Mode
{
CALL V0139
}
Var 0139, Link SUBRUTINE // state of transponder to set led
{
IF v0399 = 0
{
&XPONDER_LED = 1
}
ELSE
{
&XPONDER_LED = 0
}
}
Var 0140, name XPONDER_LED, Link IOCARD_OUT Output 11 // led to indicate standby or Mode C
Var 0141, name XPNDRCALC, Link SUBRUTINE // Code calculation
{
L0 = V0121 * 1000
L1 = V0122 * 100
L0 = L0 + L1
L1 = V0123 * 10
L0 = L0 + L1
L0 = L0 + V0124
&XPNDRTOFS = TOBCD L0
&XPNDRDISP = L0
}
Any sugggestions? This is my first OC script (borrowed from an OC forum post and slightly revised) and I thought I had it nailed.
Many thanks.
I am putting the finishing touches finally on my GA transponder and have run in to a small problem with my script which is included below. As you can see it starts by assigning the standard VFR squawk code 1200 to the transponder. I would expect that when I turn my "1's" encoder one detent the code would become 1201 or if I turn the "10's" encoder one detent the code would become 1210, etc.
However when I turn any one of my four encoders the 1200 code displayed on both my led display and the FS transponder becomes a totally random number. Any turn of any encoder after that behaves as expected. If I push my VFR button to return the code to 1200 it works fine. Then again with one trun of any of the encoders it displays a random number before settling in and changing digits propoerly.
//-------------------------------------------------------------------------------------------------------
// ** Transponder, similar to Bendix King KT-70 **
//-------------------------------------------------------------------------------------------------------
Var 0, value 0
{
&XPONDER_INIT = 10
&LED_INIT = 20
}
Var 0001, name XPONDER_INIT // used to initialize led to be unlit
Var 0002, name LED_INIT
{
IF &XPONDER_INIT = 10
{
&XPONDER_LED = 0
}
}
Var 0121, Value 1
{
CALL &XPNDRCALC
}
Var 0122, Value 2
{
CALL &XPNDRCALC
}
Var 0123, Value 0
{
CALL &XPNDRCALC
}
Var 0124, Value 0
{
CALL &XPNDRCALC
}
Var 0125, name INPXPNDR1000, Link IOCARD_ENCODER, Input 06, Aceleration 0, Type 2 // Input 1000
{
V0121 = V0121 + &INPXPNDR1000
V0121 = ROTATE 0 ,7 ,0
}
Var 0126, name INPXPNDR100, Link IOCARD_ENCODER, Input 04, Aceleration 0, Type 2 // Input 100
{
V0122 = V0122 + &INPXPNDR100
V0122 = ROTATE 0 ,7 ,0
}
Var 0127, name INPXPNDR10, Link IOCARD_ENCODER, Input 02, Aceleration 0, Type 2 // Input 10
{
V0123 = V0123 + &INPXPNDR10
V0123 = ROTATE 0 ,7 ,0
}
Var 0128, name INPXPNDR1, Link IOCARD_ENCODER, Input 00, Aceleration 0, Type 2 // Input 1
{
V0124 = V0124 + &INPXPNDR1
V0124 = ROTATE 0 ,7 ,0
}
Var 0129, Link IOCARD_SW, Input 09 // VFR button
{
&XPNDRDISP = 1200 // VFR Code (CH 7000, USA 1200, Germany 0021)
&XPNDRTOFS = TOBCD &XPNDRDISP
}
Var 0130, name XPNDRDISP, Link IOCARD_DISPLAY, Digit 12, Numbers 4 // Display
{
L0 = &XPNDRDISP
}
Var 0131, name XPNDRTOFS, Link FSUIPC_INOUT, Offset $0354, Length 2 // XPNDR
{
L0 = &XPNDRDISP
}
Var 0132, name XPNDRIN, Value 1200 // XPNDR Input from FS
Var 0133, Link FSUIPC_OUT, Offset $7b93, Length 1 // IDT button for Squawkbox
Var 0134, Link IOCARD_SW, Input 10 // IDT button
{
V0133 = V0134
}
Var 0304, Link IOCARD_SW, Input 11 // XPNDR Mode STBY
{
IF V0304 = 1
{
V0399 = 1
}
}
Var 0305, Link IOCARD_SW, Input 12 // XPNDR Mode Normal
{
IF V0305 = 1
{
V0399 = 0
}
}
Var 0399, Link FSUIPC_OUT, Offset $7B91, Length 1 // Squawkbox XPNDR Mode
{
CALL V0139
}
Var 0139, Link SUBRUTINE // state of transponder to set led
{
IF v0399 = 0
{
&XPONDER_LED = 1
}
ELSE
{
&XPONDER_LED = 0
}
}
Var 0140, name XPONDER_LED, Link IOCARD_OUT Output 11 // led to indicate standby or Mode C
Var 0141, name XPNDRCALC, Link SUBRUTINE // Code calculation
{
L0 = V0121 * 1000
L1 = V0122 * 100
L0 = L0 + L1
L1 = V0123 * 10
L0 = L0 + L1
L0 = L0 + V0124
&XPNDRTOFS = TOBCD L0
&XPNDRDISP = L0
}
Any sugggestions? This is my first OC script (borrowed from an OC forum post and slightly revised) and I thought I had it nailed.
Many thanks.