Walkthrough: Problem 4: Air Cylinder

Difficulty

Target behavior

Extend the rod with the Push button and retract it with the Pull button

What you will learn

  • Set (SET) / Reset (RES) instructions
  • Interlocks using auto switches

Problem

Next, let's practice ladder logic using an air cylinder, a device used in the moving parts of machines.

Here we explain how an air cylinder works and how to control it.


An air cylinder is driven by air. By supplying and exhausting air, it pushes and pulls the rod inside the tube.

For example, it is used to push workpieces off a belt conveyor in a sorting system.


The figure shows how an air cylinder is driven. High-pressure air generated by a compressor drives the cylinder.



First, let's watch a video of an air cylinder in action.

(The video is by SMC, the world's largest maker of pneumatic equipment. SMC pneumatic devices are found in almost every machine.)




When an air cylinder is used in a machine, the PLC must control when the rod extends and retracts.

The device used for this is a solenoid valve. By switching the air path with the solenoid valve, the rod is pushed and pulled.

SMC's video explains this very clearly too. The explanation of how the solenoid valve works starts at about 30 seconds.



We now know the solenoid valve can extend and retract the cylinder. But control is difficult if we cannot tell whether the rod has finished extending or retracting.

In other words, the PLC needs to know where the rod is. For this we use auto switches.

The rod of an air cylinder has a magnet, and a sensor that detects magnetism is mounted on the cylinder to detect the rod position. This sensor is called an auto switch.



That covers the air cylinder and how it is driven.


Now for this model.

Reproduce the motion where pressing the Push button extends the rod and pressing the Pull button retracts it!

In other words, turn the solenoid valve ON when the Push button is pressed and OFF when the Pull button is pressed!

For wiring, you need to wire the solenoid valve and the auto switches for detecting the retracted end and the extended end of the rod.

Target behavior (video)

Approach

A single-solenoid valve extends the rod while its coil is ON and retracts it when OFF. The state must be kept after the button is released, so SET/RES instructions are used instead of a self-holding circuit.

Based on this approach, try writing the ladder yourself first.
In the simulator, you can create the wiring and ladder and actually run the 3D equipment model.

Try it in the simulator
Show the sample ladder and explanation(click to open)

Devices used

DeviceComment
Inputs
X0Auto switch (extended)
X1Auto switch (retracted)
X2Push button
X3Pull button
Outputs
Y0Cylinder solenoid valve

Ladder explanation

The row numbers in the figures match the row numbers in the simulator's ladder window.

1Extend (SET) and retract (RES)Rows 001–002

  • Row 001: if X2 (Push button) is ON and X1 (retracted-end auto switch) is ON, SET Y0 (solenoid valve)
  • Row 002: if X3 (Pull button) is ON and X0 (extended-end auto switch) is ON, RES Y0

SET turns the device ON when the condition is satisfied and keeps it ON even after the condition is no longer met. RES turns the device OFF.

The auto switches are included in the conditions so that the rod extends only after it has fully retracted, and retracts only after it has fully extended. A condition like this that prevents an opposite command during a motion is called an interlock.

The sample wiring and ladder data can be downloaded fromGitHuband loaded with "Load wiring" and "Load ladder" in the simulator.

Key points

  • SET/RES lets you write what a self-holding circuit does with a single instruction.
  • Using the same device with both SET and RES is normal (it is not a double coil).