AutomateDirectUSAMotion LibraryShop the parts catalog

How-to

How to Home a Double-Acting Pneumatic Cylinder in Ladder Logic

Pneumatics and hydraulics Published 8 min read

Short answer

Latch a one-shot home request into a homing state, drive the retract output only from that state, and clear the state when the retracted sensor turns on. Consume the request on entry so a held button cannot re-trigger it. Rapid cycling means the sensor is driving the output directly instead of a completed state, so add a jam timer and an impossible-sensor check as faults, not as delays.

On this page
  1. Why the cylinder cycles fast without a timer
  2. The homing routine step by step
  3. What the valve does with both coils off
  4. Jam timer sizing and sensor diagnostics
  5. Where this logic stops being a safety function
  6. Questions asked

Retract the cylinder from a homing state, not from the sensor. Latch a one-shot home request into that state, energize the retract coil only while the state is active, and close the state on the retracted sensor's on-transition — then hold the completed bit until a new request clears it. Consume the request when you accept it, so a held button cannot re-trigger the move. The rapid cycling you are fighting comes from the position input driving the output directly through a home latch that resets itself; a timer only slows that loop. Two checks replace the timer where it matters: a jam timer sized from the stroke time, and an impossible-state check that rejects both endpoint sensors on at once. What the valve's spool does with both coils off decides whether dropping the output parks the rod at all, so read that configuration before writing the last rung.

Why the cylinder cycles fast without a timer #

The rung that cycles is almost always the direct one: the retract output held on by (home mode AND NOT retracted sensor), with home mode itself held by NOT homed. The cylinder reaches the sensor, the output drops, and then one of two things happens. With a valve whose center position exhausts the cylinder ports, the rod creeps back off the sensor under load or side force; the sensor breaks, the output returns, and the loop repeats at the speed of the drift. With any valve, a home-mode latch that drops out on the sensor and re-seals on the next scan of the same rung restarts the stroke electrically. Both look identical on the coil: chatter that a delay only slows.

Trend the state bit, both coil outputs, both sensor inputs and supply pressure together for one cycle and the two cases separate. Pneumatic drift shows the sensor breaking with both outputs off; re-triggering shows an output rising while the sensor is still made. The fix is the same either way: make completion an event that sets a retained bit, and let nothing follow the sensor afterward.

The homing routine step by step #

  1. Read the valve before the rungs. From the valve's symbol or datasheet, establish what the spool does with both coils off — detented, or spring-centered with blocked, exhausted or pressurized working ports — and confirm which coil retracts by jogging the cylinder in air, clear of the work. Write the finding into the machine's documentation; the output strategy hangs on it.

  2. Wire the two coils as a pair. One solenoid per direction, on the supply and suppression the valve's electrical data calls for — the same practice as any valve setup for a double-acting cylinder — so neither coil is ever driven from two places in the program.

  3. Verify the sensors against the rod. With the cylinder at each end, exactly one input is on; between ends, neither is on. Confirm the two sensing zones cannot both see the piston at any position. Only a stroke shorter than the combined zones breaks that, and then the impossible-state check must be relaxed to match the real geometry.

  4. Reject impossible inputs before accepting a request. Both endpoint inputs on at once latches a sensor fault and blocks motion until a deliberate reset. Do not gate homing on a timer to wait out a flapping input.

  5. Capture the request once. On the rising edge of the operator or supervisory home command, set an internal request latch. When the routine accepts the latch, clear it in the same rung. A held button then has no effect until it is released and pressed again.

  6. Complete without stroking if already home. If the retracted sensor is valid at entry, set the homed bit in the same scan and never energize the coil.

  7. Drive the retract output from the state, not from the sensor. Output on while the homing state is active and the retracted sensor is off, extend output forced off. Generate both coil outputs in one place, mutually exclusive, so no other rung can fight them.

  8. End on the sensor's on-transition. When the retracted input goes true during homing, drop the retract output, set the homed bit and exit the state. The homed bit stays set until a new cycle request or a fault clears it, so drift off the sensor afterward cannot restart motion.

  9. Arm the jam timer with the command, not the request. Start timing when the retract output actually turns on; if the retracted sensor has not appeared by the preset, drop outputs, latch a jam fault and demand a reset. The preset comes from the sizing below.

  10. Prove it on the bench. Hold the home command on for the whole test: the routine must enter homing exactly once and sit ready. Then inhibit the retracted sensor input and confirm the jam fault latches at the preset. Run both tests with air on, rod in view and nothing in the tooling.

Tags and initial values #

The tag names below are illustrative. TON, IN, PT and Q are the IEC 61131-3 on-delay timer names; the ladder equivalents are one rung each.

Tag Type Start value Role
Home_Cmd BOOL input Operator or supervisory home command
Home_Req BOOL FALSE One-shot internal request
Homing BOOL FALSE Retract-in-progress state
Homed BOOL FALSE Retained completion
Retracted_Sensor BOOL input Retracted endpoint sensor
Extended_Sensor BOOL input Extended endpoint sensor
Air_OK BOOL input Pressure permissive, if fitted
Sensor_Fault BOOL FALSE Latched impossible-state fault
Jam_Fault BOOL FALSE Latched timeout fault
Retract_Out BOOL FALSE Retract coil
Extend_Out BOOL FALSE Extend coil
Jam_Timer TON PT := T#2.5S Preset from the worked example below

The rungs in one place #

// 1. Capture the request
IF Home_Cmd AND NOT Homed AND NOT Sensor_Fault AND NOT Jam_Fault AND Air_OK THEN
    Home_Req := TRUE;
END_IF;

// 2. Accept it once and consume it
IF Home_Req AND Air_OK THEN
    Homing   := TRUE;
    Home_Req := FALSE;
END_IF;

// 3. Impossible sensor state
IF Retracted_Sensor AND Extended_Sensor THEN
    Sensor_Fault := TRUE;
END_IF;

// 4. Jam watch on the actual command
Jam_Timer(IN := Homing AND NOT Retracted_Sensor, PT := T#2.5S);
IF Jam_Timer.Q THEN
    Jam_Fault := TRUE;
END_IF;

// 5. Complete (runs after entry, so an already-retracted cylinder
//    finishes in the same scan without energizing the coil)
IF Homing AND Retracted_Sensor THEN
    Homing := FALSE;
    Homed  := TRUE;
END_IF;

// 6. Outputs, one place, mutually exclusive
Retract_Out := Homing AND NOT Retracted_Sensor
               AND NOT Sensor_Fault AND NOT Jam_Fault AND Air_OK;
Extend_Out  := FALSE;  // homing never extends; the cycle logic writes this

Fault bits clear only from a separate, deliberate reset rung. Rung order carries two behaviors: the entry rung above the completion rung makes the already-home case finish in one scan, and the completion rung above the output rung drops the coil in the same scan the sensor appears.

What the valve does with both coils off #

A two-coil valve says nothing about its de-energized behavior; the symbol and datasheet do. Four arrangements cover almost everything you will meet:

Spool with both coils off What happens at the cylinder Decision for a homed axis
Detented two-position Spool stays in the last commanded position; the retract port stays pressurized Works, and the coil can be pulsed and released, but the rod then sits against the cap under steady pressure
Spring-centered, blocked working ports Cylinder ports blocked; trapped air resists motion The default choice for a horizontal homed axis; a soft hold, not a lock, because leakage and compressibility let a heavy load creep
Spring-centered, exhausted (float) center Both ports vent; the load moves the rod freely Do not drop the coil after homing. Hold the retract output through the ready state, after confirming the coil's continuous-duty rating in the valve datasheet, or change the valve
Spring-centered, pressurized center Both ports see supply; on a single-rod cylinder the full-bore side wins Never holds a retracted home: the rod extends off the sensor as long as pressure is on

The pressurized-center row is piston arithmetic: the rod removes area on one side, so equal pressure on both ports is not equal force. Decision for a machine that homes to retracted and waits: specify a spring-centered blocked-center valve and let the routine drop both coils. Keep a detented valve when steady pressure against the cap is acceptable. This pattern is endpoint-to-endpoint control; holding mid-stroke under command needs a proportional valve and continuous position feedback, which is a different architecture.

Jam timer sizing and sensor diagnostics #

Run the numbers before picking a preset. Measure one full stroke with a stopwatch at working pressure when you can; a measured time beats an estimate. Calculated example for one set of inputs — stroke length L = 200 mm and planning speed v = 250 mm/s from the same estimate behind estimating pneumatic cylinder end-of-stroke velocity:

t = L ÷ v = 200 mm ÷ 250 mm/s = 0.8 s

Rule of thumb, labelled as one: preset the jam timer at three times the stroke time with a 1 s floor. Three times 0.8 s is 2.4 s, so set 2.5 s for these inputs — the T#2.5S in the rungs above. The margin covers cold starts, pressure dips and a sensor aligned late in its zone; scaling is linear, so 400 mm at 100 mm/s (t = 4.0 s) takes a 12 s preset.

Two checks do the rest, both latching faults that need a deliberate reset. Both endpoint inputs on at once is impossible wherever the zones cannot overlap — the geometry verified in step 3 — and means a shifted sensor, a bent bracket or crossed wiring. The jam timer fires on command-without-completion, which catches a mechanical jam, low air pressure and a sensor that never switches under one bit. The one blind spot is a retracted sensor stuck on with the rod mid-stroke: the routine completes instantly and believes itself home. If the process cannot tolerate that, add an independent witness, such as a mid-stroke sensor that must be off at completion, and fault on a miss.

Where this logic stops being a safety function #

Everything above is functional control. Where a guard, light curtain or e-stop must stop this cylinder, ISO 13849-1 requires the safety function to be designed and validated to the performance level the machine's risk assessment sets, and standard PLC logic with a standard valve does not qualify. The air side follows ISO 4414's general rules for pneumatic systems, including isolating and venting stored energy before anyone reaches into the stroke. Stopping on a safety device is a valve-and-circuit problem rather than a ladder problem; stopping a vertical air cylinder on a light curtain trip shows the hardware-side pattern.

Questions asked

Why does my homing routine cycle rapidly until I add a timer?

The retract output was following the retracted sensor through a home latch that reset itself: the sensor makes, the output drops, the rod drifts off the sensor or the latch re-fires, and the output returns. A timer only slows the loop and hides a genuine jam. Complete the homing state once on the sensor's on-transition and hold the completed bit until a new request; after that, nothing follows the sensor, so there is no loop left to slow.

How long should the jam timer preset be?

Take the stroke time and multiply by three, with a one-second floor. For a 200 mm stroke retracting at 250 mm/s, the move takes 0.8 s, so three times that is 2.4 s and the preset is 2.5 s. The floor matters on short strokes, where a start-up pressure dip can stretch a fraction-of-a-second move into nuisance trips. Watch the first faults: a timer that fires repeatedly is telling you about the air supply, not about the preset.

Both endpoint sensors came on together — wiring or placement?

Treat it as a fault, and put the rod mid-stroke to see which input is still on: that one is stuck, shifted or miswired. On any stroke long enough that the two sensing zones cannot overlap, both signals at once is never a valid position. Only a stroke shorter than the combined zones makes it geometrically possible, and then the check must be relaxed on purpose and the geometry documented in the machine file.

Should both valve coils ever be energized at the same time?

No. Generate the two coil outputs in one mutually exclusive rung set and let the fault response drop both. Opposing commands put competing pressure on the spool, waste air and leave the position to chance. If a valve's documentation defines a behavior for simultaneous energization, treat it as a property of that valve family under those conditions, not as permission to command it routinely.

Keep reading

  • Selection guide

    Pneumatic valve setup for double-acting robot grippers

    One 5/3 double-solenoid valve with a chosen center runs a single double-acting gripper cylinder: coil A closes, coil B opens, both off gives the idle state you ordered. Two spring-return valves on one manifold usually feed two functions — equalization, safety lock, cascaded exhaust — not one cylinder. Size the valve on peak flow: the worked example needs about 264 L/min at close.

    Pneumatics and hydraulics

  • Comparison

    Stopping a Vertical Air Cylinder on a Light Curtain Trip

    Use a 3-position center-pressurized valve with a higher regulated rod-side pressure — the only pneumatic center that balances a vertical load mid-stroke — then let a rod lock hold it. Verify every component in the trapped-air path against the deceleration pressure spike and confirm total stop time against the safety-distance formula Ds = 63 in/s × Ts.

    Pneumatics and hydraulics

  • How-to

    Building a Pneumatic Cycle Test Stand Without a PLC

    Stop the test with a preset counter set to 10, not a 60-second timer: a 3 s extend plus 3 s rest gives 6 s per commanded cycle, which is a duration check, not proof of ten strokes. Wire a Start/Stop-sealed control relay to feed a 3 s on / 3 s off repeat-cycle timer driving a single-solenoid spring-return 3-way valve, and let the counter's preset contact break the run circuit.

    Pneumatics and hydraulics