Fareed Mohmed← Project library

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

Two cylinders: A+ B+ B- A-

Cylinder A extends, then B extends, then B retracts, then A retracts. The classic pneumatic sequence.

▶ Run it in the simulator

Virtual machine for Two cylinders: A+ B+ B- A-: 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

Each step waits for a sensor, not for time. The next movement only starts when the previous one has really finished, so the machine adapts if a cylinder is slow. Spring-return valves retract when their output turns off.

How it works

  • Press START with both cylinders retracted.
  • A+ then B+ then B- then A- run one after another.
  • Each step waits for its sensor: A1, B1, B0, A0.

In real life

Pick-and-place units, stamping, clamping and packaging machines are built from sequences like this.

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
A0Cylinder A retracted sensorInput%I0.2Local:1:I.Data.2X2X20.02%IX0.2X2
A1Cylinder A extended sensorInput%I0.3Local:1:I.Data.3X3X30.03%IX0.3X3
B0Cylinder B retracted sensorInput%I0.4Local:1:I.Data.4X4X40.04%IX0.4X4
B1Cylinder B extended sensorInput%I0.5Local:1:I.Data.5X5X50.05%IX0.5X5
YAValve A (on = extend)Output%Q0.0Local:2:O.Data.0Y0Y0100.00%QX0.0Y0
YBValve B (on = extend)Output%Q0.1Local:2:O.Data.1Y1Y1100.01%QX0.1Y1

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: A extends (A+)S0%M0.0START%I0.0A0%I0.2B0%I0.4S1%M0.1S2%M0.2STOP%I0.1S1%M0.1Rung 2 Step 2: B extends (B+)S1%M0.1A1%I0.3S2%M0.2S3%M0.3STOP%I0.1S2%M0.2Rung 3 Step 3: B retracts (B-)S2%M0.2B1%I0.5S3%M0.3S4%M0.4STOP%I0.1S3%M0.3Rung 4 Step 4: A retracts (A-)S3%M0.3B0%I0.4S4%M0.4A0%I0.2STOP%I0.1S4%M0.4Rung 5 Step 0: idle when no other step is activeS1%M0.1S2%M0.2S3%M0.3S4%M0.4S0%M0.0Rung 6 Output YA is on in step 1, 2, 3S1%M0.1S2%M0.2S3%M0.3YA%Q0.0Rung 7 Output YB is on in step 2S2%M0.2YB%Q0.1

Sequential function chart

0IDLESTART & A0 & B01A extends (A+)N YAA12B extends (B+)N YAN YBB13B retracts (B-)N YAB04A retracts (A-)A0back 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 *)


"YA" := FALSE;
"YB" := FALSE;

IF NOT "STOP" THEN
   Step := 0;   (* stop or emergency stop: back to idle *)
ELSE
   CASE Step OF
      0: (* idle *)
         IF "START" AND "A0" AND "B0" THEN Step := 1; END_IF;
      1: (* A extends (A+) *)
         "YA" := TRUE;
         IF "A1" THEN Step := 2; END_IF;
      2: (* B extends (B+) *)
         "YA" := TRUE;
         "YB" := TRUE;
         IF "B1" THEN Step := 3; END_IF;
      3: (* B retracts (B-) *)
         "YA" := TRUE;
         IF "B0" THEN Step := 4; END_IF;
      4: (* A retracts (A-) *)
         IF "A0" 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 *)


YA := FALSE;
YB := FALSE;

IF NOT STOP THEN
   Step := 0;   (* stop or emergency stop: back to idle *)
ELSE
   CASE Step OF
      0: (* idle *)
         IF START AND A0 AND B0 THEN Step := 1; END_IF;
      1: (* A extends (A+) *)
         YA := TRUE;
         IF A1 THEN Step := 2; END_IF;
      2: (* B extends (B+) *)
         YA := TRUE;
         YB := TRUE;
         IF B1 THEN Step := 3; END_IF;
      3: (* B retracts (B-) *)
         YA := TRUE;
         IF B0 THEN Step := 4; END_IF;
      4: (* A retracts (A-) *)
         IF A0 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 pneumatic cylinders with magnetic sensorsAmazon.in · IndiaMART · Robu.in
32 solenoid valvesAmazon.in · IndiaMART · Robu.in
4Air supplyAmazon.in · IndiaMART · Robu.in
← 6. Tank filling and mixing (SFC)All projects8. Traffic light →

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.