Loading local progress…
PLC Gym
PLC Gym homeLevel 1, 0 XP · your progress
Mission 52 · PRO (needs Pro)

A+ B+ B− A−: PLC programming exercise

Run two cylinders through the classic four move sequence.

On Start, run one cycle: A out, B out, B back, A back. Every move waits for the reed switch of the move before it.

This mission is part of ProCreate a free account: every account gets a free Pro trial until 5 December.

No card. Nothing to pay. Nothing to cancel.

Official release: 5 December. Top the leaderboard on the day and win 3 months of Pro, plus 2 weeks of Pro to give a friend. 2nd place wins 4 weeks. 3rd place wins 2 weeks. Rules

  • Every Coaching lesson, from zero
  • Every mission and lesson, as you level up
  • A practical test for every title, with a certificate
  • Rewind any test, one scan at a time
  • Worked solutions when you're stuck
  • The code converter, as much as you like
The 3D electro-pneumatics trainer this mission runs onPRO (needs Pro) mission
How the test runs

One cycle, in order

Test 1 of 4
Set by the testChecked by the testStep 9 of 9 · 5.9 s
Level
Applied
Time
About 30 min
Reward
+350 XP
Rig
3D electro-pneumatics trainer
Siemens editors
Ladder (LAD), SCL
Rockwell editors
Ladder, Structured Text
Beckhoff editors
Structured Text
Stage
33. Pneumatics lab: cylinders, valves and reed switches
Required behaviour

A+ B+ B− A−: what your code must do

Think of A as a clamp and B as a punch. The clamp closes (A+), the punch goes out (B+), the punch comes back (B−), the clamp lets go (A−). Keep AirOn ON. Start begins one cycle when the air is up (AirOK) and both cylinders are back (A0 and B0). A goes out: ExtendA ON. At A1, B goes out: ExtendB ON. At B1, B comes back: ExtendB OFF and RetractB ON. At B0, A comes back: ExtendA OFF and RetractB OFF. At A0 the cycle is over. B's valve has two solenoids and remembers its last position: energise ExtendB only to send B out and RetractB only to bring it back, never both together. RunLamp is ON for the whole cycle. One press is one cycle.

Start
Needs AirOK, A0 and B0. One press, one cycle.
Order
A out, B out, B back, A back.
Proof
Each move waits for the switch before it.
Valve 2V1
ExtendB and RetractB never ON together.
How it's checked
The checks press Start and watch the trainer itself: its reed switches, StrokesA and StrokesB (strokes that reached the end) and BothSolenoids (times both of 2V1's solenoids were ON together).
Tag table

A+ B+ B− A−: inputs and outputs

Your program reads 6 inputs and sets 5 outputs. 2 more inputs drive the simulation or show readings, for you to test with. The names are the same in every maker’s editor.

TagData typeYour codeWhat it means on the machine
StartBOOLReadsAn input your code needsGreen Start pushbutton
AirOKBOOLReadsAn input your code needsPressure switch 0B1: ON once the air is above 4.5 bar
A0BOOLReadsAn input your code needsReed switch 1B1: cylinder A fully back
A1BOOLReadsAn input your code needsReed switch 1B2: cylinder A fully out
B0BOOLReadsAn input your code needsReed switch 2B1: cylinder B fully back
B1BOOLReadsAn input your code needsReed switch 2B2: cylinder B fully out
SlowABOOLNot neededFor testing or watching; your code can leave it outTry it: wind in the flow control on A's out stroke, so A goes out slowly
SlowBBOOLNot neededFor testing or watching; your code can leave it outTry it: wind in both flow controls on B, so B is slow both ways
AirOnBOOLWritesAn output your code setsDump valve 0V2: ON lets the air in, OFF lets it out
ExtendABOOLWritesAn output your code setsValve 1V1, spring return: ON sends A out, OFF brings it back
ExtendBBOOLWritesAn output your code setsValve 2V1, out solenoid: sends B out, and the valve stays there
RetractBBOOLWritesAn output your code setsValve 2V1, back solenoid: brings B back, and the valve stays there
RunLampBOOLWritesAn output your code setsGreen lamp: a cycle is running

In Siemens SCL, write a block’s own tags with # in front, as TIA Portal does: #Start. Rockwell and TwinCAT use the name on its own: Start.

Automatic tests

A+ B+ B− A−: what the tests check

  1. The order is A out, B out, B back, A back.
  2. B never leaves until A is fully out, however slow A is.
  3. A stays out until B is fully back, however slow B is.
  4. ExtendB and RetractB are never ON together.
  5. One press gives one cycle, and both cylinders finish at home.
  1. Try it Use the buttons below the model and watch the rig respond.
  2. Test solution Every check runs on your code in one press.
  3. Rewind PRO (needs Pro) If one fails, step back through it one scan at a time to see why.

Stuck on this mission? Ask the members in the Locker Room.

Why it matters

Where you’d see this on site

Clamp and punch, clamp and drill, grip and lift: the same four moves run in presses, drilling jigs and assembly stations everywhere.

If the punch fires before the clamp has closed, the part moves and is scrap. If the clamp lets go while the punch is still in the part, something bends or breaks.

Where you'd find thisMove things with air, and know where every cylinder is

Most machines that clamp, push, lift or eject do it with air cylinders. A solenoid valve sends air to one side of the piston and lets it out of the other, and a small switch on the barrel tells the controller when the piston has arrived. Colleges teach it on a board like this one, because the same few parts make up almost every pneumatic machine.

  1. Air supplyFiltered, set to 6 bar
  2. ValvesOne 5/2 valve a cylinder
  3. CylindersOut and back on airYou are here
  4. Reed switchesProve each stroke
On a real site: places, parts and safety
  • Assembly machines that clamp a part, then press or drill it
  • Packing lines that push, lift and eject cartons
  • College and apprentice training workshops

Compressed air is stored energy. Shut the isolator and let the air out before touching pipework: a hose that comes off under pressure whips.

Letting the air out isn't always the safe state. A cylinder holding a load upright drops when the air goes, so real machines are assessed one cylinder at a time.

The sizes, timings and cutaways are teaching choices, not a drawing of any one real installation.

Keep going

Next on the road