AutomateDirectUSAMotion LibraryIndustrial monitors & PCs

How-to

PID speed control of a hydraulic motor with pulse feedback

Pneumatics and hydraulics Published 9 min read By AutomateDirectUSA engineering team

Short answer

Measure motor speed from its pulser: a 22 pulse/rev unit at 1000 rpm delivers about 367 Hz, which needs a hardware high-speed counter rather than a scan-time input. Convert counts to rpm over a fixed window, scale the PID output linearly onto the valve's ±10 V command around its documented neutral, then bring the loop up P-first, add integral, and compensate the valve deadband.

On this page
  1. How do you close a speed loop on a hydraulic motor?
  2. How do you mount the pulser and check it counts one revolution?
  3. Which PLC input can follow the pulser at full speed?
  4. Example: what frequency does a 22 pulse/rev pulser give at 1000 rpm?
  5. How do you turn the counter value into rpm feedback?
  6. How do you scale the PID output to the valve command?
  7. How do you bring the loop up and tune it?
  8. Questions asked

A hydraulic motor holds speed only as well as the loop behind it. Close that loop by counting the pulser on the motor shaft, converting the pulse rate into rpm, and letting a PID compare that rpm with the setpoint and drive the proportional valve's ±10 V command. Three datasheets set the design before any tuning: the pulser's pulses-per-revolution figure fixes the feedback frequency — 367 Hz at 1000 rpm, beyond what a scan-time input can count — the valve datasheet fixes the command span and its neutral, and the counter's datasheet fixes the input card. The sections below give the formulas, a worked example, and the bring-up order.

How do you close a speed loop on a hydraulic motor? #

You close the loop by counting the pulser on the motor shaft, converting its pulse rate into rpm, and letting a PID compare that rpm with the setpoint so its output moves the proportional valve's command above or below the neutral stated in the valve datasheet.

The chain is short: setpoint in rpm into the PID, PID output to the analog card, analog voltage to the valve, valve flow to the motor, pulser back to the counter, rpm back into the PID. Decide what the loop controls before configuring anything. A speed loop regulates rpm and needs the rate of change of the count; a position loop regulates accumulated angle and needs the count itself. The same pulser serves both, but the feedback processing, the scaling, and the tuning differ, and a loop configured for one will fight the other.

Keep the objective in writing before the first powered test: the setpoint is a speed in rpm, the feedback is a speed in rpm, and the output is a bidirectional voltage command whose neutral comes from the valve datasheet, not from assumption.

How do you mount the pulser and check it counts one revolution? #

Mount the pulser so its shaft turns with the motor shaft and nothing else — a shaft-driven pulser rides on a flexible shaft coupling — wire its output to the counter input whose supply voltage and output circuit it matches, then hand-turn the motor one revolution and read exactly 22 counts.

Three checks finish the mounting work. Alignment: set the coupling within the pulser maker's alignment limits from its datasheet, because misalignment shows up as count jitter and, at speed, as heat in the coupling. Edge mode: the counts-per-revolution figure on the pulser datasheet must equal the events your configured edge mode actually produces — a counter that counts both edges doubles the figure, and every formula downstream must use the doubled number. Direction: a single pulse channel counts motion but not direction, so direction knowledge comes from a second channel, a direction output, or by limiting the duty to one direction.

Verify counting across the speed range too: stable counts at top speed with no lost events is the acceptance check, and it doubles as the field test of the counter's rating.

Which PLC input can follow the pulser at full speed? #

A hardware high-speed counter is the right input: at 1000 rpm this pulser produces about 367 Hz, a rate a scan-time digital input cannot follow reliably because its reading interval and input filter both span several milliseconds.

A scan-time digital input is read once per scan and reports a level, not edges; to catch every edge by polling, the read would have to happen more than twice per pulse, and no scan schedule guarantees that. The mechanics of why a PLC misses short input pulses and how to catch them are identical on every platform, and at hydraulic-motor speeds they surface as a speed reading that sags as program load grows. A high-speed counter counts edges in hardware, independent of the scan, which is why it is the tool here.

The decision comes from hardware documents, not the controller badge: compare the frequency your top speed produces against the counter's maximum input frequency and its digital filter settings in the CPU or input module datasheet — on an S7-1200-class CPU, as on any other make, those live in the I/O documentation — and match the pulser's electrical interface to the input. Counter configuration is vendor-specific: mode, gate, and filter live in the counter's configuration, and the counter documentation of the exact part is the authority.

Example: what frequency does a 22 pulse/rev pulser give at 1000 rpm? #

At 1000 rpm, 22 pulses per revolution gives f = 22 × 1000 / 60 = 367 Hz — a pulse every 2.7 ms — so the counter must be rated above that and a 10 ms scan misses most of the edges.

  • Pulse frequency: f = P × n / 60 = 22 × 1000 / 60 = 366.7 Hz, call it 367 Hz.
  • Pulse period: T = 1 / f = 2.7 ms, so about 3.7 pulses land inside one 10 ms scan, and a once-per-scan level read can register at most one of them.
  • Feedback resolution: with a 0.1 s update window, one count moves the feedback by Δn = 60 / (22 × 0.1) = 27.3 rpm, a 2.7 % step at the example speed.
  • Decision: a hardware counter rated at least twice the top-speed frequency clears this case with margin — a rule of thumb, with the binding figure being the counter's own datasheet — and the 0.1 s window is the default trade: 27 rpm feedback steps in exchange for a 0.1 s measurement lag. Halve the window to 0.05 s and the steps double to 54.5 rpm while the measurement updates twice as often.

These are arithmetic results for those inputs, not measured or rated figures. The only rating that matters next is the counter's documented maximum input frequency, taken from the datasheet of the exact module.

How do you turn the counter value into rpm feedback? #

Compute rpm from the count change over a fixed window: n = 60 × ΔN / (P × Δt), with ΔN the counts gained, P the counts per revolution you verified at the shaft, and Δt the window in seconds from the PLC's clock, not assumed from the scan.

Time the window with the PLC's real-time clock or a hardware-timed interrupt: when program load stretches the scan, an assumed Δt skews every rpm the loop sees. Handle counter rollover, reset, and first-scan initialization explicitly, and subtract in a data type wide enough that a wrap cannot pose as a speed spike.

Quantization is not noise: the feedback moves in steps of Δn = 60 / (P × Δt) rpm per count — the value the example worked out — so a shaft turning perfectly smoothly still shows adjacent-value stepping. Widen the window, or switch to period measurement, which derives speed from the time between successive pulses and resolves far better at low rpm. Period measurement needs a no-pulse timeout chosen from the lowest speed you must resolve and how fast a stopped shaft must be reported; without it, the last computed speed freezes in place after the motor stops.

Edge losses and double counts are a failure class of their own, and counting encoder pulses on a PLC without losing position covers the usual suspects. Filter the feedback before tuning, and only lightly: every filter adds lag, and lag in the feedback path destabilizes a loop whose gains were otherwise right.

Acceptance: at a speed you trust — a tachometer on the shaft, or a driven machine whose surface speed you know — the computed rpm lands within the quantization step plus instrument uncertainty, and a stopped shaft reports zero within one window plus the timeout.

How do you scale the PID output to the valve command? #

Map the controller output linearly onto the valve command: with the PID output limited to −100 % through +100 % and a valve that accepts ±10 V, the command in volts is the output in percent times 0.1, so +40 % commands +4.0 V.

For endpoints that are not symmetric, use the general linear map: V = Vmin + (u − umin) × (Vmax − Vmin) / (umax − umin), with u the controller output and the endpoint pairs taken from the analog output module's own documentation — never from an assumed raw-value span. Confirm the installed output channel can drive a bipolar voltage at all; the controller family name does not guarantee the card behind the terminal does. If the valve is driven through its own amplifier card, that card's input range sets the endpoints instead.

The command span is an electrical fact, not a hydraulic one: the valve datasheet states the neutral command, the polarity-to-flow mapping, the permitted input range, and the behavior on loss of command — the last of those decides whether your fault logic drives the output to neutral or to zero.

Verification before any gain is tuned: automatic mode off, small manual steps around neutral, meter on the valve terminals, and the measured volts must match the mapping. Then one small positive step: the motor must turn in the sense that makes rising output reduce the speed error. A loop whose sign is wrong runs away the moment it closes; fix sign or mapping first.

How do you bring the loop up and tune it? #

Bring the loop up in that order — counter, rpm scaling, output mapping, feedback sign, then gains — and hold the first powered tests at reduced pressure with the load secured, because a speed loop signed backwards slams the valve open instead of braking.

Safety note: before powered tests, verify the relief valve setting and function, account for stored pressure, and work from the machine's risk assessment — ISO 4413, the general safety standard for hydraulic systems and their components, is the reference for those safeguards.

  1. Motor at rest: the feedback reads zero and stays there — the no-pulse timeout is doing its job.
  2. Hand-turn one revolution: the count advances by the counts per revolution you verified, in the expected direction.
  3. Manual output, auto off: meter the valve terminals at neutral and at small positive and negative steps; the measured volts must match the mapping.
  4. Sign check: one small manual step must turn the motor so that rising output moves rpm toward the setpoint.
  5. Proportional alone: raise the proportional gain until speed responds briskly without sustained oscillation, then back it off by about a third — a starting rule of thumb, not a tuned result.
  6. Add integral until the steady error disappears; if correction stays sluggish under a heavy load, the inertia side of that is covered in why PI tuning is slow on a high-inertia hydraulic drive.
  7. Leave derivative at zero as the default: pulser feedback arrives in steps, and derivative amplifies steps.
  8. Compensate the deadband: if the motor sits still over a stretch of command around neutral or lurches as the command crosses it, add a direction-dependent offset to the PID output, sized from the valve's published deadband or a ramp test — the near-neutral nonlinearity that also makes a hydraulic cylinder jerk when the valve shifts — and re-check the offset after pressure or temperature changes.
  9. Sweep the setpoint from minimum to maximum speed and back: counting holds at top speed, overshoot stays inside what the load tolerates, and the quantization steps do not keep the integral hunting.

The decision by case: one-direction duty at fixed or slowly varied speed — single-channel pulser, hardware counter, PI, one deadband offset; bidirectional duty — direction-capable feedback, the symmetric valve's documented neutral, mirrored offsets; and on every variant, the counter and pulse-loss alarms armed before the loop is trusted with load.

Questions asked

Can a ±10 V proportional valve run the motor in both directions?

Yes, if the valve is a symmetric proportional directional valve: one polarity feeds the motor one way, the opposite polarity reverses it, and the datasheet states the neutral command and the behavior when the command is lost. The feedback must then know direction, which a single pulse channel cannot, so add quadrature or a direction signal — or restrict the loop to one direction.

How fast should the PID sample on a hydraulic speed loop?

At one fixed interval, identical every cycle, chosen from the valve's step response time on its datasheet. A rule of thumb is to sample five to ten times faster than the valve can respond: sampling faster adds no control authority because the valve is the bottleneck, and sampling slower leaves the valve's own lag inside the loop, where tuning gets harder to hold across pressures and temperatures.

How large should the deadband compensation offset be?

Read it from the valve datasheet if the deadband is published; otherwise find it by test: loop in manual, load secured, ramp the command slowly from neutral until flow just starts, and record that value. Add an offset of that size to the PID output in the direction of travel and the mirrored offset for reverse, then re-check after pressure or oil temperature changes, because the deadband moves with both.

What does a lost pulse do to a running speed loop?

The counter under-reports the speed, the PID sees a false underspeed, and it opens the valve, so the motor can run away to overspeed. Arm two alarms: a counter that stops advancing while the command is nonzero, and a feedback step larger than the load can physically produce. Either one trips the output to the state the valve datasheet documents as safe.

Keep reading

  • Troubleshooting

    Why PI Tuning Is Slow on a High-Inertia Hydraulic Drive

    Your manual voltage-decrement test took the motor from 2100 to 2000 RPM in about 1 s, while the tuned PI loop manages about 3.3 RPM/s — roughly 30 times slower — so the hydraulics can respond and the slowness points to output scaling, output limits or valve-command mismatch. Fix those, then retune against the measured benchmark.

    Pneumatics and hydraulics

  • Troubleshooting

    Diagnosing a Hydraulic Winder That Stalls Under Tension

    When raising the tension command stalls the drive roll of a hydraulic winder, first measure the speed-valve command: if the controller is already at full output, the fault is hydraulic capacity — pump flow, relief setting, filter or internal leakage — not control logic. A top speed of 75 against a documented 150 m/min confirms the drive motor is getting about half its designed flow.

    Pneumatics and hydraulics

  • How-to

    Path control of a hydraulic cylinder with 4-20 mA feedback

    Yes, a 4-20 mA transducer closes a hydraulic cylinder position loop as a slow process value, never as an encoder substitute. Scale the 16 mA span to the calibrated stroke, run acquisition, trajectory, control and valve output in one fixed-period task, treat out-of-range current as a motion-stopping fault, and keep the measured input-to-output delay below the following-error budget your velocity allows. Worked example: 250 mm stroke, 200 mm/s, 25 ms budget.

    Pneumatics and hydraulics