Explainer
Built-In PID or PLC Logic for Stable Hydraulic Pressure Control
Short answer
Run the pressure PID in your PLC logic unless the motion controller's built-in PID is documented to read the analog pressure input and write the analog speed command at a fixed interval with output limiting. A PLC loop updated every 10-20 ms is fast enough for most pump pressure loops and every step of it is verifiable in your code.

On this page
Run the pressure PID in your PLC logic unless the motion controller's built-in PID is documented, in that controller's own manual, to do three things: read your analog pressure input every cycle, write your analog speed command every cycle through the EtherCAT analog module at a fixed loop interval, and limit its output to the valid command range. If you cannot point to all three in the documentation, the PLC path is the decision. A loop updated every 10 to 20 ms in PLC code is fast enough for the pressure loop described here - a pump whose speed command holds a hydraulic system pressure - and every parameter in it is one you can trend, prove and tune.
The loop itself #
The hardware chain is simple. The motor driver receives a 0-10 V speed command from an EtherCAT analog output module. A pressure sensor on the hydraulic system outputs a 0-10 V signal proportional to pressure into an EtherCAT analog input module. The controller has to compare measured pressure against setpoint and adjust motor speed to drive that error to zero.
The same structure appears in the related problem of PID control of a bipolar proportional valve from a PLC, and the wiring discipline is the same: the analog input and the analog output are two independent scaled channels, and the control algorithm is a third, separate thing that runs between them on a timer.
What the built-in PID must prove before you use it #
A built-in PID inside a motion controller can execute faster than a PLC task and can run in the same execution context as the motion planner. Those are real advantages - but only if the loop's signals are actually in its reach. Three questions decide it, and each has a concrete check:
- Can the PID's execution context read the scaled pressure input? Some motion controllers only let the built-in PID act on motion-axis feedback - an encoder position or velocity - not an arbitrary analog channel on a fieldbus I/O module. Check the PID's documented input sources for the analog input module, not just the drive axes.
- Does it run at a fixed, documented interval that includes the EtherCAT analog write? The PID is only as deterministic as its output path. If the algorithm runs every cycle but the analog output value reaches the module only on a slower or jittery exchange, the effective loop interval is the slower one, and your tuning must be based on that.
- Does it support output limiting? Without a clamp, integrator windup during startup drives the calculated command far past the driver's full-scale command voltage, and the loop overshoots hard when pressure finally responds.
If the controller's documentation answers all three for your exact analog modules, the built-in PID is the better choice: tighter timing, no scan-time dependence, and typically built-in anti-windup. If it does not, no amount of clever PLC code changes that the built-in loop was never designed to close around a fieldbus analog channel.
Why PLC logic is the safe default #
The loop you are closing is not a fast one. A hydraulic pump-speed pressure loop has a process response measured in hundreds of milliseconds: oil is compliant, the pump and relief valve have their own lags, and pressure does not jump between two PLC scans. A PID executing in a 10-20 ms cyclic task therefore samples the process 50 to 100 times per time constant, which is comfortably inside normal tuning practice.
PLC logic also wins on verifiability. You wrote the error calculation, the scaling and the clamp yourself, so you can trend setpoint, measured pressure, error and output in the same program and see exactly what the algorithm did at each scan. When the same question shows up on a different hardware chain - controlling hydraulic cylinder position from an analog input - the same PLC structure ports over directly.
The one thing a packaged PID and a handwritten correction loop both require is the same list: correct scaling on both channels, output limiting before closed-loop enable, tuning matched to the actual execution interval, and defined behavior when the sensor reads out of range or the fieldbus exchange faults. Where the PID lives does not excuse any of those.
Scaling: the step that breaks most pressure loops #
Never treat the output voltage as pressure. The sensor input and the speed-command output are two separate channels with two separate transfer functions:
- Input: take the sensor's documented span from its datasheet - for example, a sensor whose 0-10 V output represents 0 to 250 bar. One bar is then 10 V / 250 bar = 0.04 V, so a 6.4 V reading is 6.4 / 0.04 = 160 bar. Convert the module's raw count to volts with the module's documented count-per-volt scaling first, then volts to bar with the sensor span.
- Output: take the driver's documented command interpretation - 0 V meaning zero speed and the full-scale command voltage meaning rated speed. The PID's output in engineering units maps linearly onto that span, and the clamp holds it inside it.
Worked example: one PID scan #
This is a calculated example for the stated inputs, not a measured result. Assume a PLC task at T = 20 ms, a setpoint of 160 bar, gains Kp = 0.05 V/bar, Ki = 2.5 V/(bar·s), Kd = 0, and no derivative term because the process is slow and noisy:
- Measured pressure this scan: 150 bar. Error e = 160 − 150 = 10 bar.
- Proportional term: Kp × e = 0.05 × 10 = 0.5 V.
- Integral term per scan: Ki × e × T = 2.5 × 10 × 0.02 s = 0.5 V added to the accumulated integral each scan.
- If the accumulated integral is 3.5 V after previous scans, the total command before limiting is 0.5 + 3.5 = 4.0 V.
- Clamp check: 4.0 V is within the 0-10 V command range, so 4.0 V goes out as the speed command. With a setpoint far from measurement at startup, say 60 bar of error, the same arithmetic gives 3.0 V proportional plus a growing integral; the clamp at the top of that range is what stops windup while the pump is already at full speed.
The tuning numbers here are illustrative, not a recommendation. Real gains depend on the pump's response, the relief valve setting and the actual loop interval, and you establish them by trending setpoint, measured pressure, error and output during a step change.
Commissioning sequence #
- Map and verify the channels. Read a known pressure and confirm the engineering value; command a known voltage and confirm the motor speed responds as the driver documents.
- Apply output limits before enabling closed-loop control, so the calculated command cannot leave the valid analog range.
- Start in manual: drive the pump at a fixed speed, watch measured pressure settle against the relief setting, and confirm the trend is clean enough to tune against.
- Enable the PID with low gains, step the setpoint, and trend all four signals.
- Accept the loop when pressure settles at setpoint without sustained oscillation and the output stays inside its limits through startup, a load step and a fault test (unplug or saturate the sensor path deliberately and confirm the defined fault behavior).
The decision #
- Use the built-in PID if and only if its documentation confirms all three conditions: it reads your analog pressure channel, it writes your analog command channel through the EtherCAT module at a fixed interval, and it clamps output. Then you gain tighter timing for free.
- Use PLC logic in every other case, at a 10 to 20 ms update with explicit input scaling, output clamping and anti-windup in your own code. For this class of loop - pump speed holding system pressure - the slower interval costs nothing, and the loop becomes something you can inspect line by line.
One safety note: before closed-loop pressure control is enabled at all, the hydraulic system must have its relief valve set and verified independently of the control loop, so a drive or software fault cannot take the system above its rated pressure. The relief is the machine's protection; the PID is only the regulator.
Questions asked
Is a 10-20 ms PLC update fast enough for a hydraulic pressure loop?
For a pump-and-relief or pump-speed pressure loop on a small hydraulic power unit, yes. Pressure in such a system changes over hundreds of milliseconds, so a 10-20 ms sample interval gives 50-100 samples per process time constant. Fast pneumatic or servo-valve pressure loops with sub-10 ms dynamics are the exception and need a faster execution context.
How do I scale a 0-10 V pressure sensor into engineering units?
Use the sensor's documented transfer function from its datasheet. If 0-10 V represents 0-250 bar, one bar is 0.04 V, so a 6.4 V reading is 160 bar. Scale the raw analog input count to volts first with the module's count-per-volt figure, then volts to bar with the sensor span. Never assume the span; read it off the sensor datasheet.
What must be true before I use the controller's built-in PID?
Three things, all documented, not assumed: the PID's execution context must read the analog pressure input each cycle, it must write the analog speed-command output each cycle through the EtherCAT analog module at a fixed interval you can verify, and it must support output limiting to the full command range. If any of the three is undocumented, put the loop in PLC logic.


