Results 1 to 9 of 9
  1. #1
    10+ Posting Member
    Join Date
    Nov 2012
    Location
    Netherlands
    Posts
    19
    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

    Hello Nico,

    I allready posted this thread in Open cockpits section of Mycockpit, but didn't get an answer. Maybe you can help me.... At least I hope...

    For a friend of mine (having a A320 cockpit that he is rebuilding for interfacing with Opencockpits and Sioc) 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...

    Do you have a clue on this?

    Kind regards,
    Kees Schroijen

  2. #2
    2000+ Poster - Never Leaves the Sim kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    2,202
    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

    Hello Kees,
    Why are you not using the COMM1 offset in FSUIPC directly, like this:

    Code:
    //  An implementation of a COMM1 radio, consisting of:
    //
    //      1 dual rotary encoder controlling the frequency
    //      five 7-segment displays for the frequency  
    //          - software controlled Decimal Point via an Output
    
    
    
    
    Var 8600 name FI_COMM1Freq Link FSUIPC_IN Offset $034ELength 2    
    {
      L0 = FROMBCD &FI_COMM1Freq
      &COMM1Freq = L0
      &COMM1FreqHigh = DIV L0 100
      &COMM1FreqLow = MOD L0 100
      CALL &OutCOMM1Freq               // display new freq value 
    }
    
    
    Var 8610 name COMM1FreqLow
    Var 8611 name COMM1FreqHigh
    Var 8612 name COMM1Freq
    
    
    Var 8613 name CalcCOMM1Freq Link SUBRUTINE
    {
      L0 = &COMM1FreqHigh * 100          // high * 100 
      &COMM1Freq = L0 + &COMM1FreqLow    // + low 
      &FO_COMM1Freq = TOBCD &COMM1Freq   // BCD value to panel 
      CALL &OutCOMM1Freq                 // display new freq value 
    }
    
    
    Var 8620 name OutCOMM1Freq Link SUBRUTINE  
    {
       &D_COMM1Freq = &COMM1Freq + 10000    // to display + '1'
       &O_COMM1DP = 1  
    }
    
    
    Var 8640 name RO_COMM1FL Link IOCARD_ENCODER  Input 59 Aceleration 1 Type 2     
    {
      L0 = &RO_COMM1FL * 5     
      &COMM1FreqLow = ROTATE 0 99 L0
      CALL &CalcCOMM1Freq     
    }
    
    
    Var 8641 name RO_COMM1FH Link IOCARD_ENCODER  Input 57 Aceleration 1 Type 2     
    {
      L0 = &RO_COMM1FH      
      &COMM1FreqHigh = ROTATE 8 35 L0
      CALL &CalcCOMM1Freq     
    }
    
    
    Var 8670 name D_COMM1Freq Link IOCARD_DISPLAY  Digit 20 Numbers 5  
    Var 8680 name O_COMM1DP Link IOCARD_OUT  Output 96    
    Var 8699 name FO_COMM1Freq Link FSUIPC_OUT Offset $034E Length 2
    Groeten,
    Nico

  3. #3
    10+ Posting Member
    Join Date
    Nov 2012
    Location
    Netherlands
    Posts
    19
    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,

    Thank you for your answer.

    The reason I use the virtual joysticks in stead of the COMM1 offset is that I would make an easy script that my friend could change himself for all the rotaries he uses. So also for the HDG, VS etc. Thereby, he doesn't have the 7-segment displays, so there is no need for outputs.
    In his old situation he allready uses mouse macro's assigned to his old rotaries. Now he wants to use these mouse macro's with the OC rotaries. So using the virtual joysticks he can assign a button of that virtual joystick to his mouse macro's.

    The script I wrote above, is working with this way, but the problem seems to be that Sioc doesnt notice a 'button release' with the rotaries.

    I allready tried to add a line with:
    V158 = 0

    To simulate a button release, but that didn't work.

    If there is no way to solve this, I will think of the way of writing/reading direct to the offsets. But in tha case, i have to write all his scripts and i have no time anymore to work on my own 767 cockpit .

    Groeten,
    Kees

  4. #4
    2000+ Poster - Never Leaves the Sim kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    2,202
    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 Kees,
    Aha I see.

    Quote Originally Posted by kees69 View Post
    But in tha case, i have to write all his scripts and i have no time anymore to work on my own 767 cockpit .
    Yeah that would be a pity, no progress to show at the next FSWeekend

    You have to modify the script such that setbits and clearbits come in sequence. Setting a bit twice (or more) has no effect at the joystick.
    This is how I would do it. Have not tried it yet, but I think it will work...

    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
    gr,
    Nico

  5. Thanks KLM366 thanked for this post
  6. #5
    New Member
    Join Date
    Nov 2012
    Location
    Netherlands
    Posts
    8
    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 7 Mjoy's to connect the more than 200 buttons and switches in my Airbuscockpit (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

  7. #6
    New Member
    Join Date
    Nov 2012
    Location
    Netherlands
    Posts
    8
    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

  8. #7
    New Member
    Join Date
    Nov 2012
    Location
    Netherlands
    Posts
    8
    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

  9. #8
    10+ Posting Member
    Join Date
    Nov 2012
    Location
    Netherlands
    Posts
    19
    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,

    Paul (the friend where i was writing this for) was also reading the forum and did read your answer. He tried it and it worked. He is very happy now . He would reply to you, but since he is no forum member, he couldn't. So he asked me to thank you very much for your help. So hereby...

    And i want also thank you for your help, so now i can go on with my 767... And you will of course see the progress in november.

    I studied your code and now i understand what i was doing wrong, correct me if i am wrong. Turning the encoder to the right, did set BIT 5, but turning further to the right again Set BIT 5 which was already set and so FSUIPC didnt notice a new button press. Only when i turned to the left, BIT 5 was cleared. Of course so stupid of me that i didn't thought of that...

    So we see, we are never too old to learn!

    Groeten,
    kees

  10. #9
    2000+ Poster - Never Leaves the Sim kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    2,202
    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

    Dag Paul,
    Quote Originally Posted by KLM366 View Post
    Hartstikke bedankt (as they say in Dutch
    Graag gedaan, en veel plezier met je cockpit!
    Nico