PDA

View Full Version : Need Help with Transponder Script



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.

fordgt40
09-14-2010, 04:19 AM
Dave

You are welcome to try mine, or to use to trouble shoot against yours. I think that they both had the same origin

Regards

David


// *********************************** Transponder ************************************

//-------------------------------------------------------------------------------------------------------
// ** Transponder, similar to Bendix King KT-70 **
//-------------------------------------------------------------------------------------------------------

Var 1200, Name THOU, Value 7
{
CALL &XPNDRCALC
}

Var 1201, Name HUN, Value 0
{
CALL &XPNDRCALC
}

Var 1202, Name TENS, Value 0
{
CALL &XPNDRCALC
}

Var 1203, Name DECS, Value 0
{
CALL &XPNDRCALC
}

Var 1204, name INPXPNDR1000, Link IOCARD_ENCODER, Input 70, Aceleration 0, Type 2 // Input 1000
{
&THOU = &THOU + &INPXPNDR1000
&THOU = ROTATE 0 ,7 ,0
}

Var 1205, name INPXPNDR100, Link IOCARD_ENCODER, Input 68, Aceleration 0, Type 2 // Input 100
{
&HUN = &HUN + &INPXPNDR100
&HUN = ROTATE 0 ,7 ,0
}

Var 1206, name INPXPNDR10, Link IOCARD_ENCODER, Input 66, Aceleration 0, Type 2 // Input 10
{
&TENS = &TENS + &INPXPNDR10
&TENS = ROTATE 0 ,7 ,0
}

Var 1207, name INPXPNDR1, Link IOCARD_ENCODER, Input 64, Aceleration 0, Type 2 // Input 1
{
&DECS = &DECS + &INPXPNDR1
&DECS = ROTATE 0 ,7 ,0
}

Var 1208, Link IOCARD_SW, Input 63 // VFR button
{
&XPNDRDISP = 7000 // VFR Code (CH 7000, USA 1200, Germany 0021)
&XPNDRTOFS = TOBCD &XPNDRDISP
}

Var 1209, name XPNDRDISP, Link IOCARD_DISPLAY, Digit 5, Numbers 4 // Display
{
L0 = &XPNDRDISP
}

Var 1210, name XPNDRTOFS, Link FSUIPC_INOUT, Offset $0354, Length 2 // XPNDR
{
L0 = &XPNDRDISP
}

Var 1211, name XPNDRIN, Value 7000 // XPNDR Input from FS

Var 1212, Name IDENT, Link FSUIPC_OUT, Offset $7b93, Length 4 // IDT button for Squawkbox

Var 1213, Name IDENT_BTN, Link IOCARD_SW, Input 63 // IDT button
{
&IDENT = &IDENT_BTN
}

Var 1214, name XPNDRCALC, Link SUBRUTINE // Code calculation
{
L0 = &THOU * 1000
L1 = &HUN * 100
L0 = L0 + L1
L1 = &TENS * 10
L0 = L0 + L1
L0 = L0 + &DECS
&XPNDRTOFS = TOBCD L0
&XPNDRDISP = L0
}

Var 1216 Name STDBY, Link IOCARD_SW, Input 41
Var 1217 Name RPTG, Link IOCARD_SW, Input 39
Var 1218 Name XPNDR, Link IOCARD_SW, Input 38
Var 1219 Name TA, Link IOCARD_SW, Input 37
Var 1220 Name TA_RA, Link IOCARD_SW, Input 40

colt45
09-14-2010, 04:51 PM
David,

Thanks for offering up your script for troubleshooting it certainly looks like it was derived from the same source as mine. I have looked at this issue a bit further and now know what is causing it. It is not a matter of the transponder displaying a random code as I thought. I will try to explain.

When I first start FS the code is set to the VFR default of 1200 (for you 7000). I can dial in any other code and there are no issues. For instance, I set it to 5555. Then I hit the VFR button and it resets the display to 1200. Then I increase the "ones" encoder one detent and the display shows 5556 - hardly a random number. It is simply doing what the script says - incrementing the the least significant or "ones" digit by one. This is caused because the VFR button only resets the display to 1200 (or 7000 in your case) it does not reset the 4 variables that are used to initiate and calculate subsequent squawk codes. These variables are Var 0121,0122,0123 and 0124 in my script (Var 1200, 1201, 1202 and 1203 in your script). I have edited my code to reset them when the VFR button is pushed as shown in code snippet and it works. I thought I would pass it on as I suspect your script will have the same issue.


Var 0129, Link IOCARD_SW, Input 09 // VFR button
{
V0121 = 1
V0122 = 2
V0123 = 0
V0124 = 0
&XPNDRDISP = 1200 // VFR Code (CH 7000, USA 1200, Germany 0021)
&XPNDRTOFS = TOBCD &XPNDRDISP
}

Cheers,

fordgt40
09-14-2010, 05:07 PM
Dave

Many thanks for the feedback. I had not noticed the problem you mentioned - I just got it working to follow the encoders and moved onto the next challenge! So thanks again - you are making excellent progress for someone who professed little knowledge of SIOC some while ago, I recall:)

Regards

David

colt45
09-14-2010, 06:21 PM
David,

Thanks for the compliment but I think it is more a testament to the simplicity of SIOC than my knowledge that got me to this point. I believe I still fit in the "just enough knowledge to be dangerous" category. :lol:

Cheers,