Results 1 to 4 of 4
  1. #1
    New Member
    Join Date
    Nov 2012
    Location
    Netherlands
    Posts
    1
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Rotary encoder and FSUIPC

    For a friend of mine i try to write a little script that can turn the COM frequency by using a gray type rotary encorder of open cockpits. The script should see in which directory the encoder is turning. If it is turning left, it should generate an other button in FSUIPC then when turning right. I use the virtual Joystick in FSUPIC at the offset $3343.
    Now i did write this script:
    Var 158 Link IOCARD_ENCODER Input 1 Aceleration 1 Type 2 // input 52 voor Paul
    {
    L0 = v158
    IF L0 > 0
    {
    &COM1 = setBIT 5 // set bit 5 of joystick COM1 incr
    &COM1 = CLEARBIT 6 // clear bit 6 of joystick
    }
    ELSE
    {
    &COM1 = setBIT 6 // set bit 6 of joystick COM1 decr
    &COM1 = CLEARBIT 5 // clear bit 5 of joystick
    }
    }

    Var 160 name COM1 Link FSUIPC_OUT Offset $3343 Length 4
    The script works fine. According to the direction of the encoder, another button in FSUIPC is activated. But The problem is that it will not repeat that button when I keep turning the encoder in the same direction.

    eg. If the COM = 120.25 and I turn the encoder to the right, it becomes 121.25. But it doesn't go further. Now when I turn the encoder to the left it goes back to 120.25, but again not further...

    Does anybody have a clue on this?

    Kind regards,
    Kees Schroijen

  2. #2
    75+ Posting Member HansJansen's Avatar
    Join Date
    Jan 2007
    Location
    Nuenen, The Netherlands
    Posts
    81
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Rotary encoder and FSUIPC

    Kees,

    You'll have to set the activated input back to 0, else the Master card thinks you are holding the switch and will not send new data to the software. Maybe you'll have to delay the resetting for a while; if it follows too quickly on the setting action the software may not see it.

    I am not familiar with your setup, so I cannot give more precise instructions, but I think you should be able to find out for yourself now. Otherwise, take a peek at www.lekseecon.nl, Nico Kaan's excellent site; he gives a number of examples for programming SIOC scripts.

    Good luck!
    Hans

  3. #3
    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: Rotary encoder and FSUIPC

    Code:
    Var 156 name GreaterState value 0
    Var 157 name LessState value 0
    
    
    Var 158 Link IOCARD_ENCODER Input 1 Aceleration 1 Type 2 // input 52 voor Paul
    { 
      L0 = v158 
      IF L0 > 0
      {
        IF &GreaterState = 0
        {
          &COM1 = SETBIT 5   //  joystick COM1 incr
        } 
        ELSE
        {
          &COM1 = CLEARBIT 5  // joystick COM1 incr
        }
        &GreaterState = CHANGEBITN 0 &GreaterState  // toggle state (from 0 to 1 or from 1 to 0)
      }
      ELSE
      {
        IF &LessState = 0
        {
          &COM1 = SETBIT 6   // joystick COM1 decr
        } 
        ELSE
        {
          &COM1 = CLEARBIT 6  // joystick COM1 decr
        }
        &LessState = CHANGEBITN 0 &LessState  // toggle state (from 0 to 1 or from 1 to 0)
      }
    }
    
    
    Var 160 name COM1 Link FSUIPC_OUT Offset $3343 Length 4
    Nico

  4. #4
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    Nov 2012
    Location
    Netherlands
    Posts
    5
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Rotary encoder and FSUIPC

    Hi Nico,

    I am the A320 cockpit builder who Kees is asking the question for and Kees informed me that he posted the request here.
    Today I checked the forum and I saw your script.
    Ofcourse I tried it and it works !!

    Until now I used Mjoy's (a printed circuit developed by Mindaugas, that is recognized as joystick), but they are rather unstable and frequently give wrong indications.

    At the advice of Kees I switched to OC and that is much more reliable and stable indeed.
    I will now connect all Autopilot rotaries via Gray encoders and use your script.

    Hartstikke bedankt (as they say in Dutch

    KLM366