PID Controller Data Source
The PID Controller data source implements a closed-loop feedback controller using the standard form of the PID (Proportional-Integral-Derivative) equation. It reads a system output (process variable), compares it to a desired setpoint, and computes a control signal to drive the system toward the target. The controller uses the derivative of the process variable (not the error) to avoid derivative kick on setpoint changes.
PID controllers are fundamental to industrial process control and are used wherever a system needs to maintain a target value automatically -- temperature regulation, flow control, pressure management, speed control, and countless other applications. This data source brings PID control logic directly into Mango, eliminating the need for a separate hardware controller in many scenarios.
Overview
| Property | Value |
|---|---|
| Module | mangoAutomation-PID |
| Protocol | N/A (control) |
| Direction | Control loop |
| Typical Use | PID closed-loop process control |
Prerequisites
- At least one settable numeric data point to serve as the system input (the control output from the PID algorithm).
- At least one numeric data point to serve as the system output (the process variable being measured).
- Settable numeric data points for the P, I, D tuning parameters and the setpoint.
- A settable multistate data point for the controller mode (optional, for runtime mode switching).
- The system output point must be sampled faster than the PID data source's poll period to ensure the controller has current data.
Configuration
Data Source Settings
The PID controller uses the standard form of the PID equation:
MV(t) = Kp * [e(t) + (1/Ti) * integral(e) + Td * d(PV)/dt]
Where:
- MV(t) is the controller output (manipulated variable) at time t
- Kp is the proportional gain
- e(t) is the error (setpoint - process variable)
- Ti is the integral time
- Td is the derivative time
- PV(t) is the process variable (system output)
Some controllers use the Ideal PID form with gain parameters instead of time parameters. To convert between forms: Ki = Kp/Ti and Kd = Kp * Td.
| Setting | Description |
|---|---|
| Name | A descriptive name for the data source. |
| Update period | How often the controller computes a new output value. |
| P point | A settable numeric data point containing the proportional scale factor (Kp). |
| I point | A settable numeric data point containing the integral time (Ti). |
| D point | A settable numeric data point containing the derivative time (Td). |
| Setpoint point | A settable numeric data point containing the desired output value for the controlled system. |
| Output point | A numeric data point linked to the controlled system's measured output (process variable). |
| Input point | A settable numeric data point linked to the controlled system's input (the actuator or control element). The PID algorithm writes its computed output to this point. |
| Input filter window size | The number of point values to keep in the algorithm's historical window. Must be greater than 0. A larger window provides smoother control but slower response. |
| Control type | Either positive or negative. A positively controlled system output increases when the system input is increased. Set this to match your physical system's behavior. |
| Mode point | (Optional) A settable multistate data point for changing the controller's operating mode at runtime. |
Output Limits and Deadband
| Setting | Description |
|---|---|
| Output high limit | The maximum value the controller can set the input to. For example, a PWM output cannot exceed 100%. |
| Output low limit | The minimum value the controller can set the input to. For example, a PWM output cannot go below 0%. |
| Output deadband high range | Upper deadband to prevent the controller from making small adjustments near the setpoint, reducing actuator wear. |
| Output deadband low range | Lower deadband for the same purpose. |
| Allowable windup range | The range within which the integral term is allowed to accumulate. This is an absolute value -- for example, setting 1.0 means the integral winds up only when the process variable is within +/- 1.0 of the setpoint. This prevents integral windup when the system is far from the setpoint. |
Controller Modes
The controller supports three operating modes, controlled by the mode point's multistate value:
| Mode | Value | Description |
|---|---|---|
| Running | 2 | Normal control mode. The controller actively adjusts the input to maintain the setpoint. For smooth transitions, when switching into this mode the controller sets the setpoint to the current process variable value before beginning control. |
| Tuning | 1 | Currently identical to Running mode. Future versions will incorporate automatic tuning methods for adjusting P, I, and D parameters during runtime. |
| Off | -1 | The controller does not compute output or attempt to control the system. Use this mode when manual control is temporarily required. |
Data Point Configuration
Data points for the PID data source are automatically created when no points have been configured. These auto-created points correspond to the internal controller signals (error, integral, derivative, output) and are not user-editable. They provide visibility into the controller's internal state for monitoring and tuning purposes.
Common Patterns
HVAC Temperature Control
Configure a PID controller where the Output point reads a room temperature sensor, the Input point controls a heating valve position, and the Setpoint point holds the desired temperature. Start with conservative tuning parameters (low Kp, moderate Ti, small Td) and adjust based on the system response.
Flow Rate Regulation
Use the PID controller to maintain a constant flow rate by adjusting a pump speed or control valve. The Output point reads a flow meter, and the Input point sets the pump VFD frequency or valve position percentage.
Pressure Maintenance
Configure the controller to maintain a target pressure in a vessel or pipeline. The Output deadband settings are particularly useful here to prevent the controller from constantly cycling a compressor on and off for small pressure variations.
Tuning the Controller
A systematic approach to PID tuning:
- Start with I and D set to 0 (P-only control).
- Increase Kp until the system oscillates steadily around the setpoint.
- Reduce Kp by approximately half.
- Gradually decrease Ti (increase integral action) until the steady-state error is eliminated without excessive overshoot.
- If needed, increase Td slightly to dampen oscillations and improve response time.
Monitor the auto-created data points to observe the error, integral, and derivative terms during tuning.
Logging for Debugging
Enable detailed PID algorithm logging by setting the Log4J configuration to DEBUG for the package:
com.infiniteautomation.pid.rt
This provides per-cycle output of all PID terms, which is invaluable during tuning.
Troubleshooting
Controller Output Saturates at Limits
- Integral windup -- if the system cannot reach the setpoint (e.g., the actuator is too small), the integral term grows indefinitely. Configure the Allowable windup range to limit accumulation when the process variable is far from the setpoint.
- Output limits too tight -- verify that the high and low limits match the actual range of your actuator.
Oscillating Output
- Kp too high -- reduce the proportional gain.
- Ti too low -- increase the integral time (reduce integral action).
- Td too high -- reduce the derivative time. Excessive derivative gain amplifies noise.
- Sample rate too slow -- ensure the Output point is sampled faster than the PID update period. If the controller sees stale data, it cannot respond accurately.
No Control Action
- Verify the controller is in Running mode (mode point value = 2).
- Confirm all P, I, D, setpoint, output, and input points are enabled and have current values.
- Check that the Control type matches your system -- a positive system with negative control type (or vice versa) will drive the output in the wrong direction.
Setpoint Changes Cause Large Spikes
The PID controller uses the derivative of the process variable rather than the derivative of the error to minimize this issue (known as "derivative kick"). If spikes persist, reduce the derivative gain (increase Td) or temporarily switch the controller to Off mode before making large setpoint changes.
Related Pages
- Data Sources Overview — General data source and data point concepts
- Meta Data Source — Create derived points from calculations on other data points
- Scripting Data Source — Implement custom control algorithms in JavaScript
- Data Source Performance — Tuning update intervals for real-time control loops