Results 1 to 2 of 2

Thread: encoder in SIOC

  1. #1
    10+ Posting Member
    Join Date
    Aug 2009
    Location
    Netherlands
    Posts
    18
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    encoder in SIOC

    Hi again,

    David helped me out with my problem showing heading on my sim-avionics.

    Now I have the following problem:

    I have a SIOC script to change my heading.
    The goal of this script is only to change the heading bug on my virtual cockpit in FSX.

    I have a CTS288 grey encoder from opencockpits, connected on the mastercard inputs 3 and 4 (and gnd off course)
    When I look at the Controlador software, and turn the encoder I see:
    RIGHT: 004 -> 003-004 -> 003 -> empty
    LEFT: 003 -> 003-004 -> 004 -> empty

    I think that is good?!

    My script is:

    Code:
    Var 1, name X_HDG, Link FSUIPC_INOUT, Offset $07CC, Length 2 
    { 
    // convert from fsuipc range to degrees: 
    L0 = DIV &X_HDG, 182 
    IF &HDG != L0 
    { 
    &HDG = L0 
    } 
    } 
    
    
    Var 2, name HDG 
    { 
    CALL &OutHDG 
    } 
    
    Var 3, name OutHDG, Link SUBRUTINE 
    { 
    // convert from degrees to fsuipc range: 
    L0 = &HDG * 182 
    IF &X_HDG != L0 
    { 
    	&X_HDG = L0 
    } 
    } 
    
    Var 4, name RO_HDG, Link IOCARD_ENCODER, Input 3, Aceleration 4 Type 2 
    { 
    L0 = &RO_HDG // * -1 turning right should be plus 
    &HDG = ROTATE 0, 359, L0 
    }
    Now in FS, when I turn the button to the right...
    I see the heading bug move one degree to the right and immediately one to the left (for example 342 and instantly 341 again).
    When I turn the encoder fast, it moves to the right, but very shaking and nog very well.

    I changed the input number to 1 (that is my altitude encoder), the same happens, So I don't think it is a problem with the encoder.

    Is there something wrong with my code?

    Thanks again,
    Steef

  2. #2
    10+ Posting Member
    Join Date
    Aug 2009
    Location
    Netherlands
    Posts
    18
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: encoder in SIOC

    I was looking for the solution for about two days now..

    Kept looking and found the solution!!

    On: http://www.kennair.com.au/downloads/SIOC/Pedestal.txt

    I now have the code cut from this:

    Code:
    Var 2000, Value 0  //  Initialization
    {
    &D_HDG = 360
    }
    
    Var 2004, Link FSUIPC_INOUT, Offset $07C8, Length 4 // AP_HDG_SEL
    {
      IF V2004 = 1
      {
        &O_HDGSEL = 1
      }
      ELSE
      {
        &O_HDGSEL = 0
      }
    }
    
    Var 2005, name APD_HDG, Link FSUIPC_INOUT, Offset $07CC, Length 2 // APD_HDG
    
    Var 2104, name D_HDG, Link IOCARD_DISPLAY, DEVICE 1, Digit 6, Numbers 3
    {
      L1 = &D_HDG * 182.04444
      L0 = L1 + 1
      &APD_HDG = L0
    }
    
    Var 2212, name O_HDGSEL, Link IOCARD_OUT, DEVICE 1, Output 26
    
    
    
    Var 2306, name E_HDG, Link IOCARD_ENCODER, Input 3, Aceleration 4, Type 2
    {
      L0 = &E_HDG // * -1
      &D_HDG = ROTATE 1, 360, L0
    }
    
    
    Var 2426, name I_HDGSEL, Link IOCARD_SW, DEVICE 1, Input 28
    {
      IF &I_HDGSEL = 1
      {
        IF V2004 <> 1
        {
          V2004 = 1
        }
        ELSE
        {
          V2004 = 0
        }
      }
    }
    And works perfect!!!

    Maybe I can help soneone with this, thanks anyway

Similar Threads

  1. Encoder Help
    By CessnaGuy in forum General Aviation (GA) Builder Disccusion
    Replies: 5
    Last Post: 04-20-2011, 05:03 AM
  2. Dual Rotary Encoder in SIOC
    By 737dragon in forum OpenCockpits General Discussion
    Replies: 0
    Last Post: 09-13-2010, 05:01 AM
  3. Turning a Rotary encoder with a pushbutton into a dual rotary encoder
    By snizbatch in forum I/O Interfacing Hardware and Software
    Replies: 2
    Last Post: 05-11-2009, 02:57 AM
  4. Encoder
    By Andras in forum FS2Phidget Users
    Replies: 5
    Last Post: 12-13-2004, 08:03 PM