LD UDFB Guided Learning Q11: – What is state fall through for a state machine?

This article is part of a guided learning series on building and analyzing User-Defined Function Blocks (UDFBs).

:pushpin: Canonical Article: Building a User-Defined Function Block (UDFB) Using Siemens TIA Portal
:blue_book: Learning Companion (Q&A): Explore All Questions

You are reading: Question 11

What is state fall through for a state machine

Clarification

Suppose we are in state A, The A network changes the state variable to B. Can we expect both network A and network B to execute? Is this an important consideration? What could be done to prevent this behavior if it was important?

Answer

This is directly related to the β€œlast rung wins” gotcha that we commonly encounter in PLC programming.

If we change states, we risk falling through to the next state thereby vising both states in a single program scan. This could be a problem if we expected events to occur on the transition from A to B. However, if we design a true Moore state machine the hazard is eliminated.

If events must occur on the state transitions, it may be better to include a state between A and B. This transitionAtoB state could then handle the logic using easy to follow Moore logic.

Why Moore vs Mealy matters

  • Moore: A rudimentary state machine where the outputs are entirely dependent on the state.

  • Mealy: For our PLC state machine application, we define Mealy as a machine with outputs depending on both input and state. This includes the state variable itself. In PLC language could associate a Mealy machine with a one shot that occurs on a state change.

  • Output: All memory locations that may be impacted by the state machine. This includes the output for the featured UDFB. It also includes static variables and even uiState.

:writing_hand: Article by Aaron Dahlen, LCDR USCG (Ret.), Application Engineer at DigiKey