Skip to content

SFC weird behavior TON timers

Hi,

I was trying to make my first SFC with PLCnext engineer and I wanted to create a simple traffic light FBD.

So I noticed the Q from te TON function blocks stays on and the Output from the function block ''Test SFC'' keeps flashing on and OFF. After a lot of try and error and debugging the problem it was resolved If I enable ''Evaluate_all_transistions''....

If I read the documentation correct it would work as IEC61331-3 intended if I left all the Inputs disconnected from the SFC function Block. I also made this block in a couple of other PLC programs including PCWorx and there it works as intended.

Can somebody explain why it act strange? It should be easy to replicate.

My PLC engineer version:

PLC: axc-f-2152 (Starter kit)

FW: 2023.0.0 LTS (23.0.0.65)

HW: 06

Comments

  • Hi seafoxc,

    Imo the described behavior does not seem to be strange if we operate with the assumption that the default state is that only the transition for the active step is evaluated (opposed to the option Evaluate All Transition). Thus the code in the network connected to the other transitions is not executed. Meaning the variables etc keep their last values if they are not written by other parts of the program.

    When you enter a new cycle the transitions evaluates to be TRUE because the TON remained TRUE because it wasn't executed every cycle and the first thing your code does is setting the action variable for TON.IN to TRUE (before the FB is called). So it keeps the output TRUE. That would cause the program to rush through all steps causing flashing outputs.


    Food for thought:

    You can realize your traffic light easier by using coded transitions. In those transitions you can access the time the step is active via StepName.T and use it in a condition to set the transition.

    BR

    DivisionByzero

  • I've thought this over for a while, and I find the behavior unintuitive. It raises doubts about whether Phoenix Contact can truly claim that an unconnected SFC function block behaves according to IEC 61131-3 in this case. The behavior differs from all major PLC brands I’m familiar with (Sattline, Siemens, OpenPLC) and even from its predecessor, PC Worx.

    IEC 61131-3 is designed to ensure portability and consistency across different compliant PLCs. If the same logic produces different results across platforms, it suggests that PLCnext’s implementation may not fully align with the standard’s execution model.

  • Can you please tell me the chapter in the IEC 61131-3 in which it describes how Transitions must be evaluated?

    I tried find it but I failed.

  • edited February 17

    Hi I will try to get my reasoning on paper as best as I can :-).

    So from the standard:

    So we have a transistion condition. And you have a lot of ways to connect this transistion.

    So it should Work as Inline or as transistion. Then I made a test program to see if it makes a difference if you use it inline, in a transition or for good measure I als tried ST (With the TON timer).

    In the video you can see the 3 FB's with the decribed methodes. I will also add the program to this post.


    You can see when you load the program the first run works as intended for al three of the Function Blocks. The second run it is as all transitions are True. (The last FB I set the time for the orange light to 6 seconds instead of 3 seconds so it 'bugs out' al little later.

    The the working of the TON block in the standard:


    And here print screen of the Phoenix contact help:


    So if it evaluates the transition condition it should evaluate the TON timer and the result should be false. But the standard does not specifiy the code that should be use for the TON FB. You can not see the code behind the standard FB's (Blogpost on the forum).

    Why would it be usefull to skip the execution of the TON block when it is explicit written in the transition statement?


    It is bothering me because it is not intuitive and I can not speak off all PLC manufactures but the ones I worked with like Siemens, Sattline, OpenPLC en PCWorx all handle the traffic light like I would expect it to run. Note that PCWorx is also from Phoenix Contact.

    I can not wrap my mind around why a simple SFC code would work different depending on the manufacturer and that even the same company (Phoenix Contact) has 2 PLC families where the same SFC code behaves differently (The PC Worx line of PLC's will be absolute in maybe a couple of years but still...).




  • Okay it does not deviate from the IEC61131-3 because it doesn't say wether all transitions are always evaluated or not.

    I can only assume that there is reason why it behaves the way it does and the input "Evaluate all Transitions" exists is to be able to run projects like in PCWorx or Siemens.

Sign In or Register to comment.