Loading local progress…
PLC Gym
PLC Gym homeLevel 1, 0 XP · your progress
All guides

Sequential function chart: steps, transitions and a worked tank batch

What a sequential function chart is, how steps, transitions and actions run, a worked tank batch, and how Rockwell, Siemens and Beckhoff do it.

A stainless steel mixing tank with pipework, valves and a level transmitter in a process plant.
A tank that fills, mixes and drains is the classic job for a sequential function chart.
In this guide
  1. What a sequential function chart is
  2. Steps, transitions and actions
  3. How an SFC runs in a PLC
  4. A sequential function chart example: one tank batch
  5. When to choose SFC over ladder or Structured Text
  6. Three mistakes worth learning early
  7. Sequential function chart software from the makers
  8. Practising charts in PLC Gym
  9. Sources

A sequential function chart, or SFC, is a way to program a PLC by drawing the job as a chain of steps. Each step says what the machine does right now, and the link to the next step says when to move on. If you've ever sketched a process on a whiteboard as fill, then mix, then drain, you've already got the idea.

What follows is checked against the manuals from Rockwell, Siemens and Beckhoff, linked at the bottom. Where the makers do things differently, this guide says so, because that's where people get caught out.

What a sequential function chart is

Rockwell's manual compares an SFC to a flowchart, and that's the easiest way to picture it. The difference is that this flowchart runs. You aren't describing the program, you're writing it.

It's one of the languages in IEC 61131-3, the international standard for PLC programming. PLCopen's summary lists the graphical and text languages, then describes SFC differently: as the language that structures how a program is organised inside. So a chart often doesn't replace your other code. It sits above it and decides which part of the job is happening.

Siemens calls its version GRAPH: the same idea with its own rules. The glossary entry has the short definition.

Steps, transitions and actions

Sequential function chart programming comes down to a few parts.

  • Step. One major part of the job, such as Fill or Mix. It stays active until the chart is told to move on.
  • Action. Something the step does, such as running a pump.
  • Transition. A true or false condition between steps, such as the level reaching 70%. True means go to the next step. False means stay put.
  • Qualifier. The letter in front of an action, which says when it starts and stops.

Those letters are worth learning properly. Rockwell, Siemens and Beckhoff all have these five.

QualifierWhat it doesExample
NOn only while its step is activeRun the mixer during Mix
STurns on and stays on after the step endsKeep a pump running through later steps
RClears what S turned onStop that pump in a later step
DStarts after a delay, if the step is still activeStart a fan five seconds into the step
LOn for a limited time, or until the step endsOpen a flush valve for ten seconds

Beyond those the lists differ. Rockwell and Beckhoff add pulse and stored timer versions, and Siemens has event dependent actions, so check the list for your software.

A chart can also branch, in two ways.

  • A choice. Rockwell calls this a selection branch, Siemens and Beckhoff an alternative branch. Only one path runs. Rockwell and Beckhoff both check the transitions left to right and take the first true one, and Rockwell lets you change that order.
  • Paths that run together. This is a simultaneous branch, or a parallel branch in TwinCAT. Every path runs, and the chart doesn't carry on until they've all finished.

How an SFC runs in a PLC

The chart starts at its initial step. While a step is active, its actions run and the next transition keeps being checked. When that transition turns true, the step ends and the next one starts.

The controller isn't sitting still while it waits. It keeps running its scan, so a step waiting ten minutes for a tank to fill still gets visited on every pass.

The order inside a scan is where the makers differ.

  • Beckhoff publishes the exact order: exit actions, entry actions, step actions, IEC actions, and transitions last.
  • Rockwell shows a step running, then its transition being checked. When it's true, the old step gets one last scan before the next step runs. A controller setting decides what that last scan does (Don't Scan, Programmatic reset or Automatic reset), and it applies to every chart on that controller.
  • Siemens lists permanent instructions first, then the actions of active steps, then permanent instructions again. The chart also won't advance while a supervision error is pending.

A chart also doesn't restart by itself. On Rockwell, you wire the last transition back to an earlier step or use a stop element. In GRAPH, you finish with a jump or a sequence end.

A sequential function chart example: one tank batch

Here's the job from PLC Gym's One batch, four phases mission. A tank fills, mixes, drains and reports that it's finished.

StepActionsTransition to the next step
ReadyR DoneStart AND Permit
FillN PumpOn, N FillValveLevel >= 70
MixN MixerOnMixDone
DrainN DrainValveLevel <= 5
CompleteS DoneNone, the chart stays here

In Ready nothing runs, and the R action makes sure Done isn't left on. Press Start with the permit on and the chart moves to Fill, so the pump and valve come on. When the level reaches 70%, Fill ends. Because those actions are N, the pump and valve stop on their own. You never write a line saying turn the pump off. The mixer then runs until MixDone, the drain runs down to 5%, and Complete stores Done so it stays on.

Here's the same batch in Structured Text as a CASE state machine, in Rockwell style. State is a whole number tag that starts at 0. This passes that mission's checks, which is a simulator result rather than proof on a real controller.

CASE State OF
  0: // Ready
    IF Start AND Permit THEN State := 10; END_IF;
  10: // Fill
    IF Level >= 70 THEN State := 20; END_IF;
  20: // Mix
    IF MixDone THEN State := 30; END_IF;
  30: // Drain
    IF Level <= 5 THEN State := 40; END_IF;
END_CASE;

PumpOn := State = 10;
FillValve := State = 10;
MixerOn := State = 20;
DrainValve := State = 30;
Done := State = 40;

It's short and it works. But in the chart you can see where the batch is just by looking at it. In text you're reading a number and remembering what it means.

Real batches get interrupted, so charts soon grow. In Recover the Interrupted Batch, Fill gets a second transition, Hold OR Fault, leading to a held step. That's a branch, and the hold path gets the higher priority so it wins if the tank reaches 70% at the same moment.

When to choose SFC over ladder or Structured Text

Rockwell gives a rule of thumb in its common procedures manual. That edition is from 2004, but the guidance is clear and comes straight from a maker.

LanguageWhat Rockwell points it at
SFCManaging several operations at a high level, repeated sequences, batch processes, state machines
LadderOperations that aren't sequenced, bit logic, machine interlocking, anything maintenance staff may need to read to find a fault
Function block diagramContinuous process and drive control, loop control
Structured TextComplex maths, array or table loops, string handling

The same manual says you can mix languages in one project, with the chart commanding each device while other tasks regulate it.

A simple test is this. If you can describe the job as do this, wait for that, then do the next thing, a chart fits. If it's a rule that must hold whichever phase you're in, such as a stop or an interlock, it doesn't belong inside one step. GRAPH's permanent instructions, for example, run every cycle even with no step active. And a chart is no safety function. Real safety functions need proper safety rated equipment and a competent person.

There are costs too. Siemens says GRAPH blocks need more processing time than standard blocks. And Rockwell lists faster troubleshooting as an SFC advantage while steering logic maintenance staff must read towards ladder, so ask the people who'll support the machine. You'll know your own site best.

Three mistakes worth learning early

  • A stored action with no reset. Leaving the step doesn't turn off an S action. Rockwell warns it stays active even when the chart reaches a stop. What stays on? makes you plan the reset.
  • Two transitions true at once. Make them opposites, as in Start AND RouteA and Start AND NOT RouteA, so you're not relying on priority by accident. That's the lesson in Choose the right route.
  • A chart that waits forever. If a level transmitter fails, Fill may never end. Rockwell has a LimitHigh alarm on each step, Siemens has supervision plus step time monitoring on S7-1500, and in TwinCAT a maximum active time sets SFCError.

Sequential function chart software from the makers

Each maker builds this into its own software, with its own names and rules.

Rockwell SFC in Studio 5000

You add an SFC routine in Studio 5000 Logix Designer. The simplest transition is a true or false expression in Structured Text, and an action can hold embedded Structured Text or call a subroutine in another language. The SFP and SFR instructions pause and reset a chart. This detail comes from Rockwell's March 2004 manual, when the software was RSLogix 5000, so check it against the current SFC manual, publication 1756-PM006.

Siemens GRAPH in TIA Portal

Some Siemens material says S7-GRAPH, but it's the same language. A GRAPH block is always a function block, and you need at least three blocks: the GRAPH block, its instance data block and a block that calls it. Transition conditions go in LAD or FBD. Actions can be tied to an interlock, so they only run when its conditions are met. The S7-1200 doesn't have GRAPH. Siemens' comparison list says it only supports LAD, FBD and SCL. The TIA Portal guide has the wider picture.

Beckhoff TwinCAT 3

TwinCAT 3 has a graphical SFC editor. Alongside the IEC qualifiers, Beckhoff adds its own entry, step and exit actions, plus flags such as SFCInit and SFCError for control and monitoring. It warns that forcing a step active leaves the chart in an uncontrolled state.

Practising charts in PLC Gym

PLC Gym has editors for GRAPH, styled on TIA Portal V20, and for SFC, styled on Studio 5000 v38. You build the chart, press Run and a 3D tank responds. The chart missions sit in the course after the free missions, so they're on Pro. The pricing page has the details.

Here's what it isn't. It's a simulator, not a real controller, and it isn't made by or affiliated with Siemens, Rockwell or Beckhoff. PLC Gym's charts cover one active path, alternative branches in priority order, and N, S and R actions. There are no simultaneous branches, timed qualifiers, nested charts or action routines, and no full interlock and supervision system. A new step's actions run on the next scan, which is PLC Gym's rule and not necessarily your controller's. Charts don't export, so you'd enter them again in the real software. And there's no TwinCAT chart editor, as the Beckhoff route is Structured Text only. The language reference has the detail.

So when you need those features, you need TIA Portal or Studio 5000, and ideally a real PLC. What PLC Gym gives you is practice at the thinking: what belongs in a step, when to move on and what stays on after you've left.

Sources

Questions about this?Ask in the Locker Room

Try it on a machine

Free · Runs in your browser

Try it on a working machine

Write real Siemens or Rockwell code in the free online PLC simulator and watch a 3D pump, tank or filling line do exactly what you told it. Nothing to install.