PID Loop Implemented in Ladder Program


Thread Starter

Paul Riley

I'm interested in implementing a PID loop using only regular ladder instructions in a small PLC, a Cutler-Hammer D50. Does anyone have code fragments for this?
I've put together a couple of PI loops on micro PLC's using math and timer functions. Works for loops not requiring a derivative term.

Find the error (difference) between the setpoint and the process variable.

Multiply the error by the proportional gain to find the first part of the output contribution.

Multiply the error by the integral gain to find out how much to change the output every time interval. I call this result the integral "slice".

Set up a repeating timer to add up the integral slices to get the integral contribution to the output. Be sure to reset this term to zero when the loop is off so the integral term doesn't wind up.

Sum up the proportional and integral contributions and send to the output.

Be sure to check the scaling of each math operation so the result stays within the signed 16-bit integer range (-32k / +32k) of the PLC.

Tune the loop starting with the proportional gain. Play with the integral gain and repeat timer settings to put the process variable down
to zero error.

I'm sure you could rig up a derivative term in a similar fashion.


Tom Rhodes
Pyxis Engineering Corporation