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

    Flap Position Indicator Code

    Hi Guys,
    Been trying to get Code to opearate corectly. Its for a Cessna and has o 10 20 and 30
    degree steps. With the following code it works with one exception.
    When the Indicator moves from 20 to 30 degrees or 30 to 20 the servo seems to speed up . Looking at the Fsuipc value when its showing 8192 its at 20 but as it passes thru
    i think it appears to be a slight delay the the servo operates and moves at the correct speed until 30 is reached. Its almost as though when you just pass thru this 8192
    its not seeing any change then it sees it and catches up ie increase in speed.
    0 to 10 to 20 degrees either up or down is fine.
    Appreciate anyones help to see where ive gone wrong.
    Here is the code;

    //
    *******************************************************************
    **********
    // * Config_SIOC ver 3.4 - By Manolo Vélez - www.opencockpits.com
    //
    *******************************************************************
    **********
    // * FileName : sioc.txt
    // * Date : 04/06/2011

    Var 0030, Link FSUIPC_INOUT, Offset $0BE0, Length 4 // Flap
    Position
    {
    L0 = V0030
    L0 = ABS L0
    L2 = L0
    IF L0 <= 5461
    {
    L1 = L2 * 0.0325
    }
    ELSE
    {
    L2 = L0 - 5461
    IF L0 <= 8192
    {
    L1 = L2 * 0.044
    L1 = L1 + 178
    }
    ELSE
    {
    L2 = L0 - 8192
    IF L0 <= 16383
    {
    L1 = L2 * 0.0415
    L1 = L1 + 536
    }
    }
    }
    &FlapPosServo = L1 + 72
    }
    Var 0001, name FlapPosServo, Link USB_SERVOS, Device 0, Output 1,
    PosL 1, PosC 512, PosR 1023 // FLAP INDICATOR

    Thanks
    Les

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



    Join Date
    Jul 2013
    Posts
    917
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Flap Position Indicator Code

    Les

    I do not see anything wrong with your code. The only thing that I can think of is that the servo ramp calculations are "interrupting" the smooth movement, though this seems highly unlikely

    I attach a working code for the 737, though of course you will need to remove the LED outputs, change the servo and flap value/number of positions. Might be worth a try as it works smoothly on my machine.

    Code:
    Var 0095, name LE_EXT_LED, Link IOCARD_OUT, Output 41 
    
    Var 0096, name LE_TRANS_LED, Link IOCARD_OUT, Output 39 
    
    Var 0099, name FLAPS_IN, Link FSUIPC_INOUT, Offset $0BE0, Length 4 
    { 
    L0 = &FLAPS_IN 
    L0 = ABS L0 
    L2 = L0 
    IF L0 < 10 
    { 
    &LE_EXT_LED = 0 
    &LE_TRANS_LED = 0 
    } 
    C0 = L0 >= 10 
    C1 = L0 <= 408 
    IF C0 AND C1 
    { 
    &LE_TRANS_LED = 1 
    &LE_EXT_LED = 0 
    } 
    IF L0 > 408 
    { 
    C0 = L0 > 2049 
    C1 = L0 < 4095 
    IF C0 AND C1 
    { 
    &LE_TRANS_LED = 1 
    &LE_EXT_LED = 0 
    } 
    ELSE 
    { 
    &LE_TRANS_LED = 0 
    &LE_EXT_LED = 1 
    } 
    } 
    C0 = L0 >= 0 
    C1 = L0 <= 409 
    IF C0 AND C1 
    { 
    &x1 = 0 // between 0 and 1 
    &x2 = 409 
    &y1 = 1023 
    &y2 = 950 
    } 
    C0 = L0 >= 409 
    C1 = L0 <= 819 
    IF C0 AND C1 
    { 
    &x1 = 409 
    &x2 = 819 
    &y1 = 950 
    &y2 = 760 // between 1 and 2 
    } 
    C0 = L0 >= 819 
    C1 = L0 <= 2047 
    IF C0 AND C1 
    { 
    &x1 = 819 
    &x2 = 2047 
    &y1 = 760 
    &y2 = 650 // between 2 and 5 
    } 
    C0 = L0 >= 2047 
    C1 = L0 <= 4095 
    IF C0 AND C1 
    { 
    &x1 = 2047 
    &x2 = 4095 
    &y1 = 650 
    &y2 = 500 // between 5 and 10 
    } 
    C0 = L0 >= 4095 
    C1 = L0 <= 6143 
    IF C0 AND C1 
    { 
    &x1 = 4095 
    &x2 = 6143 
    &y1 = 500 
    &y2 = 400 // between 10 and 15 
    } 
    C0 = L0 >= 6143 
    C1 = L0 <= 10239 
    IF C0 AND C1 
    { 
    &x1 = 6143 
    &x2 = 10239 
    &y1 = 400 
    &y2 = 300 // between 15 and 25 
    } 
    C0 = L0 >= 10239 
    C1 = L0 <= 12287 
    IF C0 AND C1 
    { 
    &x1 = 10239 
    &x2 = 12287 
    &y1 = 300 
    &y2 = 220 // between 25 and 30 
    } 
    C0 = L0 >= 12287 
    C1 = L0 <= 16383 
    IF C0 AND C1 
    { 
    &x1 = 12287 
    &x2 = 16383 
    &y1 = 220 
    &y2 = 179 // between 30 and 40 
    } 
    &dy21 = &y2 - &y1 
    &dx21 = &x2 - &x1 
    &dx = L0 - &x1 
    &dy = &dy21 * &dx 
    &dy = &dy / &dx21 
    L1 = &y1 + &dy 
    &FLAPSERVO = L1 
    } 
    
    Var 0086, name dy 
    
    Var 0087, name dx21 
    
    Var 0088, name dy21 
    
    Var 0089, name dx 
    
    Var 0090, name x1 
    
    Var 0091, name x2 
    
    Var 0092, name y1 
    
    Var 0093, name y2
    
    var 0022, name FLAPSERVO, Link USB_SERVOS,Output 1, POSL 177, POSC 512, POSR 1024

  3. Thanks iwik thanked for this post
  4. #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: Flap Position Indicator Code

    David,
    Thanks for comments which are valued. After posting i hacked o/c code which ended up like yours and worked liked the one listed with this anomaly.
    Further investigation, now think what im seeing is normal. You us ethe 737 and have degree settings of 0 1 2 5 10 ect. Looking at the gauge in the default
    737 it can be seen to move thru 1 2 and 5 quicker than the rest. So changes in speed of servo not really noticeable. In my case i go from 0 to 10 degrees and so the degree diff is much greater and hence speed of servo will be more noticeable. I cant be sure about this unless i came across some one trying to do what i am doing. Others are using Simkits and they of course have their own code.
    This effect is not really a problem as it is very quick occurence, maybe i could add afew more dummy positions to fine up up the resolution.
    Regards
    Les

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



    Join Date
    Jul 2013
    Posts
    917
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Flap Position Indicator Code

    Les

    Thanks for the update and I think your conclusion is logical. A few more dummy positions or a DELAY factor could evem out the speed

    Regards

    David

  6. #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: Flap Position Indicator Code

    Take Care
    Les