Results 1 to 5 of 5
  1. #1
    75+ Posting Member
    Join Date
    Oct 2008
    Location
    ontario
    Posts
    95
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Need Help with Transponder Script

    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.

    Code:
    //------------------------------------------------------------------------------------------------------- 
    // ** 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.
    Dave Kemp
    FS9-BU0836X-GoFlight 166-TH2GO-WideFS-FSUIPC-Opencockpits

  2. #2
    500+ This must be a daytime job



    Join Date
    Jul 2013
    Posts
    917
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Need Help with Transponder Script

    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

  3. #3
    75+ Posting Member
    Join Date
    Oct 2008
    Location
    ontario
    Posts
    95
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Need Help with Transponder Script

    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.

    Code:
    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,
    Dave Kemp
    FS9-BU0836X-GoFlight 166-TH2GO-WideFS-FSUIPC-Opencockpits

  4. #4
    500+ This must be a daytime job



    Join Date
    Jul 2013
    Posts
    917
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Need Help with Transponder Script

    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

  5. #5
    75+ Posting Member
    Join Date
    Oct 2008
    Location
    ontario
    Posts
    95
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Need Help with Transponder Script

    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.

    Cheers,
    Dave Kemp
    FS9-BU0836X-GoFlight 166-TH2GO-WideFS-FSUIPC-Opencockpits

Similar Threads

  1. New transponder
    By gokhotit in forum My Cockpit Update
    Replies: 0
    Last Post: 12-30-2009, 01:28 PM
  2. Building A GA Transponder
    By CessnaGuy in forum General Builder Questions All Aircraft Types
    Replies: 7
    Last Post: 10-01-2009, 12:36 PM
  3. Transponder for GA (Cessna)
    By colt45 in forum General Builder Questions All Aircraft Types
    Replies: 5
    Last Post: 05-01-2009, 07:03 PM
  4. Transponder
    By bindook in forum I/O Interfacing Hardware and Software
    Replies: 5
    Last Post: 03-22-2007, 02:07 AM