Write your own controller

What is a controller, line by line? Write one in Structured Text, run it on the bench, and see how its edge cases show up in the tests.

💧 Liquid flow loopPID is the answer3 guided steps
Step 1
Step 1 of 3

The PI, written out

Pick Your own (ST) on the bench's controller list. It starts with the flow loop's PI written out in full: the error in % of span, the integral as a static, conditional integration for anti-windup, and tracking in manual. Run it and compare it with the built-in PI: the trends are identical, to the last decimal.

Comparing in this step:Built-in PIThe same PI in ST
Running the tests…
Step 2
Step 2 of 3

Leave out the edges

The same PI with the anti-windup and the manual tracking taken out (eight lines shorter). Now every test starts with a bump. Without tracking, its integral starts at zero instead of where the valve is, so its first move slams the valve (up to 54 % overshoot, IAE ten times worse). When the valve saturates it winds up too. Most of a real controller's code is about these edges, not the PID formula.

Comparing in this step:The PI in STWithout its edges
Running the tests…
Verdict
Step 3 of 3

Now yours

Open either in the bench and change it. Try a gain that grows with the error (error-squared PI), a deadband, a different anti-windup, or a setpoint ramp in the controller. The Automation view turns your code into an FB (LL_Custom) for TIA Portal (with # prefixes) or any IEC 61131-3 PLC, with the call site.

Everything in this case, through every test

Running the tests…