PLC Training

PID_Compact in TIA Portal: A Beginner's Guide to Closed-Loop Control on the S7-1200

Brijin Chacko
3 min read
PID_Compact in TIA Portal: A Beginner's Guide to Closed-Loop Control on the S7-1200

From on/off to a controller

A heater switched on below setpoint and off above it works, and oscillates. A PID controller moves the output smoothly in proportion to the error, keeps pushing while any error remains, and damps the swing. On an S7-1200 or S7-1500 that controller is the PID_Compact technology object, and the PID Compact course is six modules on using it properly.

The loop around PID_Compact
The loop around PID_Compact

Rule one: a cyclic OB

PID_Compact must be called from a cyclic interrupt OB such as OB30 at a fixed interval, 100 ms is typical. Called from OB1 its sample time wobbles with the rest of the program and the loop hunts no matter how it is tuned. The organisation blocks course explains why.

Rule two: scale the signals

The analog input arrives as 0 to 27648. NORM_X turns it into 0.0 to 1.0, SCALE_X into engineering units, or you feed the raw value into Input_PER and let the controller scale it. The output leaves as a percent, a raw value through Output_PER, or a pulse train through Output_PWM for heaters and solenoid valves. Clamp the demand with LIMIT before unscaling it, so a glitch cannot pin a valve at 110 percent.

Tuning

Open the commissioning window. Pretuning makes a step and estimates gain, integral time and derivative time from the response. Fine tuning rocks the loop gently around setpoint and refines them. Then upload the values into the project; tuning that lives only in the CPU is overwritten by the next download.

Tuning in three moves
Tuning in three moves

Proving it without a tank

A free tank simulation function block takes the valve output and produces a level with lag, so the controller has something real to fight inside PLCSIM. The course ends with a setpoint, mode and trend on an HMI and the same loop in a Factory I/O level scene. A trend where the process value meets the setpoint with a small overshoot and settles in a few cycles is a good loop.

Where it goes wrong

Gain too high: overshoot and hunting. No integral: settles below setpoint and stays there. Called from OB1: hunts whatever you do. PWM period too short: the contactor chatters itself to death.

Frequently asked questions

PID_Compact or PID_3Step? PID_Compact for valves and drives with an analog or PWM output; PID_3Step for motorised valves with open and close commands.

Do I need to understand the maths? Only what P, I and D each change. The course teaches that in the first module.

Does this work on the S7-1500? Identically.

Start Your Engineering Career at EDWartens

Join as a Junior Engineer at Wartens Automation Pvt Ltd. Get hands-on PLC SCADA training, industry certifications, and a 100% Job Guarantee backed by a 100% refund policy.