Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    500+ This must be a daytime job



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

    Sioc,Im Confused,Help

    Hi Guys,
    Im struggling with Sioc,everytime i seem to try things,i take for ever and sometimes i completely bomb out.Here is what im trying to achieve.
    Want to display my remaining fuel in gallons on a lcd display.However Fsuipc returns the value as a percentage.There is also an offset that holds the max capacity of the tank.So with my maths i would take the
    percentage multiply it by tank capacity and divide by 100.
    So i set to write some code as follows(i really dont fully inderstand sioc);

    // **** Fuel Left *****
    var 6030 name fuell Link FSUIPC_IN,offset $0b7c Length 4 // % remaining
    {
    L0 = v6030 / 0.000011920928955078125
    v6032 = L0 / 100
    }
    var 6034 name fuelmax Link FSUIPC_IN,OFFSET $0b80 Length 4 // Tank Capacity
    {
    v6033 = v6034
    }
    Var 6037 name fcalc Value 0
    {
    CALL &Outfuel
    }
    Var 6039 name Outfuel Link Subrutine
    {
    Fuellcd = (here is where im trying to do the maths)
    }


    Var 6001 name Fuellcd // Output to lcd

    Now when i try to say multiply the tank value by the percentage i cant seem to find out how to do this portion.
    I dont even know if what i have written above is correct.
    Any help would be much appreciated.
    Thanks
    Les

  2. #2
    2000+ Poster - Never Leaves the Sim Michael Carter's Avatar
    Join Date
    Oct 2006
    Location
    Southern Illinois, USA
    Posts
    2,881
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    I wish I could help.

    I can't believe I'm going to have to go through this myself in a short time. I dred this.
    Boeing Skunk Works
    Remember...140, 250, and REALLY FAST!

    We don't need no stinkin' ETOPS!



    Powered by FS9 & BOEING

  3. #3
    Boeing 777 Builder


    Kennair's Avatar
    Join Date
    Jan 2007
    Location
    Perth, Western Australia
    Posts
    728
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Don't worry Mike, when you know Nico is around, you know there's help. If nothing but to give you a nudge how to figure it out yourself. He is da master of SIOC code!

    Les, I won't even try to attempt a correct code for you as I don't know anything about the LCD card but it's coding is different to most other OC cards. However you have a friend in Nico (Kiek) as he has his LevelD767 Fuel display to LCD code available to learn from. Have a look HERE and enjoy

    Ken.
    Opencockpits | Aerosim Solutions | Sim-Avionics | P3D | FDS | FTX | AS16 | PPL | Kennair


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



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

    Hi all,
    Thanks for the comments,
    Ken i did have a look at nicos article, but i think he just displays it as a
    percentage.Ive been able to display percentages but when it comes
    something involving multiple processes i get confused.Still im hoping
    someone will help.Thats what i like about this site,someone always
    is looking.
    Rgds
    Les

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

    Quote Originally Posted by iwik View Post
    Hi all,
    but i think he just displays it as a percentage.
    No, I display in kg-tons (with one decimal), see http://www.lekseecon.nl/news.html#news200831

    About your SIOC code:
    I'm afraid, you made a mistake in interpreting offset 0x0b7C. It is an offset indicating the fuel level as % * 128 * 65536, not just a percentage (0 -100).

    Also note that the max capacity of a tank in your aircraft is fixed (if your script is for a certain type of aircraft). You do not need to read it from a FSUIPC offset.

    My approach is to read the level of fuel and to divide it by a value that scales the (default FS tank) to the capacity of a 767 tank, like this:

    Var 2923 name FI_FuelL Link FSUIPC_IN Offset $0B7C Length 4
    {
    L0 = DIV &FI_FuelL 45467
    IF (L0 <> &FuelL)
    {
    &FuelL = L0
    }
    }
    I'll describe the formula behind this scaling factor in a later post.

    You can take this code, and replace 45467 by a value that scales the default FS tank to the tannk of your aircraft (in gallons).

    If you want to have this script work for various aircraft, then you have to read the max capacity of the tank indeed.

    regards,
    Nico

  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

    Okay, here the promised calculation:

    Offset $0Bc7 gives the fuel level in the left wing tank as a "percentage" * 128 * 65536.

    The Level-D left wing tank has a capacity of 18,449 kilo tons.

    To map the FSUIPC "percentage" value to a real value we have to multiply the offset by

    (18,449 / (128 * 65536))

    or (that will give the same result) divide the offset by ((128 * 65536) / 18,449) or 454692

    This will give us kg-tons; in my display I use * 100 kg (and I put a decimal point before the last digit to make it kg-tons) so I divide by 45469 (my sioc code is slighty wrong by dividing by 45467...)

    You will have to find out the capacity of your tank in gallons. You should divide the offset by ((128 * 65536) / your capacity in gallons) = ?
    This will give you gallons.

    I'd recommend to make the SIOC script first fit for 7-segment displays using the DispII card, and if your satified change it to be used at a lcd

    Cheers,
    Nico Kaan
    www.lekseecon.nl

  7. Thanks iwik thanked for this post
  8. #7
    500+ This must be a daytime job



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

    Hi Nico,
    Thanks for the explanation,i dont think i made myself clear.I had been able
    to get my Gallons displayed.But i am wanting to show Fuel remaining on
    Any aircraft i am flying and therefore will have to read the offset that stores the Max capacity.This is where im having trouble.What i wanted to do was to multiply the pecentage by the max tank offset value.
    How does one take this value and mutiply it by the %.In other words if
    the values (% and Max cap) are in two vaiables how is this done.I cant see to find any logic that will do this.
    Please bear with me as im really trying to get a handle on Sioc.When you get in your latter years the brain doesnt work well,at least mine doesnt.
    Les

  9. #8
    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

    Hi Les,

    Okay, no problem.

    See Config_sioc, Help, Help, Scripts Language ..

    Here is the basic schema, you only may have to do some math.

    The basis idea behind SIOC is that the statements in the body (between curly braces) are (only) executed if the value of the Var changes.... (!)

    In this example if Var 1 (the percentage) changes, subroutine Calc is called and also if Var 2 changes Calc is called. So you are always up to date.


    var 1 Link FSUIPC_IN,offset $0b7c Length 4 // % remaining
    {
    CALL &Calc
    }

    var 2 Link FSUIPC_IN,OFFSET $0b80 Length 4 // Tank Capacity
    {
    Call &Calc
    }

    Var 3 name Calc Link SUBRUTINE
    {
    v4 = v1 * v2
    }

    Var 4 name Fuel
    {
    CALL &OutFuel
    }

    Regards,
    Nico

  10. #9
    500+ This must be a daytime job



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

    Hi Nico,
    Thanks for imfo,i think im slowly getting the hang of it.Been able to display
    Gallons,but not parts of gallons.Suppose thats not so important but would be curious how to do this.My tanks have capcity under 100 gallons.Would be good if i could display say 56.7 gallons.
    Rgds
    Les

  11. #10
    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

    Quote Originally Posted by iwik View Post
    Hi Nico,
    My tanks have capcity under 100 gallons.
    Do you really mean 100 gallons or 100.000 gallons?

    You can only display information that you have available. Suppose you have a value in gallons and you want to display gallons, then you have no info about something to put behind a decimal point.

    But if you have available the amount in gallons and you want to display in tons of gallons with one decimal value, you should first divide your gallons by 100 (to get gallons * 100), and then you display this value and you put a decimal point before the least significant digit.

    Example:
    Suppose you have 56743 gallons
    Divide by 100 makes 567 (*100) gallons
    Write this to a 4 digit display: 0567
    and make sure that the DP of digit 6 is on, so it shows 056.7 (*1000) gallons.
    A full tank would show 100.0

    Rgrds,
    Nico
    nico

Page 1 of 2 12 LastLast

Similar Threads

  1. Hi, Rob here, a bit confused...
    By LancasterBob in forum Welcome to MyCockpit New here? Introduce Yourself!
    Replies: 1
    Last Post: 10-18-2010, 05:33 PM
  2. Really confused!!
    By mondo50m in forum General Builder Questions All Aircraft Types
    Replies: 1
    Last Post: 01-05-2010, 01:15 PM
  3. confused
    By mrdon in forum Welcome to MyCockpit New here? Introduce Yourself!
    Replies: 6
    Last Post: 10-26-2007, 10:26 PM
  4. so confused
    By twin50 in forum I/O Interfacing Hardware and Software
    Replies: 6
    Last Post: 10-01-2007, 01:05 PM