A powerful concept in real-world programming controlling physical machinery is to begin by breaking the complete process down into a series of operating states. This is commonly referred to as using a state machine.
Rather than attempting to describe the entire machine or process with one large program, the control problem is divided into smaller, clearly defined operating conditions. At any particular point in the process, the controller knows which state, or states, are active and therefore which control actions should be taking place.
IEC 61131-3 Sequential Function Chart, normally abbreviated to SFC, provides a graphical programming language specifically designed around this concept.
Consider a relatively simple pumping application. The complete operating sequence could be divided into the following states:
Initialisation
Wait
Start
Pipe Fill
Run
Stop
Trip
Under normal operation the process might progress:
Initialisation → Wait → Start → Pipe Fill → Run → Stop → Wait
From each appropriate operating state there may also be a transition to the Trip state. The Trip state can then remain active until the fault condition has cleared and a valid reset command has been received, after which the sequence may return to the Wait state.
The important point is that each state contains only the control actions that are relevant while the process is in that state.
For example, the Pipe Fill state might contain the logic necessary to operate the pump at a reduced speed or controlled pressure while monitoring discharge pressure and elapsed time. Once the required pipe pressure has been established, the transition condition becomes true and control passes to the Run state.
The Run state does not need to know how the pipe was filled. Its responsibility is simply to control the system while the plant is running normally.
This approach has already divided what could have become one large and complicated program into a number of relatively small and easily understood modules.
The IEC SFC terminology normally uses the word Step rather than state.
A Step represents a particular condition or phase of operation. Associated with that Step are one or more Actions, which define what the controller is required to do while that Step is active.
Between Steps are Transitions.
A Transition contains the logical condition that determines when control is permitted to leave the current Step and proceed to the next Step.
The fundamental SFC structure is therefore:
STEP → TRANSITION → STEP → TRANSITION → STEP
For example:
Wait → Start command received → Start → Motor running → Pipe Fill → Pressure established → Run
The Transition conditions may be based on virtually any information available to the controller, including:
Digital inputs
Operator commands
Measured analogue values
Timers
Internal variables
Communications data
Completion of another operation
Combinations of several logical conditions
This provides a very natural way of describing the behaviour of physical machinery.
Every Step has a clearly defined entry and exit.
A Step becomes active when the preceding Transition is satisfied. The Actions associated with that Step can then be executed.
The Step remains active until the conditions associated with its outgoing Transition are satisfied. At that point the following Step becomes active and the previous Step is deactivated.
This is fundamentally different from conventional PLC programming where a large quantity of logic may be continuously scanned and individual rungs determine whether particular outputs should operate.
With SFC, the structure of the program itself indicates where the machine currently is in its operating sequence.
This can make both programming and fault finding considerably easier.
The Actions associated with a Step should normally relate only to the responsibilities of that particular Step.
For example, the Start Step might:
Issue the motor start command.
Verify that the starter or drive responds.
Monitor the motor-running feedback.
Start a maximum starting-time timer.
Generate a start failure if the motor does not respond correctly.
Once the motor has successfully started, the Start Step has completed its purpose and control can pass to the next Step.
This separation is important.
A common cause of unnecessarily complicated control software is allowing one section of a program to become responsible for too many unrelated operations. SFC encourages the programmer to divide the process into clearly defined functional sections.
Not everything belongs inside an SFC Step.
Some functions must operate continuously regardless of which Step is active.
Typical examples include:
Reading and conditioning analogue inputs.
Scaling instrumentation.
Monitoring emergency stops and safety inputs.
Detecting motor or drive faults.
Monitoring temperature, pressure and other protective devices.
Communications.
Alarm processing.
Updating operator displays.
Calculating process variables.
These functions can operate independently of the SFC sequence and provide information that the SFC uses when determining whether a Transition should occur.
For example, a pressure transmitter may be continuously scaled into engineering units by another program block. The SFC Pipe Fill Step does not need to know how the pressure value was obtained; it simply tests whether:
Discharge Pressure ≥ Required Fill Pressure
and, when that condition is satisfied, permits the Transition to the Run Step.
This separation between continuous process functions and sequential control is one of the major advantages of a well-structured SFC program.
A simple state machine is sometimes implemented using a numerical variable or counter.
For example:
State 0 = Wait
State 1 = Start
State 2 = Pipe Fill
State 3 = Run
State 4 = Stop
The program increments or decrements the state number as the machine progresses.
Although this works for very simple processes, it can become restrictive as the machine becomes more complicated.
SFC is considerably more flexible.
The next Step does not necessarily have to be numerically before or after the current Step. The program can follow different paths according to the conditions that exist in the real machine.
For example, from the Run Step:
Run → Normal Stop → Stop
but alternatively:
Run → Process Fault → Trip
or:
Run → Low Demand → Standby
or:
Run → Cleaning Required → Cleaning Sequence
The direction taken is determined by the Transition conditions rather than by simply incrementing a state counter.
Real machines rarely have only one possible sequence.
SFC allows the program structure to represent alternative operating paths.
For example, after a pump receives a Start command the controller might determine whether the pipeline is already pressurised.
If pressure is low:
Start → Pipe Fill → Run
If adequate pressure already exists:
Start → Run
There is no reason to perform the Pipe Fill sequence when the physical condition requiring it does not exist.
This illustrates an important principle of SFC programming: the software structure can follow the actual state of the process rather than forcing the process through an artificial fixed sequence.
SFC can also represent processes where more than one activity needs to occur at the same time.
A machine may reach a point where two or more operations can proceed independently. These branches can execute concurrently and later rejoin when the required operations have been completed.
For example, a process might simultaneously:
Open a valve
and
Start an auxiliary cooling system
before permitting the main process to continue.
The next major Step can be made conditional on both operations having completed successfully.
This ability to represent alternative and parallel paths makes SFC particularly useful for machinery and process applications where operation cannot be adequately represented by a simple linear sequence.
Fault handling should be considered when the SFC is designed, rather than added later.
Each Step should be examined by asking:
What can go wrong while the machine is in this Step, and where should the program go if it does?
For the pump example, a trip from the Run Step might be caused by:
Motor overload.
Drive or soft starter fault.
Excessive discharge pressure.
Loss of suction pressure.
Excessive motor temperature.
Emergency stop.
Loss of communications with essential equipment.
Any of these conditions could cause a Transition to the Trip Step.
The Trip Step could then perform the actions required to place the process into a defined condition, such as removing the run command, closing or opening appropriate valves and recording the reason for the trip.
A reset should not simply remove the alarm. The Transition from Trip back to Wait should confirm that the appropriate conditions for restarting the machine are valid.
This makes the recovery behaviour of the machine explicit and predictable.
One of the most important disciplines when designing an SFC program is to make every Transition condition clearly defined.
A Transition should answer the question:
Exactly what must be true before the process is allowed to leave this Step?
For example, instead of thinking:
Pipe filled
the actual Transition might require:
Pressure ≥ 450 kPa AND minimum fill time complete AND motor running AND no trip present
This makes the engineering requirements visible in the software.
It also makes commissioning and fault finding much easier because the programmer can determine exactly which condition is preventing the sequence from progressing.
Whenever a Step waits for something to happen in the physical world, consideration should also be given to what happens if it does not happen.
For example, the Start Step might normally exit when a motor-running signal is received.
However, if the motor-running signal is never received, the machine should not remain indefinitely in the Start Step.
The logic should therefore include a maximum permitted starting time.
Conceptually:
Motor Running → proceed to Pipe Fill
but:
Start Time Exceeded → Trip
This principle applies to valve movement, pressure build-up, temperature changes, communications responses and almost every other physical operation.
A good SFC therefore describes not only how the machine should operate when everything works, but also how it should respond when something fails to happen.
An important practical advantage of SFC is that the active Step provides an immediate indication of the current condition of the sequence.
If a machine has stopped progressing, the commissioning engineer can first determine:
Which Step is active?
and then:
Which Transition condition is preventing it from leaving that Step?
This is usually much easier than tracing a large conventional ladder program containing interlocks distributed across many rungs.
The graphical nature of SFC also makes it easier to discuss the control sequence with engineers and technicians who did not originally write the program.
The chart itself becomes a useful description of how the machine is intended to operate.
Horner Cscape supports IEC 61131-3 programming and allows SFC to be used as part of a structured control application.
SFC is particularly appropriate for the high-level sequencing of a machine or process, while other IEC languages can be used for the detailed control functions associated with the sequence.
For example, an application may use SFC to determine whether the machine is in:
Wait, Start, Fill, Run, Stop or Trip
while detailed calculations, analogue processing, communications and equipment control are implemented using the most appropriate programming method.
This is an important concept. SFC does not have to replace the other programming languages.
Its strength is in providing the structure and sequencing of the application.
A useful way of designing an SFC application is to avoid beginning with the PLC program.
Begin with the machine.
Ask:
What distinct operating conditions can this machine physically be in?
Write these down as candidate Steps.
Then, for every Step, ask three questions:
What must the machine do while it is in this Step?
What must happen before it is allowed to leave this Step?
What faults or abnormal conditions can occur while it is in this Step?
The answers naturally produce the Actions, Transitions and fault paths required for the SFC.
This approach keeps the control program closely related to the physical process being controlled.
The real strength of SFC is not simply that it provides another graphical PLC programming language.
Its advantage is that it encourages the programmer to think about the application as a collection of defined operating states, actions and transition conditions.
Instead of asking:
“What should this output be doing?”
the programmer first asks:
“What state is the machine in?”
Once that is known, the required behaviour of the outputs is usually much easier to determine.
For sequential machinery, pumping systems, process control, material handling, batching and similar applications, this can result in programs that are easier to design, easier to commission, easier to diagnose and, most importantly, easier for another engineer to understand many years after the original program was written.