This article is part of a guided learning series on building and analyzing User-Defined Function Blocks (UDFBs).
Canonical Article: Building a User-Defined Function Block (UDFB) Using Siemens TIA Portal
Learning Companion (Q&A): Explore All Questions
You are reading: Question 2
What are the advantages and disadvantages of each method used to hold a PLC’s state? At a minimum include the latch, set/reset coils, and numeric methods (integer state variables).
Type: Explicit
Recommended for: Technicians,
Students
Answer
As described in the primary article, we can select our state (memory) based on program complexity. Here are several methods to maintain a PLC’s state.
Latch
The 3-Wire start-stop circuit is a very simple state machine based on an explicit latch. As seen in Figure 1 the M1 contact provides the holding current until the stop button is pressed.
Set/Reset Coils
Set and reset coils provide a succinct way to hold the states. They are not as verbose as the latch as the holding circuit does not need to be explicitly coded.
However, a moderately complex state machine such as described in the primary article would have an uncomfortable number of coils. Here the term “moderately complex” describes a state machine with multiple branches from any given state.
Cam or Drum Sequencers
Cam and drum sequencers provide a built-in method that is easy to read and to program. They are perfect for a machine that follows a deterministic path but can be complex when we need to jump across states. As an example, consider the cam indexer as shown in the previous question. If state “clamp” were encoded position C and state “fault” was position F, a fault detected in the clamp state would require us to quickly step through states D and E.
Numeric Methods
The numeric method as described in the primary article easily accommodates complex state transition with a structure that is clean and easy to follow. The beauty is that we can troubleshoot an error by monitoring the current state then testing the transition to each state.
Figure 1: Wire diagram for the 3-wire start stop circuit developed using KiCad.
Article by Aaron Dahlen, LCDR USCG (Ret.), Application Engineer at DigiKey