Results 1 to 3 of 3
  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

    Help with SIOC script

    I made my own radios with displays and encoders from Open Cockpits but I apparently don't have a talent for programing. Math never was one of my easiest subjects. I copied this script for my COM1 and tried to translate some of the Spanish to English to help me understand it better. I input my pin numbers but I don't know if there was something wrong with the script or it isn't right for my setup. I'm using 2 encoders and 2 five digit displays. When I turn my encoders counter clockwise the digits count down as they should but when I turn them clockwise the digits change back and forth between the last 2 numbers. I can't even find the original file to see if I accidentally deleted some script. I would really appreciate some help with this, I have been struggling with it for a while. Here is my script.



    Var 0200 // Standby Frequency 2D High Digits
    {
    CALL V0212 // Send value to Simulator
    }

    Var 0201 // Standby Frequency 2D Low Digits
    {
    CALL V0212 // Send value to Simulator
    }

    Var 0202, Link IOCARD_DISPLAY, Digit 64, Numbers 5 // Active Radio Frequency

    Var 0203, Link IOCARD_DISPLAY, Digit 69, Numbers 2 // Standby Frequency Low Digits

    Var 0204, Link IOCARD_DISPLAY, Digit 71, Numbers 2 // Standby Frequency High Digits

    Var 0205, Link IOCARD_DISPLAY, Digit 73, Numbers 1 // Standby Frequency 1 Digit

    Var 0206, Value 0

    Var 0207, Link FSUIPC_OUT, Offset $311A, Length 2 // COM1 Standby Frequency
    {
    V0204 = V0200 // Send high digits to display
    V0203 = V0201 // Send low digits to display
    }

    Var 0208, Link FSUIPC_OUT, Offset $034E, Length 2 // COM1 Active Frequency
    {
    L0 = FROMBCD V0208 // change to binary
    V0202 = L0 + 10000 // and display the 1 in front
    }

    Var 0209, Link IOCARD_SW, Input 135, Type P // SWAP Active/Standby
    {
    L0 = V0200 * 100 // Value of 2 high digits
    L0 = L0 + V0201 // + value of low digits
    L1 = FROMBCD V0208 // Save the current frequency changing to dec
    V0208 = TOBCD L0 // Y le paso la frecuencia de Standbye
    L0 = L1 / 100 // Saco los 2 digitos altos
    V0200 = TRUNC L0 // Se los paso a la variable
    L2 = V0200 * 100
    V0201 = L1 - L2 // Paso los 2 digitos bajos
    }

    Var 0210, Link IOCARD_ENCODER, Input 183, Aceleration 1 // Encoder High Digits
    {
    V0200 = ROTATE 18 ,36 ,V0210 // Inc/Decrement considerando limites 18-36
    }

    Var 0211, Link IOCARD_ENCODER, Input 185, Aceleration 1 // Low digits
    {
    IF V0211 > 0 // If the frequency increases
    {
    IF V0201 = 97 // If it has reached the high limit
    {
    V0201 = 0 // Step to 0
    }
    ELSE // If it has not reached the limit
    {
    L0 = V0201 + 3 // add 3 but now I check...
    L1 = L0 / 10 // Saco unidades
    L1 = TRUNC L1
    L1 = L1 * 10
    L1 = L0 - L1
    IF L1 = 3 // If the units end in 3
    {
    L0 = L0 + 1 // Decrease by 1
    }
    IF L1 = 8 // If the units end in 8
    {
    L0 = L0 - 1 // Decrease by 1
    }
    V0201 = L0 // pass the final value
    }
    }
    ELSE // If the frequency decreases
    {
    IF V0201 = 0 // If it has reached the limit
    {
    V0201 = 97 // Step to the high value (97)
    }
    ELSE // If it has not reached the limit
    {
    L0 = V0201 - 3
    IF L0 = -1 // See if it is - 1 which corresponds to 0
    {
    V0201 = 0 // assign 0
    }
    ELSE // continue with lextraccion of the units
    {
    L1 = L0 / 10 // Saco unidades
    L1 = TRUNC L1
    L1 = L1 * 10
    L1 = L0 - L1
    IF L1 = 4 // If it ends in 4 corresponding to 5
    {
    L0 = L0 + 1
    }
    IF L1 = 9 // If it ends in 9 corresponding with 0
    {
    L0 = L0 + 1
    }
    V0201 = L0 // Paso el valor a la variable
    }
    }
    }
    }

    Var 0212, Link SUBRUTINE // Manda valor a frecuencia standby
    {
    L0 = V0200 * 100 // Monta el número
    L0 = L0 + V0201
    V0207 = TOBCD L0 // Pasamos a BCD y enviamos al simulador
    }

  2. #2
    150+ Forum Groupie


    Perik's Avatar
    Join Date
    Aug 2007
    Location
    NORWAY
    Posts
    229
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Help with SIOC script

    Jerry

    You forgot to define the type of encoder:

    Code:
    Var 0210, Link IOCARD_ENCODER, Input 183, Aceleration 1 Type 2 // Encoder High Digits
     
    Var 0211, Link IOCARD_ENCODER, Input 185, Aceleration 1 Type 2 // Low digits
    Regards,
    Per-Erik
    www.hoddo.net

  3. #3
    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

    Re: Help with SIOC script

    Thank you so much. I can't believe it was something so simple. Works fine now.

    Jerry