This simulator closes a PID position loop around a ball-screw-style linear stage. A bounded actuator force moves a carriage toward a target while a sensor reports its position. Apply a load step, bias the sensor or make it stick at zero, and see how closed-loop control behaves when the measurement is right and when it is wrong.
• A stage with bed and rails, a drive screw and motor, a moving carriage and load, a position sensor and readhead, a PID controller indicator and mechanical travel stops. • Controls for position target (50-500 mm), Kp (40-240 N/m), Ki (0-100 N/(m·s)), Kd (5-40 N·s/m), moving mass (1-5 kg), load force applied after 4 s (-15 to 15 N), sensor bias (-20 to 20 mm), a feedback enable box and a sensor-stuck-at-zero fault. • Readouts for true stage position, measured position, controller error, actuator force, integrated error and whether the stage is at a travel stop. • Experiments for rejecting a load step and for a biased measurement, where zero measured error leaves the true position near 230 mm.
The controller command is Fcmd = Kp e + Ki∫e dt - Kd v, limited to ±60 N, acting on m dv/dt = F - 2v + Fload with travel limited to 0 to 0.6 m. The integral term accumulates error until it supplies the force needed to hold position against a constant load, so a steady offset disappears. Conditional anti-windup stops the integral growing while the actuator is saturated. A loop regulates what the sensor reports, so a biased sensor moves the true position away from the command, and a stuck sensor can keep demanding motion until the carriage hits a travel stop.
The stage is single-axis lumped mechanics with ideal actuator force, viscous drag, conditional anti-windup and hard travel bounds. It omits screw compliance, backlash, stiction, sampling delay and motor electrical dynamics. Sensor fault behavior is stated explicitly rather than randomly generated.
As long as any error remains, the integral term keeps growing, increasing the actuator force. It stops changing only when the error is zero, at which point the integral term supplies exactly the force that balances the load.
The controller drives the measured position to the target, so the true position ends up offset by the bias. With the example settings, settled zero measured error corresponds to a true position of about 230 mm.
The controller believes the stage is at zero and keeps demanding motion toward the target. Without a working measurement the stage can run until it reaches a mechanical travel stop, which the at-stop flag reports.
When the actuator force is clipped at its limit, the integrator would otherwise keep accumulating error and cause large overshoot later. Conditional anti-windup stops accumulating while the force is saturated.