GRAFCET and sequences
Almost every machine does the same thing: a sequence of steps. Lower, close the gripper, raise, move across, open. GRAFCET is the standardised way of drawing that sequence before programming it, and it is the best cure for programs where nobody knows which step the machine is in. It is defined in IEC 60848, and the SFC language of IEC 61131-3 is derived from it; in Siemens it is called S7-GRAPH.
The elements
- Step: a square with a number. It represents a state of the machine. It can be active or inactive.
- Initial step: a double square. It is the one that is active at start-up.
- Transition: a horizontal bar between steps. It has an associated receptivity: the condition that must be true to move to the next step, for example “part present”.
- Action: a rectangle to the right of the step, with what is done while the step is active, for example “lower the drill”.
- Links: the lines joining steps and transitions. They are read from top to bottom; if a link goes upwards, it has an arrow.
The evolution rules
A GRAFCET is not a free drawing: it evolves according to five rules.
- Initial situation: at start-up, the initial steps are active.
- Clearing a transition: a transition is enabled when all the steps immediately before it are active. It is cleared when it is enabled and its receptivity is true.
- Evolution: when a transition is cleared, all the following steps are activated and all the preceding ones are deactivated.
- Simultaneity: if several transitions can be cleared at the same time, they are cleared at the same time.
- Activation has priority: if a step must be activated and deactivated at the same time, it stays active.
Structures
Linear sequence
One step after another, like the drill. There is only one active step at any time.
OR divergence and convergence (selection)
Several branches leave a step, each with its own transition, and only one is followed. For example, depending on the type of part, it goes to station A or station B. The receptivities of the branches must be mutually exclusive: if two could be true at once, the simultaneity rule would activate both branches, and that is almost never what you want.
AND divergence and convergence (parallel)
They are drawn with a double horizontal line. When the transition is cleared, all the branches are activated at once and evolve separately. At the end, the AND convergence waits for every branch to finish before continuing: it is a synchronisation. For example, while one cylinder places the part, another opens the door, and no drilling happens until both are done.
Jumps and loops
A transition can lead back to an earlier step (repeat) or skip steps that are not needed in a particular case.
Types of actions
- Continuous: the output is on while the step is active. It is the most common and the safest: when the step is left, the action stops.
- Conditional: it only runs if a condition is also true, for example “spin if the door is closed”.
- Stored: it is turned on in one step and off in a later one (set and reset). Useful, but it must be well documented: the output stays on even though the step is no longer active.
- Timed: a receptivity can be a time, for example “2 s since step 3 became active”, written
t/X3/2s.
From GRAFCET to the PLC
There are three common ways of turning a GRAFCET into a program:
1. One memory bit per step, with set and reset (LAD)
Each step is a bit. Each transition is a network: if the previous step is active and the receptivity is true, the next step is set and the previous one is reset.
Network "Transition 0 → 1":
X0 Start Part X1
--| |----| |------| |----------(S)--
X0
--(R)--
The outputs are calculated separately, once each, from the steps: Spin = X1 OR X2. That way each output
has a single coil. At start-up, a start-up block (OB100) sets X0 and resets the rest.
2. A step number with CASE (SCL)
For linear sequences, an integer variable stores the active step and a CASE runs its transitions. It is very compact, but it only allows one active step: parallel branches have to be handled with several sequences.
3. S7-GRAPH or SFC
The GRAFCET is drawn directly in the PLC’s sequential language, which handles the evolution rules by itself and shows online which step is active. In Siemens, S7-GRAPH is available on the S7-1500 (not on the S7-1200).
Typical mistakes
- Receptivities that are not mutually exclusive in an OR divergence: two branches become active at once.
- Forgetting initialisation: after a power cut, no step is active and the machine does not respond.
- Writing the outputs inside each transition, with repeated coils, instead of calculating them once from the steps.
- Using stored actions without resetting them on every possible path.
- Not showing the active step on the HMI: the technician does not know where the machine has stopped.
Summary
- GRAFCET (IEC 60848) describes a sequence with steps, transitions with receptivities, and actions.
- A transition is cleared if its previous step is active and its receptivity is true; it then activates the following steps and deactivates the previous ones.
- OR divergence: one branch is followed, with mutually exclusive conditions. AND divergence: all branches at once, synchronised at the end.
- It is taken to the PLC with one memory bit per step (set and reset), with a step number (CASE) or with S7-GRAPH/SFC.
- Outputs are calculated once from the steps, and the initial step is set at start-up.
Test what you have learned
32 practical questions with explained answers. Free, no sign-up.
Start the test