Introduction
In many industrial automation systems, maintaining a process variable (such as temperature, pressure, flow, or speed) within a desired range is critical to system stability and performance. This is typically achieved through closed-loop control, most commonly using PID control (Proportional–Integral–Derivative).
TIA Portal provides a range of function blocks for PID control, with the most modern and flexible being the PID_Compact block, which supports:
- Continuous (analog) or discrete (digital) control modes
- Manual and automatic operation
- Internal or external setpoints
- Auto-tuning of PID parameters
- Standard alarm and monitoring functionality
- Integration with HMI and Engineering Tools for monitoring and diagnostics
This chapter focuses on the practical use of the PID_Compact block for implementing reliable and maintainable PID logic in Siemens PLCs. You’ll learn how to:
- Configure the block for your specific application
- Connect inputs/outputs, setpoints, and enable logic
- Perform auto-tuning and interpret the results
- Monitor and fine-tune control performance
- Avoid common pitfalls such as scaling issues or unstable control behavior
Whether you are controlling the speed of a pump, the temperature of an oven, or the pressure in a tank, PID_Compact provides a standardized and reusable solution that integrates smoothly with the TIA Portal environment.
Overview of PID_Compact Function Block
What is PID_Compact?
PID_Compact is Siemens’ standard function block for implementing PID control in the TIA Portal environment. It is available in the Standard and Technology libraries for S7-1200 and S7-1500 PLCs.
This block encapsulates the logic needed for closed-loop PID control, and provides built-in features for:
- Automatic or manual control
- Auto-tuning of parameters (Kp, Ki, Kd)
- Multiple operation modes (continuous or discrete)
- Error handling and diagnostics
- Integration with HMI or supervisory systems
- Runtime monitoring and parameter adjustment
It is designed to be easy to configure, reusable across projects, and highly adaptable to different types of processes — from simple on/off loops to advanced analog control.
Key Features
| Feature | Description |
| Auto-tuning | Calculates optimal PID parameters based on system response |
| Manual/Auto Mode | Switch between manual output and automatic control |
| Integrated Alarms | Built-in status and error flags for diagnostics |
| Ramp & Limiter Options | Optional ramp-up/down of setpoint and output |
| External or Internal SP | Can receive setpoint from external signal or internal value |
| Multiple Control Types | Supports P, PI, or PID control logic |
| Reusable & Modular | Can be integrated inside custom FBs or project libraries |
When to Use PID_Compact
You should consider using PID_Compact if your application requires:
- Stable control of analog or continuous process variables (e.g. temperature, pressure, level, flow).
- Simple integration of PID loops into your PLC logic without implementing from scratch
- On-site or runtime tuning capability (for maintenance or commissioning)
- Integration with HMI panels to allow operators to change setpoints or monitor loop status
This block provides a standardized solution for process control that minimizes effort while ensuring maintainability and flexibility in future changes or scaling.
Block Inputs and Outputs (Simplified View)
| Port | Type | Description |
| EN | BOOL | Enable block execution |
| PV | REAL | Process Value (input measurement) |
| SP_INT | REAL | Internal Setpoint (used if SEL_SP = FALSE) |
| SP_EXT | REAL | External Setpoint (used if SEL_SP = TRUE) |
| MAN | BOOL | Manual mode active |
| MAIN_IN | REAL | Manual output value |
| OUT | REAL | Output (to actuator) |
| CTRL_ENABLE | BOOL | Enables the control algorithm |
| AUTOTUNE | BOOL | Starts the auto-tuning procedure |
| STATUS | WORD | Status word (diagnostics) |
Understanding PID Parameters and Tuning Guidelines
This section provides a detailed explanation of the core parameters used in PID control logic and offers practical tuning guidance to help you configure stable and responsive control loops using the PID_Compact function block in TIA Portal.
1. Proportional Gain (Kp)
The proportional gain determines how strongly the controller reacts to the current error — the difference between the desired value (Setpoint) and the actual value (Process Variable).
- A higher Kp leads to a faster response, but may cause overshooting or oscillation.
- A lower Kp results in a slower system response and may never fully reach the setpoint.
Tip: Start with a low value and gradually increase until you observe a slight overshoot, then reduce slightly.
2. Integral Time (Ti)
The integral term accumulates past errors over time and helps eliminate steady-state error.
- A smaller Ti means faster integral action, which can improve accuracy but might cause overshoot or instability.
- A larger Ti slows down the integral correction, making the system more stable but slower to eliminate errors.
Use integral only when your system shows a consistent offset after tuning Kp.
3. Derivative Time (Td)
The derivative term reacts to the rate of change of the error. It anticipates system behavior and dampens rapid movements.
- Small or zero Td: Has minimal effect; useful in simple systems.
- Larger Td: Can stabilize fast-changing systems but is sensitive to noise.
Avoid using Td in noisy environments (e.g., hydraulic systems).
4. Sampling Time (Ts)
Defines how often the PID loop runs. This directly affects control responsiveness and CPU load.
- Smaller Ts: Faster reaction, but more CPU-intensive and may lead to instability in slow systems.
- Larger Ts: Slower control but can be more stable and CPU-efficient.
Choose Ts based on the nature of the system.
- Fast processes (e.g. liquid level): 100–500 ms
- Slow processes (e.g. temperature): 1–5 sec
Deadband
Defines a range around the setpoint where the PID output is considered zero (no control action). This prevents the system from constantly adjusting for very small errors.
Useful in systems where minor deviations are acceptable or where actuator wear is a concern.
Tuning Process – Step-by-Step
Step 1 – Define the Main Signals
- Setpoint (SP): Desired value (e.g., 180° heading)
- Process Variable (PV): Sensor feedback (e.g., gyro value)
- Control Variable (CV): Output of the PID (e.g., valve/thruster control)
Step 2 – Understand the Process
Ask the following:
| Question | Why It Matters |
| Is the system fast or slow? | Affects Ts choice |
| Does it have inertia (e.g., temperature)? | May require lower Kp, higher Ti |
| Is it noise-sensitive? | May require Td = 0 |
Step 3 – Choose Tuning Method
Αuto-Tune (Recommended Starting Point)
PID_Compact supports automatic tuning.
- It perturbs the output slightly and learns from the system’s response.
- Suitable for systems like pressure, temperature, flow.
Manual Tuning
Start with:
- Kp = 0.5
- Ti = 60s
- Td = 0
Then:
Step 4 – Tune Sampling Time (Ts)
| System Type | Siggested Ts |
| Fast | 0.1 – 0.5s |
| Slow | 1 – 5s |
Step 5 – Observe and Adjust
| Behavior | Action |
| Oscillates | Decrease Kp, increase Ti |
| Too Slow | Increase Kp, reduce Ti |
| Overshoot | Add small Td or reduce Kp |
| Constant error | Reduce Ti |
If you found this helpful, please consider supporting with a small donation. Thank you!
Leave a Reply