Fareed Mohmed← Project library

Engineering · PLC · Project 6 of 15 · Sequences · Level 3

Tank filling and mixing (SFC)

Fill with liquid A, fill with liquid B, stir for 5 seconds, then drain. A true step-by-step sequence.

▶ Run it in the simulator

Virtual machine for Tank filling and mixing (SFC): buttons, lamps and the process it controls
Learning model only. This page teaches the program logic. A real machine needs a proper control panel with an isolator, fuses, motor protection and a hard-wired emergency stop. Mains and motor wiring is for qualified electricians. A PLC output never drives a motor directly.

You will learn

A sequence is a list of steps. Only one step is active at a time; it switches outputs on, and a transition condition moves on to the next step. In ladder each step is a memory bit; in Structured Text it becomes a CASE statement; in SFC it is drawn as boxes.

How it works

  • Press START. Step 1 opens valve A until Level 1.
  • Step 2 opens valve B until Level 2.
  • Step 3 stirs for 5 s. Step 4 drains until empty, then the sequence returns to IDLE.

In real life

Batch plants in food, paint, chemicals and pharmaceuticals use this pattern, usually from a recipe table.

Inputs, outputs and addresses

The same signals on seven PLC brands. Inputs and outputs are numbered in order; check your own hardware and software, because addresses depend on the model and module position.

NameWhat it isTypeSiemens
S7-1200
Allen-Bradley
CompactLogix
Mitsubishi
iQ-F FX5U
Delta
DVP / AS
Omron
CP2E
Schneider
M241
Inovance
H5U
STARTSTART push-buttonInput%I0.0Local:1:I.Data.0X0X00.00%IX0.0X0
STOPSTOP push-button (N.C.)Input%I0.1Local:1:I.Data.1X1X10.01%IX0.1X1
L1Level 1 float (40 %)Input%I0.2Local:1:I.Data.2X2X20.02%IX0.2X2
L2Level 2 float (80 %)Input%I0.3Local:1:I.Data.3X3X30.03%IX0.3X3
L0Empty float (above 3 %)Input%I0.4Local:1:I.Data.4X4X40.04%IX0.4X4
VAValve AOutput%Q0.0Local:2:O.Data.0Y0Y0100.00%QX0.0Y0
VBValve BOutput%Q0.1Local:2:O.Data.1Y1Y1100.01%QX0.1Y1
MIXMixer motorOutput%Q0.2Local:2:O.Data.2Y2Y2100.02%QX0.2Y2
DRAINDrain valveOutput%Q0.3Local:2:O.Data.3Y3Y3100.03%QX0.3Y3

Ladder diagram (shown for Siemens, live state)

Green wires carry power in the moment captured below. Switch the brand and the language in the simulator.

Rung 1 Step 1: Fill with AS0%M0.0START%I0.0S1%M0.1S2%M0.2STOP%I0.1S1%M0.1Rung 2 Step 2: Fill with BS1%M0.1L1%I0.2S2%M0.2S3%M0.3STOP%I0.1S2%M0.2Rung 3 Step 3: MixS2%M0.2L2%I0.3S3%M0.3S4%M0.4STOP%I0.1S3%M0.3Rung 4 Step 3 timer (5 s)S3%M0.3"T3"TONINPT T#5sQETET = 0 msRung 5 Step 4: DrainS3%M0.3Timer 3 done"T3".QS4%M0.4L0%I0.4STOP%I0.1S4%M0.4Rung 6 Step 0: idle when no other step is activeS1%M0.1S2%M0.2S3%M0.3S4%M0.4S0%M0.0Rung 7 Output VA is on in step 1S1%M0.1VA%Q0.0Rung 8 Output VB is on in step 2S2%M0.2VB%Q0.1Rung 9 Output MIX is on in step 3S3%M0.3MIX%Q0.2Rung 10 Output DRAIN is on in step 4S4%M0.4DRAIN%Q0.3

Sequential function chart

0IDLESTART1Fill with AN VAL12Fill with BN VBL23MixN MIXT3 elapsed (5 s)4DrainN DRAIN!L0back to IDLE

Structured text, Siemens SCL

(* Siemens S7-1200, CPU 1214C DC/DC/DC - TIA Portal - SCL *)
(* Variable "Step" (INT) holds the active step: 0 = idle *)

"T3"(IN := Step = 3, PT := T#5s);

"VA" := FALSE;
"VB" := FALSE;
"MIX" := FALSE;
"DRAIN" := FALSE;

IF NOT "STOP" THEN
   Step := 0;   (* stop or emergency stop: back to idle *)
ELSE
   CASE Step OF
      0: (* idle *)
         IF "START" THEN Step := 1; END_IF;
      1: (* Fill with A *)
         "VA" := TRUE;
         IF "L1" THEN Step := 2; END_IF;
      2: (* Fill with B *)
         "VB" := TRUE;
         IF "L2" THEN Step := 3; END_IF;
      3: (* Mix *)
         "MIX" := TRUE;
         IF "T3".Q THEN Step := 4; END_IF;
      4: (* Drain *)
         "DRAIN" := TRUE;
         IF NOT "L0" THEN Step := 0; END_IF;
   END_CASE;
END_IF;

Structured text, Allen-Bradley

(* Allen-Bradley CompactLogix 5069 (L306ER) - Studio 5000 Logix Designer - Structured Text *)
(* Variable "Step" (INT) holds the active step: 0 = idle *)

Timer3.PRE := 5000;   (* ms *)
Timer3.TimerEnable := Step = 3;
TONR(Timer3);

VA := FALSE;
VB := FALSE;
MIX := FALSE;
DRAIN := FALSE;

IF NOT STOP THEN
   Step := 0;   (* stop or emergency stop: back to idle *)
ELSE
   CASE Step OF
      0: (* idle *)
         IF START THEN Step := 1; END_IF;
      1: (* Fill with A *)
         VA := TRUE;
         IF L1 THEN Step := 2; END_IF;
      2: (* Fill with B *)
         VB := TRUE;
         IF L2 THEN Step := 3; END_IF;
      3: (* Mix *)
         MIX := TRUE;
         IF Timer3.DN THEN Step := 4; END_IF;
      4: (* Drain *)
         DRAIN := TRUE;
         IF NOT L0 THEN Step := 0; END_IF;
   END_CASE;
END_IF;

Try this

Parts to buy

The links open a search on each store, so you see what is in stock today. Check the model, voltage and price before you order.

#ItemBuy / compare
1PLCAmazon.in · IndiaMART · Robu.in
22 inlet solenoid valvesAmazon.in · IndiaMART · Robu.in
3Drain valveAmazon.in · IndiaMART · Robu.in
43 level switchesAmazon.in · IndiaMART · Robu.in
5Mixer motorAmazon.in · IndiaMART · Robu.in
← 5. Automatic pump with float switchesAll projects7. Two cylinders: A+ B+ B- A- →

This is a learning tool. It teaches the logic, not the exact keystrokes of each vendor’s software. Check the manual of your own PLC.