Results 1 to 8 of 8
  1. #1
    500+ This must be a daytime job



    Join Date
    Jan 2007
    Location
    NEW ZEALAND
    Posts
    908
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Sioc Codeing help

    Hi all,
    Hope someone can help me correct the following code. Tried everything i understand but no
    luck.
    What i am trying to do is to have the output to a servo(fuel gauge) read zero when battery
    switch is OFF. Here is my code.
    Code:
    Var 0010, name Batswstate, Link FSUIPC_IN, Offset $3102, Length 1     // MASTER BATTERY OFF =0
    Var 012, name Fuel, Link FSUIPC_IN, Offset $0B94, Length 4     // Right Tank Percentage
    
    {
     IF V010 = 0
      {
       V014 = 0
      }
    
    
      L0 = &Fuel / 8388608
      IF L0 < 0.25
      {
        L0 = L2 * 1023
        V014 = L1 + 60
      }
      ELSE
      {
        V014 = L0 * 1023
      }
    }
    Var 014, Link USB_SERVOS, Output 2, PosL 0, PosC 512, PosR 1000, Type 2
    Thanks
    Regards
    Les

  2. #2
    150+ Forum Groupie
    Join Date
    Feb 2007
    Location
    Argentina
    Posts
    187
    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 Codeing help

    Les:
    With the USB SERVO, the value = 0 is for disconnect servo. (stays in place)
    The value depends of the servo to mark 0 in instrument´s scale.
    Try another number (as i see in the SIOC code, must be in the range of 1 to 60)

    [
    IF V010 = 0
    [
    V014 = 60 // or value to zero the instrument´s scale
    ]

    Regards.
    Horacio.

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



    Join Date
    Jan 2007
    Location
    NEW ZEALAND
    Posts
    908
    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 Codeing help

    Hi Horacio,
    Nice to hear from you and thanks for replying. I tried your suggestion and had no luck.
    So i changed the code around as follows
    Code:
    Var 0010, name Batswstate, Link FSUIPC_IN, Offset $3102, Length 1     // MASTER BATTERY OFF =0
    
    Var 0012, name Fuel, Link FSUIPC_IN, Offset $0B94, Length 4     // Right Tank Percentage
    {
      L0 = &Fuel / 8388608
      IF L0 < 0.25
      {
        
        L0 = L2 * 1023
        V0014 = L1 + 60
      }
      ELSE
      {
        V0014 = L0 * 1023
      }
      IF &Batswstate = 0
      {
        V0014 = 10    
      }
    }
    
    Var 0014, Link USB_SERVOS, Output 2, PosL 0, PosC 512, PosR 0
    Now it works BUT only when the engine is running, which shows in IOCPconsole
    the fuel decreasing.
    From my reading on Nico's site he says that " when a variable changes the script
    in Curly brackets following is executed" obviously my understanding is wrong.
    Cause according to my script its only executed if the fuel quantity is changing.So how does one get a process executed when this varaible
    cant change as in my case fuel quantity.
    Im utterly confused and no wonder why i can never get much to work .
    Anyway your comments and ideas would be appreciated.
    Thanks again
    Regards
    les

  4. #4
    150+ Forum Groupie
    Join Date
    Feb 2007
    Location
    Argentina
    Posts
    187
    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 Codeing help

    Les:
    Some lines in your code are wrong.

    L0 = &Fuel / 8388608
    IF L0 < 0.25
    {
    L0 = L2 * 1023
    V0014 = L1 + 60
    ........


    Where is L2 ??????


    Anyway, try this way, working on my setup.


    Code:
    Var 0010, name Batswstate, Link FSUIPC_IN, Offset $3102, Length 1     // MASTER BATTERY OFF =0{
      L0 = &Fuel / 8388608
      IF &Batswstate = 0
      {
        V0014 = 10    
      }
      ELSE
      {
        IF L0 < 0.25
        {
          L1 = L0 * 1023
          V0014 = L1 + 60
        }
        ELSE
        {
          V0014 = L0 * 1023
        }
      }
    }
    
    
    Var 0012, name Fuel, Link FSUIPC_IN, Offset $0B94, Length 4     // Right Tank Percentage
    
    
    Var 0014, Link USB_SERVOS, Output 2, PosL 0, PosC 512, PosR 1023
    The values of V0014 are from your code....
    Sure, there is another way to programming (using subroutines to check Batt status), but i have not sufficient information of your setup.
    Regards.
    Horacio.

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



    Join Date
    Jan 2007
    Location
    NEW ZEALAND
    Posts
    908
    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 Codeing help

    Big Thanks Horacio,
    I have yet to try it out on the real gauges but testing SIOC it seems it works
    fine.
    Will let you know tomorrow when i integrate it with the rest of the code.
    Take Care my friend
    Regards
    Les

  6. #6
    500+ This must be a daytime job kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    698
    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 Codeing help

    Hi Guys,

    Here a SIOC best practice:

    If you want to respond to changes in two other variables, you should put your script in a subroutine and call that subroutine from each of these two variable, like this:

    Code:
    Var 10 name Batswstate Link FSUIPC_IN Offset $3102 Length 1     // MASTER BATTERY OFF =0
    {
      CALL DoSomething
    }
    
    
    Var 12, name Fuel Link FSUIPC_IN Offset $0B94 Length 4     // Right Tank Percentage
    {
      CALL DoSomething
    }
    
    Var 9000 Link SUBRUTINE name DoSomething
    {
      // here the SIOC code that uses Batswstate and Fuel to calculate the output to the Servo
    }
    Kind regards.
    Nico Kaan SIOC / How to program
    Last edited by kiek; 11-19-2016 at 04:44 PM.

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



    Join Date
    Jan 2007
    Location
    NEW ZEALAND
    Posts
    908
    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 Codeing help

    Hi Nico,
    Thanks for your comments and appreciate your guidance and i try to use your procedure when i can and will experiment so i can increase my skill level with sioc.


    Horacio: Everything worked like a dream, so thanks again.

    Kindest Regards
    Les
    P.S Had a wee go using Nico's advice and it worked great. I have stored that imformation for later

  8. #8
    150+ Forum Groupie
    Join Date
    Feb 2007
    Location
    Argentina
    Posts
    187
    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 Codeing help

    Nico: That´s the way.... Thanks
    Les: You´re welcome.
    Keep in touch.
    Regards.
    Horacio.