Results 1 to 5 of 5

Thread: Sioc Help

  1. #1
    500+ This must be a daytime job



    Join Date
    Jan 2007
    Location
    NEW ZEALAND
    Posts
    867
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Sioc Help

    Hi Guys,
    Trying to get the attached code running properly, spent many hours but its apparent
    I lack programming skills. Here is what I am trying to do:
    Have a four position rotary switch and one push button switch connected to a
    Buo386x card. I am reading the switch inputs from Offset 03c4, each switch
    has a DEC code of 256,512,1024,2048 and the push button 4096. So depending
    on which switches are active gives a unique DEC value. In two of the positions
    I want to press the push button which will give a DEC value of 4096+ 1024 and
    the other position will be 4096 + 2048.
    When these two button combinations are selected I switch pages on a O/C
    LCD module and want the page to be displayed for 10 seconds before returning
    to page designated by the 4 pos switch.
    The attached code does this with one exception. When I start sioc code
    no pages get displayed until I press the Push Button. Then everything works as I want it.
    Hope someone might be able to correct my code as I am exhausted trying all I know to
    fix it.




    Code:
      Var 251,Link FSUIPC_IN, Offset $03c4, Length 4
     {
     IF V251 = 6144 // ALT
     {
      V200 = 3
      V200 = DELAY 0 400
     }
    
     IF V251 = 5120 // ON
     {
    CALL V252
     
     V200 = 3
     V200 = DELAY 2 400
     }
    
     IF V251 = 4608 // STBY
     {
     V200 = 3
     V200 = DELAY 2 400
     }
    
    
     IF V251 = 256 // OFF
    {
     V200 = 1
    }
    
    
     }
    
    Var 252,Link SUBRUTINE
    {
    IF V251 = 1024
     {
    V200 = 3
      V200 = DELAY 2 400
     
     }
    ELSE
     {
     V200 = 2 
    }
    }
    var 200 // LCD DISPLAY 2
    Thanks
    Les

  2. #2
    500+ This must be a daytime job
    Join Date
    Jul 2013
    Posts
    948
    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 Help

    Hi Les

    You have just run up against the golden rule of SIOC, which is that nothing happens until a variable changes value, when and only then, does the code attached to that variable actually run!

    However, there is an answer Insert the following at the very start of your code

    Var 0 Value 0
    {
    V200 = 3 // or whatever initial value that matches the screen you want
    }

    The above code uses a feature of SIOC that allows an initialisation code to be run once only at the programme commencement. This will solve your problem and is also documented on Nico`s website here

    http://www.lekseecon.nl/howto.html#init

    Regards

    David

  3. #3
    500+ This must be a daytime job



    Join Date
    Jan 2007
    Location
    NEW ZEALAND
    Posts
    867
    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 Help

    Hi David,
    Thanks for that will have to try that in the morning.
    Sorry but one thing I forgot to say was that the rotary switch can be operated
    but still nothing happens till I push the Button. So a variable is changing and
    I would have thought some data should have shown up.
    Les

  4. #4
    500+ This must be a daytime job
    Join Date
    Jul 2013
    Posts
    948
    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 Help

    Hi Les

    If I understand correctly, with a four way rotary and an additional push button you have a total of 8 dec values that can be sent to Var 251. However, your code for var 251 only takes action on four values ie 6144,5120,4608 and 256. Other values will produce no actions. If you want a default action for other values then you need to add an ELSE function at the end of the IF statements in the code for Var 251.

    Also, I suggest you use the IOCPCONSOLE LOG ON function to monitor what your code is doing for each rotary switch position - that will tell you a lot!

    Regards

    David

  5. #5
    500+ This must be a daytime job



    Join Date
    Jan 2007
    Location
    NEW ZEALAND
    Posts
    867
    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 Help

    Hi David,
    Yes I understand re the Else statement. I have monitored things via IOCP Console but it only gives limited feedback. If I remember rightly I did put in some Else statements but it seemed
    to stuff up the delayed statements. I think all it did was allowed the delayed page to be displayed while the push button was pressed. But will try again and will take into account what you have said and will post again with so more data if needed.
    Les