Selecting PLC Control Algorithms Beyond Standard PID Loops

Patricia Callen8 min read
Other ManufacturerPID ControlTechnical Reference
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

The fix is to choose the simplest control structure that matches the measured process, then derive its constants or model from tests instead of repeated operator guesses. Use PID or PI when the process has predictable feedback and authority; use ramps, state logic, lookup tables, feedforward models, or predictive logic when gain changes, deadband, geometry, constraints, or sparse instrumentation violate those assumptions. Look at the trend first. Tuning does not fix wiring, mechanical play, poor measurements, or a final element that cannot produce the requested motion.

How should the symptoms be read?

Start at the process output and trace backward. Compare the measured variable, controller calculation, commanded output, and physical response on one time-aligned trend. A controller problem produces a different signature from bad feedback or a saturated final element.

Signal Source Wrong-value symptom
Process measurement Position, level, temperature, speed, or vision sensor Noise creates command chatter; bias creates steady offset; lag makes the controller react to old conditions.
Rate or derived state Filtered change in the process measurement Excess filtering delays detection; insufficient filtering produces false acceleration or trend estimates.
Controller output PID, PI, state logic, model, or lookup calculation Clamping indicates lost control authority; abrupt reversals indicate thresholds, noise, or discontinuous model regions.
Final-element feedback Drive, valve, actuator, or motion feedback when available A command that changes without a corresponding response points to deadband, saturation, load, mechanical play, or actuator limits.
Process response Independent observation or primary feedback Response that changes with operating point indicates variable process gain, changing load, or nonlinear geometry.

Measure disturbances as well as the controlled variable. For job changes, record the feed speed, starting condition, calculated command, operator correction, and achieved result. One implementation replaced repeated 5–20 minute adjustment cycles with a calculation based on changed feed speeds and measured results. It then operated consistently for several years, with operator adjustment retained for one exceptional case.

What mechanism makes a standard loop fail?

A feedback controller calculates error from setpoint minus measurement and moves the final element to reduce that error. Conventional tuning works when the sign and approximate gain of that relationship remain predictable, the actuator has enough authority, and feedback reveals the important process state. Problems appear when any link changes across the operating range.

Consider angular positioning of a large mass using two barely sufficient hydraulic cylinders, mechanical play, servo flow valves, and angular position as the only feedback. As the center of gravity crosses the rotation point, gravity changes its effect on motion. The process gain and required holding force change, while position alone does not reveal hydraulic pressure or flow. A two-level PID structure can therefore encounter operating points where acceptable tuning on one side becomes unstable or sluggish on the other. Cascaded bang-bang logic can be practical when the motion can be divided into explicit approach states and smooth command transitions, but its switching bands must be based on measured stopping behavior.

The same signal-chain reasoning applies elsewhere. Level control may need only proportional and integral action because derivative action would amplify measurement noise without adding useful state information. A Ziegler–Nichols calculation based on manual testing produced working P and I values in one tank application and landed close to the values already in use. That result does not make the method universal; the trend must show that the test conditions represent the process range.

When should PID give way to a custom PLC algorithm?

Keep PID or PI when error correction is the main requirement and process dynamics remain sufficiently similar throughout operation. Add a ramp when the target or output must change at a controlled rate. Use feedforward when a measurable input, such as feed speed, predicts the required command before feedback error develops.

Choose state or bang-bang logic when the machine has distinct acceleration, travel, approach, and settle regions. Cascaded switching can coordinate a coarse outer decision with a finer inner action, but thresholds need hysteresis so sensor noise cannot toggle states. For speed control, a cyclic algorithm can command constant acceleration and reduce the command as overshoot develops; validate it against actuator limits and changing load rather than treating acceleration as unlimited.

Use a lookup or strapping table when measurements describe the machine better than a compact equation. A polynomial fit may oscillate between calibration points, extrapolate badly, or require an order that is difficult to validate. In one comparison, a strapping table was more accurate than the attempted polynomial. Interpolation between measured points also makes calibration errors easier to locate.

Rotary motion and vision often justify trigonometric or kinematic models because geometry directly maps measurements to coordinated commands. Predictive logic becomes useful when both the measured value and its rate indicate an approaching limit. A cooling application combined filtered sensor data with Takagi–Sugeno fuzzy logic and produced an average 10–15 minutes of warning before rapid heating or cooling crossed service limits. Small neural networks can also run in a PLC, but use them for production only when their training range, failure behavior, execution load, and validation are controlled.

How should the replacement algorithm be built?

  1. Define the controlled outcome. State the target, acceptable error, motion quality, output limits, and operator actions. Separate normal cases from known exceptions.
  2. Map the signal chain. List each sensor, scaling operation, filter, derived value, controller state, output limiter, actuator, and physical response. Confirm engineering units and direction at every boundary.
  3. Collect manual test data. Place the system in an authorized manual condition, move through representative operating points, and record inputs, commands, outputs, and disturbances. Change one relevant variable at a time.
  4. Select the lowest-complexity structure. Compare PI or PID, ramped feedback, feedforward plus correction, state logic, a lookup table, or a physical model. Prefer a structure whose internal values an engineer can trend and explain.
  5. Calculate from measured data. Derive gains, table points, geometric terms, acceleration limits, or switching thresholds. Keep raw test records so later mechanical changes can be distinguished from programming changes.
  6. Add bounded correction. Limit commands, rate changes, integrator accumulation, and operator trim according to the machine’s documented limits. Define behavior for invalid feedback, out-of-range model input, and mode transfer.
  7. Commission by operating region. Test low and high commands, both directions, load changes, startup, stopping, and the boundary between control states. Watch the trend during every adjustment.

How is the result verified?

Verification must show cause and effect through the complete loop. Trend setpoint, raw measurement, filtered measurement, error, calculated command, limited command, controller state, operator trim, and final response. For a lookup table or fitted model, compare predicted output with measured output at calibration points and between them. Never judge a model only from the data used to create it.

Repeat the same job or motion enough times to expose variability, then change the load or starting condition within the approved operating range. Confirm that output limits do not hide a persistent error and that state transitions do not produce command steps. Test the exceptional case separately; an operator correction is acceptable only when it is bounded, visible, documented, and cannot override equipment limits.

For predictive alarms, verify both lead time and false-alarm behavior. Filtering must suppress noise without delaying a real rate change beyond usefulness. For motion logic, verify stopping distance, reversal, mechanical backlash, and behavior near geometry changes such as the center-of-gravity crossover.

What pitfalls recur with custom control?

The first pitfall is tuning before validating the measurement. Scaling errors, noisy feedback, reversed action, poor sensor placement, and intermittent wiring all propagate into the controller. More sophisticated math only makes the wrong signal harder to diagnose.

The second is compensating in software for inadequate mechanics or actuator authority. Deadband, undersized cylinders, valve saturation, and changing load can leave no command that achieves the target response. Detect and expose saturation instead of increasing gain until the system oscillates.

The third is fitting one operating point. A polynomial, PID gain set, or acceleration rule can look excellent during one test and fail at range boundaries. Partition the operating range, retain measured table points, and test interpolation, extrapolation, and state transitions explicitly.

The fourth is hiding the algorithm. Give maintenance personnel trends, state names, intermediate calculations, limits, and a controlled fallback mode. Lock production constants against casual adjustment while preserving a documented commissioning path.

FAQ

Why does a PID loop work at one position but oscillate at another?

Process gain, load direction, friction, or actuator authority may change with position. Trend the measurement, output limit, and physical response across the motion; retuning one gain set will not correct a geometry change or mechanical play.

Why does a lookup table outperform polynomial regression?

A table preserves measured calibration points and avoids unstable extrapolation or oscillation between points. Use it when the process is repeatable but its shape is not represented accurately by a practical polynomial.

Why does manual testing matter before calculating PI gains?

Manual tests reveal process direction, gain, lag, output authority, and disturbance sensitivity without a closed loop masking them. A Ziegler–Nichols calculation produced effective P and I values for one level-control application, but the test must cover the conditions where those values will operate.

When should I stop developing custom PLC control logic?

Stop when feedback is unreliable, the actuator remains saturated, required precision exceeds the mechanical system’s capability, or safe validation needs undocumented product behavior. Collect trends, configuration records, the repeatable test case, and the smallest logic example that reproduces the problem, then escalate to the manufacturer’s official support channel before changing undocumented limits or interfaces.

Back to blog