Slow the valve, not the plant: ramping valve commands to reduce water hammer

A valve that closes too fast can bang the pipe hard enough to break things. Here's the physics in plain words, a worked example, a rate-limited valve command in ladder and structured text, and the limits of what a PLC ramp can do.

Read this first

Ramping a valve command is a normal-control tool that can reduce pressure surges. It does not guarantee you won't get water hammer, and it does not replace a surge (transient) analysis by a qualified engineer, relief devices, surge tanks or arrestors that the system was designed with, or any safety function. Trip and emergency valves close the way the safety design says, not the way this ramp says. The trip-close rung in the example is ordinary control logic for illustration only; it is not a safety function.

Why closing a valve can bang the pipe

Liquid moving in a pipe has momentum. Close a valve quickly and the column of liquid has to stop, and that energy turns into a pressure wave that travels up the line, reflects, and comes back. That's the bang you hear, and it can crack fittings, damage pumps, and loosen supports.

Two pieces of textbook physics tell you how much time "quickly" means:

  • The critical time is 2L/a. L is the pipe length to the reflecting point (often a tank) and a is the speed of the pressure wave in the pipe, often around 1,000 to 1,400 m/s for water in steel pipe. If the valve closes faster than 2L/a, the pipe sees the full surge.12
  • The full surge is ΔP = ρ · a · Δv (the Joukowsky equation): fluid density times wave speed times the change in velocity.2

A worked example (made-up numbers, to show the arithmetic)

Water at 2 m/s in a 300 m line, wave speed 1,200 m/s. Critical time = 2 × 300 ÷ 1,200 = 0.5 seconds. Close faster than that and the surge is about 1,000 × 1,200 × 2 = 2,400,000 Pa, roughly 350 psi on top of the operating pressure. A valve that feels slow to a person can be "instant" to the pipe.

Closing slower than 2L/a lets the reflected wave come back before the valve is shut, which reduces the peak. How much it reduces it depends on the system, which is why a transient model, not a rule of thumb, is how engineers take credit for a slower closure.13 Pump trips, trapped air and column separation can cause surges that a slow valve doesn't fix.3

Where the ramp can live

  • In the PLC, as a rate limit on the analog command. Cheap, visible, and easy to change. It only works on a modulating valve with an analog output.
  • In a smart positioner. Some positioners can limit setpoint speed themselves. For example, the Siemens SIPART PS2 manual describes setpoint ramp up / ramp down parameters (TSUP / TSDO) that limit how fast the active setpoint changes in automatic mode.4 Check your positioner's manual for what applies in which mode.
  • On the actuator. An on/off valve driven by a solenoid can't be ramped from the PLC. Speed-control (flow-control) fittings on the actuator air, or a different valve, are the usual answers.

Remember that many valves pass most of their flow change in the last part of their stroke. A straight-line ramp from 100% to 0% can still be too fast near the seat. A common fix is a slower close step below a set position; confirm what your valve needs with whoever owns the hydraulic design.

A rate-limited valve command in Studio 5000

The operator or the PID sets Valve_Target. The PLC moves Valve_Cmd toward it no faster than the open or close step per 100 ms, and sends Valve_Cmd to the analog output. The target is clamped to 0-100 %, the command starts from the valve's real position on the first scan, and a normal-control trip-close request can win over the ramp. A real safety trip belongs in the safety system (hardwired or safety task), not in this educational ramp. Separate open and close rates matter because closing is usually the dangerous direction.

Ladder

Nine rungs in one ladder routine. The timer in rung 2 gives a tick about every 100 ms plus up to one scan; a periodic task is more exact if you have one free. Rung 7 is only an example of where a trip close sits: after the ramp, so the ramp can never slow it. Open "as text" under any rung to copy it into the rung editor.

Drawn the way the Studio 5000 ladder editor lays it out: inputs on the left, outputs pushed to the right rail. The small numbers with arrows are where the editor shows live values; they read 0 here because nothing is online.

On a phone, swipe sideways to see the whole rung.

First scan: start the command from where the valve actually is, so there's no step0S:FSMOVMoveSourceValve_PosFbk0 ←DestValve_Cmd0 ←
Rung 0 as text
XIC(S:FS)MOV(Valve_PosFbk,Valve_Cmd);
Keep the target inside 0-100 %1GRTGreater Than (A>B)Source AValve_Target0 ←Source B100MOVMoveSource100DestValve_Target0 ←LESLess Than (A<B)Source AValve_Target0 ←Source B0MOVMoveSource0DestValve_Target0 ←
Rung 1 as text
[GRT(Valve_Target,100)MOV(100,Valve_Target),LES(Valve_Target,0)MOV(0,Valve_Target)];
Self-resetting tick: about every 100 ms plus up to one scan (or use a 100 ms periodic task)2RampTmr.DNTONTimer On DelayTimerRampTmrPreset100Accum0
Rung 2 as text
XIO(RampTmr.DN)TON(RampTmr,100,0);
On the tick: close step as a negative number, and the distance to go3RampTmr.DNSUBSubtractSource A0Source BValve_CloseStep0 ←DestValve_NegClose0 ←SUBSubtractSource AValve_Target0 ←Source BValve_Cmd0 ←DestValve_Delta0 ←
Rung 3 as text
XIC(RampTmr.DN)[SUB(0,Valve_CloseStep,Valve_NegClose),SUB(Valve_Target,Valve_Cmd,Valve_Delta)];
Opening faster than allowed: limit to one open step4RampTmr.DNGRTGreater Than (A>B)Source AValve_Delta0 ←Source BValve_OpenStep0 ←MOVMoveSourceValve_OpenStep0 ←DestValve_Delta0 ←
Rung 4 as text
XIC(RampTmr.DN)GRT(Valve_Delta,Valve_OpenStep)MOV(Valve_OpenStep,Valve_Delta);
Closing faster than allowed: limit to one close step5RampTmr.DNLESLess Than (A<B)Source AValve_Delta0 ←Source BValve_NegClose0 ←MOVMoveSourceValve_NegClose0 ←DestValve_Delta0 ←
Rung 5 as text
XIC(RampTmr.DN)LES(Valve_Delta,Valve_NegClose)MOV(Valve_NegClose,Valve_Delta);
Move the command one limited step toward the target6RampTmr.DNADDAddSource AValve_Cmd0 ←Source BValve_Delta0 ←DestValve_Cmd0 ←
Rung 6 as text
XIC(RampTmr.DN)ADD(Valve_Cmd,Valve_Delta,Valve_Cmd);
Normal-control trip request overrides the ramp (NOT a safety function; use only if your design says so)7Valve_TripCloseMOVMoveSource0DestValve_Cmd0 ←MOVMoveSource0DestValve_Target0 ←
Rung 7 as text
XIC(Valve_TripClose)[MOV(0,Valve_Cmd),MOV(0,Valve_Target)];
Send the command to the analog output (0-100 %)8MOVMoveSourceValve_Cmd0 ←DestAO_Valve_Pct0 ←
Rung 8 as text
MOV(Valve_Cmd,AO_Valve_Pct);
(End)
All 9 rungs as text
XIC(S:FS)MOV(Valve_PosFbk,Valve_Cmd);
[GRT(Valve_Target,100)MOV(100,Valve_Target),LES(Valve_Target,0)MOV(0,Valve_Target)];
XIO(RampTmr.DN)TON(RampTmr,100,0);
XIC(RampTmr.DN)[SUB(0,Valve_CloseStep,Valve_NegClose),SUB(Valve_Target,Valve_Cmd,Valve_Delta)];
XIC(RampTmr.DN)GRT(Valve_Delta,Valve_OpenStep)MOV(Valve_OpenStep,Valve_Delta);
XIC(RampTmr.DN)LES(Valve_Delta,Valve_NegClose)MOV(Valve_NegClose,Valve_Delta);
XIC(RampTmr.DN)ADD(Valve_Cmd,Valve_Delta,Valve_Cmd);
XIC(Valve_TripClose)[MOV(0,Valve_Cmd),MOV(0,Valve_Target)];
MOV(Valve_Cmd,AO_Valve_Pct);

Structured Text

Same logic in structured text. Put the routine in a 100 ms periodic task so each pass is one known time step; then you don't need the timer. In the ladder version the tick is about 100 ms plus up to one scan, so the real rate comes out slightly slower than the step math says, which is the safe direction.

// All REAL, in percent open. Same order as the ladder rungs.
// Runs in a 100 ms periodic task, so each pass is one 100 ms step.
// Valve_OpenStep / Valve_CloseStep = allowed % per pass (both > 0)
// e.g. 100 % in 60 s to close  ->  Valve_CloseStep := 100.0 / 600.0;

IF S:FS THEN
    Valve_Cmd := Valve_PosFbk;      // start from the real position
END_IF;

IF Valve_Target > 100.0 THEN
    Valve_Target := 100.0;
ELSIF Valve_Target < 0.0 THEN
    Valve_Target := 0.0;
END_IF;

Valve_Delta := Valve_Target - Valve_Cmd;

IF Valve_Delta > Valve_OpenStep THEN
    Valve_Delta := Valve_OpenStep;
ELSIF Valve_Delta < -Valve_CloseStep THEN
    Valve_Delta := -Valve_CloseStep;
END_IF;

Valve_Cmd := Valve_Cmd + Valve_Delta;

IF Valve_TripClose THEN             // normal control only — not a safety trip
    Valve_Cmd := 0.0;
    Valve_Target := 0.0;
END_IF;

AO_Valve_Pct := Valve_Cmd;

Logix also has a process instruction for this, the Rate Limiter (RLIM), with separate increase and decrease rates in units per second.5 We show the plain version so you can see exactly what it does; check the instruction help before swapping one for the other. Note that RLIM sets its output equal to its input on the first scan, so it won't ramp from where the valve was at start-up.5

Educational example. This code has not been compiled, downloaded, or tested on a controller. It is not production-ready or drop-in code. Treat it as a starting point to review, adapt, and test on your own system. It is standard control logic, not safety logic.

Gotchas

  • PID in the loop. If a PID drives this valve, the ramp adds lag. Feed the ramped value back so the PID knows where the valve really is, or put the limit in the PID's own output rate limit if your instruction has one, so integral doesn't wind up.
  • Fail position beats the ramp. On loss of air or signal, a fail-closed valve closes at its own speed. The PLC can't slow that down.
  • Interlocks and trips. Don't route a safety or emergency close through this ramp unless the safety design says to. Keep those functions in the safety system.
  • Start-up. On first scan, set Valve_Cmd to the valve's actual position (if you have feedback) so the ramp doesn't jump.
  • Test with the people who own the process. Try new ramp rates during a planned window and watch pressure trends, not just the valve.

Sources

  1. Bentley Systems, AutoPIPE documentation, "Fluid Transient Method" (critical time 2L/a, Joukowsky surge, need for hydraulic analysis): docs.bentley.com.
  2. LMNO Engineering, "Water Hammer Impulse Surge Pressure" (Joukowsky equation and wave travel time, citing Wylie; Chaudhry; Hwang and Houghtalen): lmnoeng.com.
  3. A. S. Tijsseling and A. Bergant, "Pumps and valves cause water hammer" (2018), on surges above the Joukowsky value from air pockets, column separation and valve motion: PDF.
  4. Siemens, SIPART PS2 with 4 to 20 mA/HART operating instructions, parameters '10.TSUP' Setpoint ramp UP / '11.TSDO' Setpoint ramp DOWN: PDF.
  5. Rockwell Automation, Studio 5000 Logix Designer online help, "Rate Limiter (RLIM)" (IncRate / DecRate per second): rockwellautomation.com; first-scan behavior per the same page.

Instruction details were checked against the vendor documentation linked above. Behavior can change between software and firmware versions, so check the help for the version you run.

Valves banging or pumps tripping on start and stop?

We can review valve and pump sequencing, add ramps where they make sense, and trend what happens. We'll tell you when it's a job for a hydraulic engineer instead. Onsite in California's Central Valley, remote support nationwide.