SFC IEC Pulse (P) Action

don
2009-10-20
2009-10-22
  • don - 2009-10-20

    Hello,

    I have a program which I am running in simulation mode. In one of the steps of an SFC POU with IEC steps, I have a pulsed (P) action which simply increments a number. I find that the number is incremented twice upon entering the step. Why is this so?

    Don.

     
  • JAPIB

    JAPIB - 2009-10-20

    Hello

    It is a normal operation of the IEC SFC. You can see it in the online help :"Note:If an action has been inactivated, it will be executed once more. That means, that each action is executed at least twice (also an action with qualifier P)".

    For me it's a "bug" in the standard. Because in the french version of SFC, wich is called "GRAFCET", an action with qualifier P is executed only one time.

    In conclusion we should not use the qualifier P !!

     
  • don - 2009-10-21

    Thanks for that JAPIB,

    The book 'Programming industrial control systems using IEC 1131-3' by R. W. Lewis describes 'A pulse action that only executes once when a step is activated and once when the step is deactivated.' which was the behaviour I was expecting (so that you could reset outputs upon exiting the step). This is obviously not the functionallity of CoDeSys. Further in the the book it has another statement regarding the pulse action qualifier which seems contradictory: 'the pulse action also executes a second time from the rule that action statements or networks shall be executed one final time after the falling edge of the action qualifier'. This seems to match the functionallity of CoDeSys. I don't understand how the second execution of the P action could be useful. Is there a way of detecting if you are running the first or second execution of the action?

    Is it recommended to use the Entry-Action instead?

    Best regards,

    Don.

     
  • Igor Petrov - 2009-10-22

    JAPIB hat geschrieben:
    For me it's a "bug" in the standard. Because in the french version of SFC, wich is called "GRAFCET", an action with qualifier P is executed only one time.

    It is not a bug, but a very useful feature. Primitive example: I connect N action with a step. In this action I use FBD TON with step activity variable on input. As result I get a complete functionality for this FBD (start, run, rest – during last call) by just the only one super simple FB instance call. Without this feature I must start it in entry action, use in normal one and reset in exit action = too complicated. Additionally I could switch On and Off something related with the step. Thanks to this future I can write a pure SFC program without using different languages.

    don hat geschrieben:
    I don't understand how the second execution of the P action could be useful. Is there a way of detecting if you are running the first or second execution of the action?

    Yes, of course. You could use variables <stepname>.x and <stepname>._x for recognizing is any step active or not.</stepname></stepname>

    There are special qualifiers P0 and P1 in IEC standard identical to the entry and exit actions in CoDeSys.

    don hat geschrieben:
    Is it recommended to use the Entry-Action instead?

    Yes – if you need just the entry action. If you need to catch any step activity changing, then use P.

     

Log in to post a comment.