PID Control Loop Floating-Point Math (SIMATIC)

  Numeric (IEC)
Inputs/Outputs Operands Data Types
TBL VB BYTE
LOOP Constant (0 to 7) BYTE

Memory Ranges ENO Errors Instruction Support for S7-200 CPUs SIMATIC/International Mnemonics
The PID Loop instruction executes a PID loop calculation on the referenced LOOP based on the input and configuration information in Table (TBL).

The PID loop instruction (Proportional, Integral, Derivative Loop) is provided to perform the PID calculation. The top of the logic stack (TOS) must be ON (power flow) to enable the PID calculation. The instruction has two operands: a TBL address which is the starting address of the loop table and a LOOP number which is a constant from 0 to 7. Eight PID instructions can be used in a program. If two or more PID instructions are used with the same loop number (even if they have different table addresses), the PID calculations will interfere with one another and the output will be unpredictable.

The loop table stores nine parameters used for controlling and monitoring the loop operation and includes the current and previous value of the process variable, the setpoint, output, gain, sample time, integral time (reset), derivative time (rate), and the integral sum (bias).


Error Conditions that Set ENO = 0:

SM1.1 (overflow), SM4.3 (run-time), 0006 (indirect address)

The CPU compiler will generate a error (range error) and the compilation will fail if the loop table start address or PID loop number operands specified in the instruction are out of range.

Certain loop table input values are not range checked by the PID instruction. You must take care to ensure that the process variable and setpoint (as well as the bias and previous process variable if used as inputs) are real numbers

between 0.0 and 1.0

If any error is encountered while performing the mathematical operations of the PID calculation, then SM1.1 (overflow or illegal value) will be set and execution of the PID instruction will be terminated. (Update of the output values in the loop table may be incomplete, so you should disregard these values and correct the input value causing the mathematical error before the next execution of the loop’s PID instruction.)

Sampling Rate:

To perform the PID calculation at the desired sample rate, the PID instruction must be executed either from within a timed interrupt routine or from within the main program at a rate controlled by a timer. The sample time must be supplied as an input to the PID instruction via the loop table.

Using the PID Wizard

STEP 7-Micro/WIN 32 offers the PID Wizard to guide you in defining a PID algorithm for a closed–loop control process. Select the menu command Tools>Instruction Wizard, and then select PID from the Instruction Wizard window

PID Wizard

PID Algorithm