FB_BasicPID

FB_BasicPID 1:

The function block is a simple discretized PID element.

Transfer function:

FB_BasicPID 2:

Functional diagram:

FB_BasicPID 3:

FB_BasicPID 4: Inputs

VAR_INPUT
    fSetpointValue : LREAL; (* setpoint value *)
    fActualValue   : LREAL; (* actual value *)
    bReset         : BOOL;
    fCtrlCycleTime : LREAL; (* controller cycle time in seconds [s] *)
    fKp            : LREAL; (* proportional gain Kp (P) *)
    fTn            : LREAL; (* integral gain Tn (I) [s] *)
    fTv            : LREAL; (* derivative gain Tv (D-T1) [s] *)
    fTd            : LREAL; (* derivative damping time Td (D-T1) [s] *)
END_VAR

Name

Type

Description

fSetpointValue 

LREAL

Setpoint of the controlled variable

fActualValue   

LREAL

Actual value of the controlled variable

bReset

BOOL

TRUE at this input resets the internal state variables and the controller output.

fCtrlCycleTime

LREAL

Cycle time with which the function block is called and with which the control loop is processed [s].

The cycle time of the PLC task must be specified here if the function block is called in every PLC cycle, otherwise the corresponding multiple of the PLC cycle time.

fKp

LREAL

Controller amplification / controller coefficient

fTn

LREAL

Integral action time [s]

fTv

LREAL

Derivative action time [s]

fTd

LREAL

Damping time [s]

FB_BasicPID 5: Outputs

VAR_OUTPUT
    fCtrlOutput  : LREAL;
    nErrorStatus : UINT
END_VAR

Name

Type

Description

fCtrlOutput

LREAL

Output of the PID-element

nErrorStatus

UINT

Indicates the error number in the event of an error (nErrorStatus <> 0).

Error Codes:

Value

Constant

Error description

0

nERR_NOERROR

No error

1

nERR_INVALIDPARAM

Invalid parameter

2

nERR_INVALIDCYCLETIME

Invalid cycle time.

Requirements

Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_Utilities (System)