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

    Reversing Servo direction with Sioc

    Hi All,
    Found some code for my Turn Coordinator that works. However its direction is reversed. I know i could dismantle
    the servo and reverse the pot and motor. But i understand it can be done in Sioc.
    Here is the code and can someone tell me how to enclose my code in a seperate window.


    Var 0000, name Startup, Value 1 // Initialization
    {

    &TurnRateservo = 593

    }

    Var 0004, name TurnRateservo, Link USB_SERVOS, Output 2, PosL 163, PosC 593, PosR 1022 // Turn Rate Ind
    Var 0013, name TurnRate, Link FSUIPC_IN, Offset $037C, Length 2
    {
    C0 = TESTBIT &TurnRate ,15
    IF C0
    {
    L1 = 65536 - &TurnRate
    L0 = L1 * 0.2
    }
    ELSE
    {
    L0 = &TurnRate * -0.2
    }
    L0 = L0 + 593
    C0 = L0 < 370
    C1 = L0 > 675
    IF C0
    {
    L0 = 370
    }
    ELSE
    {
    &TurnRateservo = L0
    }
    IF C1
    {
    L0 = 675
    }
    ELSE
    {
    &TurnRateservo = L0
    }
    }





    Thanks
    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: Reversing Servo direction with Sioc

    Les:

    You just have to multiply by -1 somewhere........

    Just change (the red part) and try:

    ........
    L1 = 65536 - &TurnRate

    L0 = L1 * -0.2
    }
    ELSE
    {
    L0 = &TurnRate * 0.2
    }
    ...........





    Complete revisited code:


    Var 0000, name Startup, Value 1 // Initialization
    {

    &TurnRateservo = 593

    }

    Var 0004, name TurnRateservo, Link USB_SERVOS, Output 2, PosL 163, PosC 593, PosR 1022 // Turn Rate Ind
    Var 0013, name TurnRate, Link FSUIPC_IN, Offset $037C, Length 2
    {
    C0 = TESTBIT &TurnRate ,15
    IF C0
    {
    L1 = 65536 - &TurnRate
    L0 = L1 * -0.2
    }
    ELSE
    {
    L0 = &TurnRate * 0.2
    }
    L0 = L0 + 593
    C0 = L0 < 370
    C1 = L0 > 675
    IF C0
    {
    L0 = 370
    }
    ELSE
    {
    &TurnRateservo = L0
    }
    IF C1
    {
    L0 = 675
    }
    ELSE
    {
    &TurnRateservo = L0
    }
    }


    Regards.
    Horacio

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

    Re: Reversing Servo direction with Sioc

    Thanks Horacio,
    The software developer says all you need to do was &TurnRateservo = 1023 - FINAL_VALUE_SERVO. That then screwed up
    my centre value but did reverse it. Readjusted my L1 + 593 and this brought back the center correctly and then it stopped
    turning at 2min in one direction only. I think my problem here maybe to do with the values set in C0 = L0 < 370 and
    C1 = L0 > 675.
    i ran out of time yesterday so will play with those values to day.
    Thanks
    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: Reversing Servo direction with Sioc

    Hi Les:

    As i say in yours other topic (Real Airspeed Gauge Sioc Script Problems), changing one value can screw up all script.
    Reversing servo turn is simple as multiply by -1 in some place.
    Some servos do not work in all values (0-1023).
    So, check first the limits of your servo, check the the value of center position. and make some calculations based in the instructions of the referred topic.
    Regards.
    Horacio.

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

    Re: Reversing Servo direction with Sioc

    Thanks Horacio,
    I took the suggestion from the software developer of SIOC and did this,
    1023 - FINAL_VALUE_SERVO and it worked both times i used it.

    Horacio there is one part of SIOC that i fail to see it working.

    This is the line "PosL 163, PosC 593, PosR 1022

    From what i could take from the description it is supposed to limit the range the Servo makes.
    From my own experience i have never seen it limit the range of the servo. I have had to put limits
    into my Sioc code.
    So do you know exactly what it is supposed to do?.
    Thnaks
    Kindest Regards
    Les

  6. #6
    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: Reversing Servo direction with Sioc

    Les:
    Short of time to make some tests now.
    Give me some days, and I'll give you an answer to your question about meaning of those limits and what is supposed to do.
    Regards.
    Horacio.

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

    Re: Reversing Servo direction with Sioc

    Horacio,
    No hurry as it just a curiosity.
    Les