SPS correct programming KRC2, KSS 5.6

  • Hello. I create such a little more expanded SPS and I have a question how it is more correct.


    SPS file:

    Code
    ...
    ;user init
    GLOBAL INTERRUPT DECL 21 WHEN WATER_PRESSURE_MISSING DO DO_SOMETHING()
    INTERRUPT ON 21
    ...

    or (also in SPS file):

    Code
    ...
    LOOP
    IF (WATER_PRESSURE_MISSING) THEN
    DO_SOMETHING()
    ENDIF
    ENDLOOP
    ...

    WATER_PRESSURE_MISSING is input signal from external sensor.

    Regards.

  • Either one should work. Personally, I prefer to avoid using Interrupts unless absolutely necessary.


    The potential weakness of the "polling" method in the main SPS Loop is that, if your SPS was very large, had many branches, or contained "halting" commands like WAIT or WAIT FOR, the check for the Input could be delayed. However, a small, tidy SPS should have no trouble keeping up.

  • either one could be made to work...


    the first one can work if program is properly structured. but i would say just be careful and avoid situations that may be difficult to debug or gracefully recover from. and why it needs to be global when SPS.SUB is the top level program? in this case, this only adds restrictions on other things like RESUME.


    the second one is not really ok. entire loop only processes YOUR code. any techpackages or SPS code normally there will not be processed.

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • So it's better to try to avoid interruptions to such solutions?

    And what in case, if in "DO_SOMETHING" I would like to have a timer of 3 seconds and if after these 3 seconds the signal does not disappear then stop the program and display the alarm. But without WAIT in SPS. Only timer. Which solution would be appropriate?


    I added "GLOBAL" instinctively, because I have many branches and subprograms.


    The second (in the loop) is only example, of course, this is the main loop in SPS.SUB.

  • "But without WAIT in SPS. Only timer. Which solution would be appropriate?"

    so if you need timer, then just ... use timer!


    perhaps:

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

Advertising from our partners