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



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

    Angry Real Airspeed Gauge Sioc Script Problems

    Hi Guys,
    Been tearing my hair out trying to drive the above Real Gauge from o/c servo card.
    Segments are not linear. Im nearly there but my programming skills suck.
    Appreciate someone pointing out where i am wrong and hopefully correcting it, cause im
    totally stuffed.
    Here is the problem:
    1. The gauge does not start to move off 0 when gauge in FSX starts. It will when FSX gets to 40 knots and both will display the same.
    2. Second problem is that when FSX shows 50 knots real gauge shows 42 and IOCP console only shows 125 (see code for chart)
    and then at 51 will suddenly jump to 50 knots which is 194 ( correct for 50 knots). From then onwards the two gauges track Accurately
    all the way to 140(gauge max).
    So it only appears to be up to 50knots. Sorry about not putting code in quotes as i cant remember how.
    Here is the code and appreciate much help.
    Thanks
    Les
    [// *****************************************************************************
    // * Config_SIOC ver 3.7B1 - By Manolo Vélez - www.opencockpits.com
    // *****************************************************************************
    // * FileName : jias.txt
    // * Date : 3/21/2016

    // Gauge Servo Value

    // 0 0
    // 40 115
    // 50 194
    // 60 281
    // 80 480
    // 100 672
    // 120 857
    // 140 1023


    Var 0002, name IAS_Servo, Link USB_SERVOS, Output 3, PosL 0, PosC 562, PosR 988, Type 2 // IAS Servo Instrument

    Var 0001, name IAS, Link FSUIPC_IN, Offset $02BC, Length 4 // IAS from SIM
    {
    L0 = &IAS / 128 // FSUIPC Conversion Airspeed IAS
    L0 = ABS L0 // L0 not signed
    L2 = L0


    IF L0 <= 40 // First sector
    {
    L1 = L2 * 2.875 // 115 steps/40 values = 2.875
    }
    ELSE // Is a greater value
    {
    L2 = L0 - 40 // L2 ONLY VALUES FOR NEXT SECTOR
    IF L0 <= 50 // Second Sector
    {
    L1 = L2 * 7.9 // 79 STEPS/10 VALUES = 7.9
    L1 = L2 + 115 // ADD OTHER SECTOR STEPS
    }
    ELSE
    {
    L2 = L0 - 50 // L2 ONLY HAVE VALUES FOR NEXT SECTOR
    IF L0 <= 60 // THIRD SECTOR
    {
    L1 = L2 * 8.7 // 87 STEPS / 10 VALUES
    L1 = L1 + 194 // ADD PREVIOUS STEPS
    }
    ELSE // Out of range
    {
    L2 = L0 - 60 // ONLY VALUES FOR NEXT SECTOR
    IF L0 <= 80 // SECTOR 4
    {
    L1 = L2 * 9.95 // 199 STEPS / 20 VALUES = 9.95
    L1 = L1 + 281
    }
    ELSE
    {
    L2 = L0 - 80 // ONLY VALUE FOR NEXT XECTOR
    IF L0 <= 100 // SECTOR 5
    {
    L1 = L2 * 9.6 // 192 STEPS / 20 VALUES = 9.6
    L1 = L1 + 480
    }
    ELSE
    {
    L2 = L0 - 100 // ONLY VALUES FOR NEXT SECTOR
    IF L0 <= 120 // SECTOR 6
    {
    L1 = L2 * 9.25 // 185 STEPS / 20 VALUES = 9.25
    L1 = L1 + 672 // ADD PREVIOUS STEPS
    }
    ELSE
    {
    L2 = L0 - 120
    IF L0 <= 140 // SECTOR 7
    {
    L1 = L2 * 8.3 // 166/20
    L1 = L1 + 857
    }
    ELSE
    {
    L1 = 1023 // max position of gage
    }
    }
    }
    }
    }
    }
    &IAS_Servo = 0 + L1 // Add to minimum (0)
    }
    }
    ]
    Attached Files Attached Files

  2. #2
    150+ Forum Groupie
    Join Date
    Feb 2007
    Location
    Argentina
    Posts
    204
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Real Airspeed Gauge Sioc Script Problems

    I´m short of time now, but
    First:
    in line:

    Var 0002, name IAS_Servo, Link USB_SERVOS, Output 3, PosL 0, PosC 562, PosR 988, Type 2 // IAS Servo Instrument

    you have limited the servo range from 0 to 988 max, with center in 562.
    How do you arrive to that?.

    Second:
    I presume you have a geared needle to reach more that 180º, yes or not?

    Third:
    Can you post a graphic or photo of the gauge and details of the mechanism moving the needle? This would help to understand and help you to set the instrument.

    Fourth:
    In teory, USBServoCard send 0 to 1024, but in real life, the real range depends of the servo used (even same model o brand).
    Some of my servos works between 150 or 175 to 1000 or 1023 in some. (never down 125 to 0)...

    You need to start SIOC, and use Sioc Monitor on USBServoCard to check the limits of your servo. (Page 6 and 7 of USBServoManual).

    http://www.opencockpits.com/uploads/...V2_English.pdf

    With SIOC Monitor, moving the slider of the right servo under test, you can know what value corresponds exactly with every value in the scale of the gauge. (and to know what´s the real limits of your servo, hearing when a forced or vibrating motor is not moving anymore)
    A you say, your servo only responds after 125 (that´s seems the low limit).
    The simple solution is to move physically the gauge to 0 (detaching and attach again) when the servo is in 125 or better 130 and make again all the calculations, like:

    If Airspeed is 0, servo is 125
    If Airspeed is<= 40, servo is 125+Airspeed*scale value

    But how i say first. a great help will be a graphics or photo of your gauge and construction´s details.

    Keep in touch.
    And sorry if my english its no good.
    Regards.
    Horacio

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



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

    Re: Real Airspeed Gauge Sioc Script Problems

    Hi Horacio,
    Thanks for replying.
    !. I have adjusted these values but have found it to have no affect on the servo, so do not understand what they really do.
    2. My gauge is DC driven by a PWM to DC converter.
    3. The table shown above has the left column showing the Gauge face Knots marks and the right column the Servo value
    for these positions from Iocards test
    4. the range is 0 to 1023. Zero when meter starts moving to 1023 at 140Knots

    The problem is that 1. There is no output from sioc to the servo till 40 Knots is reached( SIOC monitor shows 0).
    2. Once 40 knots is reached sioc now send 115 to servo and gauge moves to 40 knots, now increasing the speed this
    value now increases slowly with the gauge needle increasing till sioc monitor shows 125 (gauge will show about 42 Knots)
    With the next increase in speed the meter will jump to 50 knots and sioc shows 194(correct value).
    From here on increasing the speed and the gauge tracks accurately.
    So you can see there is something in the code that is causing this jump. Also some thing else disabling output to the
    Servo from 0 to 40 knots.
    Hope this is a bit clearer.
    Thnaks
    Les

  4. #4
    150+ Forum Groupie
    Join Date
    Feb 2007
    Location
    Argentina
    Posts
    204
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Real Airspeed Gauge Sioc Script Problems

    Ok. understood now and testing.
    Yes, there is a trouble in your script.
    Let me see and give me some time to help you.
    Regards.
    Horacio.

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



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

    Re: Real Airspeed Gauge Sioc Script Problems

    Thanks Horacio, no hurry as i am stumped. All help appreciated.
    Regards
    Les

  6. #6
    150+ Forum Groupie
    Join Date
    Feb 2007
    Location
    Argentina
    Posts
    204
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Real Airspeed Gauge Sioc Script Problems

    Ok.
    You have version 3.7B1 of SIOC, mine is 5.1, but there should be no problem.
    My programming is from another point of view...
    Anyway, there are two scripts called Airspeed Corrected ..(one labeled 37b1 without DIV function, and other labeled 51 with DIV function). (i don´t remember if DIV function is implemented in SIOC 37b1....)
    Try Airspeed corrected 51.txt first, if any problem, try Airspeed corrected 37b1.txt
    Let me know if works. (at least in my console, all is working ok).

    Regards.
    Horacio.
    Attached Files Attached Files

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



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

    Re: Real Airspeed Gauge Sioc Script Problems

    Hi Horacia,
    Thanks very much for your effort. It works quite good but here is the problem i am having:
    Running your script as published and the gauge runs smoothly but slightly out compared to fSX. The plane i test with
    has the ability to read digitally the airspeed.
    I then try to adjust accuracy with the scaling factor and find that it has to be increased in the example of 0 - 40 from
    2.875 to 3.2. However when this is changed and we start from 0 speed and get to 40 all is ok then with the next speed
    increase the needle will flick back slightly then move to correct position. Observing SIOC monitor and the the value
    displayed reduces by about 15. Similar behaviour exists up to about 80 and above this changing the scale does affect
    these change over points.
    I am wondering if it has to do with those values where you have L1- ect. Where did you get those figures from?.
    To summarize, if i dont alter your script then it works quite well but has some inaccuracy between 0 and 80. Altering the scale factor make the transition
    between lower sectors sectors jumpy.
    By the way i had to use the version with the DIV removed as this caused the values sent to the servo to increment by 2.
    Be very interested in your comments and again a big Thank You.
    Regards
    Les

  8. #8
    150+ Forum Groupie
    Join Date
    Feb 2007
    Location
    Argentina
    Posts
    204
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Real Airspeed Gauge Sioc Script Problems

    Les:

    LONG LONG LONG POST............

    You cannot change the scaling factor without changing the other values in the script.
    The script sent was calculated with your data:

    // Gauge Servo Value
    // 0 0
    // 40 115
    // 50 194
    // 60 281
    // 80 480
    // 100 672
    // 120 857
    // 140 1023


    There are two approachs to make the script. Let´s see one first.
    Go to:
    http://ps://www.mathsisfun.com/strai...calculate.html

    Fill the values in the page:
    Example:
    Making
    X=GAUGE VALUES
    Y= SERVO VALUES

    For the first part
    X1=0 Y1=0
    X2=40 Y2=115
    You get Y=2.875X (Warning. only valid from 0 to 40)

    Second part:
    X1=40 Y1=115
    X2=50 Y2=194
    You get Y=7.9X-201 (Warning. Only valid from 40 to 50)

    and go on....... (you can see how the values are used in the script)

    As you see, we are broken in straight line segments and calculating a formula in every sector from a pair of points. (Straight line formula)


    But in the real life, this approach not always correspond with your instrument.
    Why? Because we are interpolating the values between two points. (we are estimating a lineal response for the intermediate points, but if the instrument is logarithmic?)
    For better response, we need more data (example, every 5 knots or less).
    Another reasons are:
    We never have the same reading at same point (example 40=115) Sometimes 40=112 or 40=118. This is servo jittering problem, and this is a big trouble.
    And SIOC works changing in this way: if we have IAS= x for x changing from 0.0 to 0.9
    0.0= 0 IAS
    0.1= 0 IAS
    0.2= 0 IAS
    0.3= 0 IAS
    0.4= 1 IAS (can you see the change... must be 1 when x=0.5)
    0.5= 1 IAS
    0.6= 1 IAS
    0.7= 1 IAS
    0.8= 1 IAS
    0.9= 1 IAS
    That´s: SIOC has a little different value from the value displayed in screen of Flight Simulator.
    Anyway, this different value is negligible, but add the jittering and you have a difference.
    And sometimes, the IOCARD Test values not correspond with the values calculated by SIOC.
    (I have the same problem with my IAS, VSI, Turn Coordinator, etc, builded with Hitec Servos)

    The other approach, is inverting the values in the formula,
    using
    X = Servo Value
    and
    Y= Gauge
    All the values changes: Example from 0 to 40, you have:
    y=0.34782608695652173x (yes... not practical).

    So, try to get more values, make some adjust, but remember, if you change one value of the script (scaling factor for example) you must change the substracted values too.
    And last: Every IAS Knots under 40 its not accurate ever in real planes ( I´m pilot in real life).
    If this is confusing for you, make some measurements again, but every 5 knots, and re-check the servo values. (sometimes values from 0 to 1023 are different if you calculate backwards from 1023 to 0).
    Send me the new values and I can correct the script for you.
    Regards.
    Horacio.
    Attached Images Attached Images

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



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

    Re: Real Airspeed Gauge Sioc Script Problems

    Thanks Horacio,
    Your explanation is brilliant and i will take time to digest it. Will attempt to fix it myself and will update you. If i am desperate i will make a list at 5 knot intervals.
    Yes i realized that below 40 would not be accurate but wanted to get the needle moving and
    have it accurate from 40 on wards.
    Your time and effort is very much appreciated and i'm sure others will get something as well.
    Regards
    Les
    P.S I have had look at the maths, my brains buzzing so will get you some values and may
    be able to understand more then.

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



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

    Re: Real Airspeed Gauge Sioc Script Problems

    Hi Horacio,
    Thanks very much for all your help and detailed explanation. I have had 100% satisfaction thanks to your link,explanation
    and a little research. I used your values to confirm i was doing things right then put my new values in and it
    works great.
    Take Care my friend.
    Regards
    Les
    P.S Have sent you a PM.

Page 1 of 2 12 LastLast