Results 1 to 2 of 2
  1. #1
    150+ Forum Groupie
    Join Date
    Aug 2008
    Location
    Dallas, Texas
    Posts
    194
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    SIOC script for radios

    I'm having a problem with my COM1 & NAV1 scripts. I'm using dual home made rotary encoders using OpenCockpits encoders. When I turn the low digits knob counter clockwise the low digits rotate forward but when I turn it clockwise they swap between the last 2 numbers. The same happens with the high digits knob and the high digits but it also changes the low digits. On the NAV1 radio. the low digits knob works ok except backwards. The high digits knob swaps between the last 2 digits. If I change the frequencies with the mouse in FS my displays follow correctly so I know its not a problem with the displays wiring. Would appreciate any help.

    Here are my scripts:

    COM1

    Var 1001, Link FSUIPC_OUT, Offset $034E, Length 2 // COM1 ACTIVE

    Var 1002, Link FSUIPC_OUT, Offset $311A, Length 2 // COM 1 STANDBY

    Var 1003, Link IOCARD_DISPLAY, Digit 64, Numbers 5 // COM 1 ACTIVE

    Var 1004, Link IOCARD_DISPLAY, Digit 69, Numbers 5 // COM 1 STANDBY

    Var 1005 // Primary Digits COM 1

    Var 1006 // Decimal Digits COM 1

    Var 1007, Link SUBRUTINE // Value of COM 1
    {
    L0 = V1006 * -100
    L0 = L0 + V1006
    V1004 = L0
    V1002 = TOBCD L0
    }

    Var 1008, Link IOCARD_ENCODER, Input 145, Aceleration 1 // COM 1 ENCODER PRIMARY DIGITS
    {
    V1005 = V1005 - V1008
    IF V1005 > 17 // Decimal Digits COM 1
    {
    }
    V1005 = 8
    IF V1005 < 8 // Decimal Digits COM 1
    {
    }
    V1005 = 17
    CALL V1007 // Value of COM 1
    }

    Var 1009, Link IOCARD_ENCODER, Input 147, Aceleration 1 // COM 1 ENCODER DECIMAL DIGITS 0506
    {
    L0 = V1009 * -5
    V1006 = V1006 - L0
    IF V1006 > 95
    {
    }
    V1006 = 0
    IF V1006 < 0
    {
    }
    V1006 = 95
    CALL V1007
    }

    Var 1010, Link FSUIPC_OUT, Offset $3123, Length 1 // Registry Swap

    Var 1011, Link IOCARD_SW, Input 135 // Swap COM1
    {
    IF V1011 = 1
    {
    V1010 = 8
    }
    ELSE
    {
    }
    V1010 = 0
    }

    NAV1

    Var 8600 name FI_NAV1Freq Link FSUIPC_IN Offset $0350 Length 2
    {
    L0 = FROMBCD &FI_NAV1Freq
    &NAV1Freq = L0
    &NAV1FreqHigh = DIV L0 100
    &NAV1FreqLow = MOD L0 100
    CALL &OutNAV1Freq // display new freq value
    }

    Var 8601 name FI_NAV1Crs Link FSUIPC_IN Offset $0C4E Length 2
    {
    &NAV1Crs = &FI_NAV1Crs
    }

    Var 8610 name NAV1FreqLow
    Var 8611 name NAV1FreqHigh
    Var 8612 name NAV1Freq

    Var 8613 name CalcNAV1Freq Link SUBRUTINE
    {
    L0 = &NAV1FreqHigh * 100 // high * 100
    &NAV1Freq = L0 + &NAV1FreqLow // + low
    &FO_NAV1Freq = TOBCD &NAV1Freq // BCD value to panel
    CALL &OutNAV1Freq // display new freq value
    }

    Var 8614 name NAV1Crs
    {
    CALL &OutNAV1Crs
    }

    Var 8620 name OutNAV1Freq Link SUBRUTINE
    {
    &D_NAV1Freq = &NAV1Freq + 10000 // to display + '1'
    &O_NAV1DP = 1
    }

    Var 8621 name OutNAV1Crs Link SUBRUTINE
    {
    &D_NAV1Crs = &NAV1Crs
    }

    Var 8640 name RO_NAV1FL Link IOCARD_ENCODER Input 151 Aceleration 1 Type 2
    {
    L0 = &RO_NAV1FL * 5
    &NAV1FreqLow = ROTATE 0 99 L0
    CALL &CalcNAV1Freq
    }

    Var 8641 name RO_NAV1FH Link IOCARD_ENCODER Input 149 Aceleration 1 Type 2
    {
    L0 = &RO_NAV1FH
    &NAV1FreqHigh = ROTATE 8 35 L0
    CALL &CalcNAV1Freq
    }

    Var 8642 name RO_NAV1CRS Link IOCARD_ENCODER Input 61 Aceleration 4 Type 2
    {
    L0 = &RO_NAV1CRS
    &NAV1Crs = ROTATE 0 359 L0
    &FO_NAV1Crs = &NAV1Crs
    }

    Var 8670 name D_NAV1Freq Link IOCARD_DISPLAY Digit 74 Numbers 5
    Var 8671 name D_NAV1Crs Link IOCARD_DISPLAY Digit 88 Numbers 3

    Var 8680 name O_NAV1DP Link IOCARD_OUT Output 96

    Var 8698 name FO_NAV1Crs Link FSUIPC_OUT Offset $0C4E Length 2
    Var 8699 name FO_NAV1Freq Link FSUIPC_OUT Offset $0350 Length 2

  2. #2
    500+ This must be a daytime job
    Join Date
    Jul 2013
    Posts
    948
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: SIOC script for radios

    Jerry

    First thing I have noticed relates to the following section of code.

    Var 1008, Link IOCARD_ENCODER, Input 145, Aceleration 1 // COM 1 ENCODER PRIMARY DIGITS
    {
    V1005 = V1005 - V1008
    IF V1005 > 17 // Decimal Digits COM 1
    {
    }
    V1005 = 8
    IF V1005 < 8 // Decimal Digits COM 1
    {
    }
    V1005 = 17
    CALL V1007 // Value of COM 1
    }

    There are open and closed brackets after the conditional IF statements but no code within them. So the condition statement does nothing. In simple terms if you want some code only actioned if a condition is met then the syntax is

    IF A = B
    {
    This code will only be executed if A=B
    }

    Regards

    David