Results 1 to 7 of 7
  1. #1
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    May 2014
    Location
    Germany
    Posts
    7
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Lightbulb SIOC init switches

    Hi,

    I'm just coding for my home-built OVH and came across some problems regarding the switch position after starting SIOC.

    What I'm using:
    - P3D 2.4
    - iFly 737 CBE
    - iFlyToFSUIPC
    - SIOC (of course) + 3 Mastercards, etc...

    After starting everything the switches are not in sync with the simulation (the LEDs are). I hoped that SIOC would read the switch-positions and then send it to the sim, but it does not Or it does it for some switches (read somewhere that this is a known problem).

    I then tried to use "Var 0" and call some init subroutines in my different sections:

    Code:
    Var 0 Value 0
    {
        v1 = DELAY 1 100 //call init routines after 1s
    }
    
    Var 1
    {
        CALL &InitBleed
        ...
    }
    Then I created subroutines (in my bleed section) for every switch and tried to call them within one function:

    Code:
    Var 1 name InitBleed Link SUBRUTINE
    {
        CALL &TRIM_SWITCH
        CALL &L_REC_SW
        CALL &R_REC_SW
        ...
    }
    Not working -> only the last switch will go to the correct position

    Then I put some delay in between (which looks terrible in SIOC ):

    Code:
    Var 1 name InitBleed Link SUBRUTINE
    {
        CALL &TRIM_SWITCH
        &InitBleed1 = DELAY 1 10
    }
    Var 2 name InitBleed1
    {
        CALL &L_REC_SW
        &InitBleed2 = DELAY 1 10
    }
    Var 3 name InitBleed2
    {
        CALL &R_REC_SW
        &InitBleed3 = DELAY 1 10
    }
    ...
    Now it's working and after ~1 s all the coded switches are in sync

    BUT: Is this really the way to do it?
    It's not good looking code in my opinion.
    Maybe anyone has a good idea how to do it?

    Thanks for any hints...

    Marc

  2. Likes Shimokuta liked this post
  3. #2
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    May 2014
    Location
    Germany
    Posts
    7
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: SIOC init switches

    Hm,

    the more switches I add to this procedure the less stable it works.
    Played around with delays and so on, but result is not very promising.

    It seems SIOC does not recognize the correct state for some switches, but eratically...very disappointing

    Maybe I should not put too much effort into that and sync my switches manually.

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

    Re: SIOC init switches

    Sorry, this was a double post. My browser did not update the page correctly.
    Last edited by Mischung; 02-28-2015 at 12:45 PM. Reason: Double post.

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

    Re: SIOC init switches

    Sorry, this was a double post. My browser did not update the page correctly.
    Last edited by Mischung; 02-28-2015 at 12:43 PM. Reason: Double post

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

    Re: SIOC init switches

    So I had some time to dig a bit deeper and I'm pretty sure it does work now. At least my panel is doing a perfect sync of all the switch positions now.

    My mistake was to think too procedural (which is pretty natural when you're programming C or C++ usually). So this event-based thing is not intuitive at first glance.
    I found out that SIOC already does a perfect init at startup, but is sending out the commands way too fast. Bringing in delays will also not work, because at first startup all variables change at the same time, so all the delays would have to be different then (otherwise commands will be sent simultaneously again).

    So I try to give you all an idea of what I did:


    1) Using var 0 to start an init-phase


    Code:
    
    Var 0 Value 0
    {
        v1 = DELAY 1 100  // go to var 1 after 1 s (wait for stable conditions)
    }
    
    Var 1
    {
        CALL &Init        // call the init routine
    }
    
    2) put all switches code into sub-routines (example for trim-switch)

    Code:
    Var 2000, name TRIMAIR, Link IOCARD_SW, Device 1, Input 31  // Trim Air
    {
      CALL &TRIM_SWITCH
    }
    
    Var 3000 name TRIM_SWITCH Link SUBRUTINE
    {
      IF &TRIMAIR = 1
      {
        &cmd_Ifly = 118
      }
      ELSE
      {
        &cmd_Ifly = 117
      }
    }

    3) init-routine (here we can call all the switches sub-routines)


    Code:
    
    Var 1 name Init Link SUBRUTINE
    {
        CALL &TRIM_SWITCH       // first call the trim switch routine
        &Init1 = DELAY 1 20     // after a delay of 200 ms call next init1
    }
    Var 2 name Init1
    { 
        CALL &L_REC_SWITCH      // call the next switches routine
        &Init2 = DELAY 1 20     // of course delay again
    }
    Var 3 name Init2
    {
        CALL &R_REC_SWITCH      // and so on
        &Init3 = DELAY 1 20
    }
    ...
    And voila, all the switches go into their corresponding "real" position. Maybe the delays can be optimized, but it will not take too long anyway. Other things can be prepared during that time

    Hope everyone got the idea. Don't hesitate to ask if you have any questions.
    Now I have to do the rest of the overhead program

    Regards

    Marc

  7. Thanks Shimokuta, iwik thanked for this post
    Likes Shimokuta liked this post
  8. #6
    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: SIOC init switches

    Hello Marc,

    Have you checked the microcontroller version of your USB expansion card?
    With version 2, available since june 2013 the initial position of switches are always detected, so no need for all your initialisation code.

    If you have an older USB expansion card you can easily upgrade it with a new microcontroller, see here.

    Regards,
    Nico Kaan

  9. #7
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    May 2014
    Location
    Germany
    Posts
    7
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: SIOC init switches

    Hi Nico,

    I have the latest version of the PIC-code. The cards and SIOC are working as expected, but the corresponding commands will be sent out way too fast during init-phase (at least iFlyToFSUIPC cannot handle that). That's where all these delays are helping out.

    If SIOC or iFlyToFSUIPC would be able to have a kind of internal command queue with configurable min. delay between executions, everything would be fine I guess.

    Regards

    Marc