Notes on the documentation

This description is only intended for the use of trained specialists in control and automation engineering who are familiar with the applicable national standards.
It is essential that the following notes and explanations are followed when installing and commissioning these components.

The responsible staff must ensure that the application or use of the products described satisfy all the requirements for safety, including all the relevant laws, regulations, guidelines and standards.

Disclaimer

The documentation has been prepared with care. The products described are, however, constantly under development.
For that reason the documentation is not in every case checked for consistency with performance data, standards or other characteristics.
In the event that it contains technical or editorial errors, we retain the right to make alterations at any time and without warning.
No claims for the modification of products that have already been supplied may be made on the basis of the data, diagrams and descriptions in this documentation.

Trademarks

Beckhoff®, TwinCAT®, EtherCAT®, Safety over EtherCAT®, TwinSAFE® and XFC® are registered trademarks of and licensed by Beckhoff Automation GmbH.
Other designations used in this publication may be trademarks whose use by third parties for their own purposes could violate the rights of the owners.

Patent Pending

The TwinCAT Technology is covered, including but not limited to the following patent applications and patents:
EP0851348, US6167425 with corresponding applications or registrations in various other countries.

Copyright

© Beckhoff Automation GmbH & Co. KG, Germany.
The reproduction, distribution and utilization of this document as well as the communication of its contents to others without express authorization are prohibited.
Offenders will be held liable for the payment of damages. All rights reserved in the event of the grant of a patent, utility model or design.


Overview

The TwinCAT temperature controller is a universally applicable PLC block for monitoring and controlling a wide variety of temperature-dependent processes. The controller can be operated in

  • automatic (closed loop) and
  • manual (open loop)

modes.

The control value can be accessed in digital or analogue form. The digital control value is pulse width modulated (PWM). A two-point or three-point output is also available. The control value is limited to the permitted maximum and minimum values.

The set value is also limited to permitted minimum and maximum values, and can also be ramped. A bit is available in the interface to the block that provides easy switching from the set value to a standby set value. A soft start can be parameterised to support "heater baking". This involves the set value (optionally ramped) being initially set to a low value, remaining there for a certain time, then being changed to the true set value (again optionally ramped).

The actual value can be digitally filtered.

The control algorithm is PID-based. An additional pre-regulator can be inserted in order to minimise overshoot.

The controller has a variety of parameterisable monitoring functions. There is

  • tolerance band monitoring (two different tolerance bands),
  • absolute value monitoring,
  • sensor monitoring (open, back voltage, reverse) and
  • monitoring of the heating current (open, short circuit, leakage current).

There is an algorithm for determination of optimal controller parameters that greatly simplifies the process of commissioning the controller. This algorithm evaluates a step, and uses a method of inflectional tangents to determine the maximum speed and delay time of the loop. This data allows a controller to be specified according to the rules of Chien, Hrones and Reswick. The parameters for the pre-controller are also determined here. If the controller parameters are already known, then the controller can also be operated using these externally supplied parameters.

Commissioning the controller in stages

Documentation of the Function Block and the structures.

For compatibilty reasons the documentation of the old Temperature Controller Function Block and structure is also included in this document.


Block Diagram

The TwinCAT Temperature Controller consists of a number of function blocks. The following function blocks are involved:

  • Self-tuning algorithm (FB_Selftuner)
  • Control algorithm (FB_ControlAlgorithm)
  • Set value generator (FB_SetpointConditioner)
  • Control value generator (FB_ControlValueConditioner)
  • Alarming (FB_Alarming)

These function blocks in turn call a number of other subsidiary function blocks.

The diagram illustrates the individual function blocks.


Generating the Set Value

One bit switches between the set values. In addition to the actual set value, there is also a standby set value. The standby set value can be used to reduce the temperature during operating pauses to a lower value in order to save power. If necessary the steps in the set value can be ramped. The parameter set for the set values includes a rate of rise and a rate of fall.

The set values are restricted to their limits.

In order to permit "heater baking", a soft start can be parameterised. In this case, the temperature is first ramped up from ambient to a low set value (fWStartUp). This temperature is them maintained for a period of time (tStartUp), and only after that has elapsed does the ramp up to the actual set value begin.

Start-up


Generating the Control Value

The control value (CV) calculated by the controller is first limited to fall within a valid range. The values of the limits are passed to the controller block in the control value structure. The control value is made available in three different ways. The control value can be picked up in analogue form. However it is more usual for the digital output to take the form of a pulse width modulated signal. The cycle time required for the pulse width modulation is supplied to the controller in the control value structure. Additionally, a two-point output (for heating or cooling) and a three-point output (for heating and cooling) can be connected.


Control Algorithm

The heart of the TwinCAT Temperature Controller is a standard PID controller. This controller kernel also supports anti-reset windup measures to limit the I-component if the control value is subjected to limiting. Since the controller has been designed to minimise disturbances using the adjusting procedure according to Chien, Hrones and Reswick, overshoot is possible when the set point is changed. In order to reduce such overshoot, a pre-controller can be inserted to handle changes in the set point. The pre-regulator has a D-T1 characteristic, and reduces ringing in the controller as a whole. Since the D component of the pre-controller has the effect of "roughening" the control value, the use of a pre-controller must be considered very carefully. The pre-controller is switched off when the actual value enters within a certain range of the set value and remains there for some length of time. The pre-controller is switched off by ramping it down over a considerable period of time. To minimise oscillation of the control value, it is optionally possible to follow the main controller with a filter. P-T1 and moving average filters are available for this purpose.


Alarming

The following alarm conditions are continuously monitored by the temperature controller:

  • Absolute temperatures (high and low)
  • Relative temperatures (in two bands around the set value)

The following hardware conditions related to the sensor can also be linked to the temperature controller:

  • Open thermocouple: broken wire to the temperature sensor
  • Back voltage: a voltage outside the permitted range is present at the temperature sensor
  • Reverse thermocouple: temperature sensor is connected with the wrong polarity

If a current sensor is connected, then the following signals can be linked to the temperature controller:

  • Short circuit
  • Open circuit
  • Leakage current


Self-tuning

The self-tuning algorithm is based on the classic inflectional tangents method. This method was first developed by Ziegler and Nichols. It is assumed that a linear P-T1 loop with a delay time is being examined. The maximum rate of change is determined following an experimental step. This is achieved through examining the differences over a number of samples. A tangent is constructed to the point where the rate of change is a maximum, and its intersection with the time axis is found. The delay time, Tu, is the time from the start of the measurement up to the intersection of the inflection tangent and the time axis. Knowing Tu and Vmax, the Chien, Hrones and Reswick formula yields the controller parameters for suppression of disturbances with 20% overshoot. The parameters for the pre-controller can easily be derived from the parameters for the main controller with the aid of heuristic formulae. After completion of the self-tuning these parameters are used in an automatic switch to closed loop operation.


Regelalgorithmus

TS4110 | TwinCAT PLC Temperature Controller

Sampe

The Sampleprogram has one MAIN_Simu program. The process is a simulated second order process with optional noise on the output. Use TwinCAT ScopeView to sample the data to a TwinCAT ScopeView.


Commisioning the Controller in Stages

The following steps must be taken:

  • The controller library must be added to the project using the library manager.

TcTempCtrl.lib is to be added in the library manager.

  • At least one instance of the controller must be programmed.

An instance of the FB_TempController block is to be created. It is also necessary for an instance of tge ST_Controllerparameter structure to be created.

  • Perform the required external connection.

Name |  | Beschreibung
eCtrlMode | Connection necessary | Switches controller to different operating modes (active, passive, tuning)
bSelSetpoint | Connection optional | Selects one of two possible set values. FALSE selects the normal set value, while TRUE selects the standby set value.
fW1 | Connection necessary | Set value.
fW2 | Connection optional | Standby set value, generally smaller than fW1. fSelSetpoint can be used to switch between fW1 and fW2.
fX | Connection necessary | Actual value. This value must be converted to LREAL.
fYManual | Connection optional | Control value in manual mode.
bOpenThermocouple | Connection optional | The thermocouple is open if TRUE. Must be indicated by the hardware (e.g. KLxxxx).
bReverseThermocouple | Connection optional | TRUE indicates that the thermocouple has been connected with the wrong polarity. Must be indicated by the hardware.
bBackVoltage | Connection optional | TRUE indicates that the input voltage at the thermocouple is too high. Must be indicated by the hardware.
bLeakage | Connection optional | TRUE indicates that leakage current has been detected at the heating element. Must be indicated by the hardware.
bShortCircuit | Connection optional | TRUE indicates that a short circuit has been detected at the heating element. Must be indicated by the hardware.
bOpenCircuit | Connection optional | TRUE indicates that an open circuit has been detected at the heating element. Must be indicated by the hardware.
sControllerParameter | Connection necessary | General parameters (sampling rate etc.) are passed to the block in this structure.
sParaControllerExternal | Connection optional | An external controller parameter set is passed to the block in this structure.
  • Perform the necessary parameterisation of the controller via the structure.

The parameters can be specified through initial values, or by assignment. If initial values are used, then the instance of the structure with initial values looks like this:

(* parameters *)
sControllerParameter : ST_CTRL_TempCtrlParameter :=
(
(* base *)
tCtrlCycleTime := t#1000ms,
tTaskCycleTime := t#10ms,

fYMin := -100,
fYMax := 100,
tPWMCycleTime := t#100ms ,
fYManual := 20,
bFilter := FALSE,
tFilter := t#100ms,
bDeadband := FALSE,
fEDeadband := 1.0, (* deadband *)
fWMin := 15,
fWMax := 60,
fWStartUp := 20.0,
tStartUp := t#160s,
fWVeloPos := 0.01,
fWVeloNeg := 0.01,
bStartUpRamping := FALSE,
fWStartUpVeloPos := 0.1,
fWStartUpVeloNeg := 0.1,
iMode := eCTRL_ControlMode_HEATING,
dwAlarmSupp := 16#FF_FF_FF_FF,
bSelCtrlParameterSet:= FALSE,

(* tuninig *)
iTuningMode := eCTRL_TuneMode_heating,
fYTuneHeating := 100.0,
fYTuneCooling := -100.0,
fEndTunePercentHeating := 80.0, (* switch to closed loop
control when X > 0.8*W *)
fEndTunePercentCooling := -70.0, (* switch to closed loop
control when X < 0.2*W *)

iReactionOnFailure :=
eCTRL_ReactionOnFailure_StopController,
TempLow := -50.0,
TempLowLow := -100.0,
TempHigh := 100.0,
TempHighHigh := 155.0,
TempAbsoluteHigh := 150.0,
TempAbsoluteLow := -95.0,
bEnablePreController := FALSE,
bEnableZones := FALSE,
bEnableCVFilter := FALSE,
iFilterType := eCTRL_FilterType_AVERAGE,
iControllerType := eCTRL_ControllerType_PID
);

The marked parameters are optional, and only need to be initialised if they are needed.

Assignment in the code can look like the following in ST:

sControllerParameter.tPWMCycleTime :=
t#100ms;
  • Specification of the controller sampling time, that task cycle time and the PWM cycle time

The controller's sampling time must be adapted to the particular process. It should be selected to be equal to or less than one tenth of the loop's dominant time constants. The task cycle time is specified by the PLC task from which the controller block has been called. This value can be read from the task configuration (PLC Control: Resources Task Configuration). The PWM cycle time is usually equal to the controller cycle time. If the task cycle time is 10ms and the PWM cycle time (=controller sampling time) is chosen to be 100ms, then a total of 10 levels (PWM cycle time / task cycle time) are available.

  • Parameterisation of TwinCAT Scope

To check the results, a scope examination should always be made of the tuning process and of the closed loop regulation behaviour. To do this, TwinCAT Scope View should be started and parameterised. The following channels should be recorded: set value (fW1 or fW2), actual value (fX) and the analog control value (fYAnalog).

  • Switching off the Alarms during the Commissioning Phase

The alarms can be temporarily switched off during the commissioning phase. An appropriate bit mask must be written into the dwAlarmSupp data word. If a bit is set in this data word, the corresponding alarm is disabled. The assignment of the individual alarms is described here.

Warning: All the required alarms should be switched on again after the initial commissioning!

  • Starting the Controller with Tuning

If the controller parameters are to be determined with the aid of the Tuning system, the bOn and bTune inputs must both be TRUE. A fixed waiting period of 20s first elapses. During this waiting period the temperature is monitored to ensure that it remains within a +-1°C band. If the temperature goes outside this band, the waiting starts again. The process is then subjected to a step excitation with a magnitude of fYTune. The process then reacts with the step response. As long as 80% of the set value is not reached, the process parameters are determined using the inflectional tangent method. For safety reasons, after 80% of the set value has been reached, control is switched over to closed loop control. If the temperature reaches the 80% mark too quickly (with no clear inflection) then the value of fYTune is to be reduced. The parameters determined in this way are used for the PID controller, and are provided in a structure at the output of the controller.

Warning: A step of at least 40°C must be used for the purposes of tuning. Smaller steps can result in incorrect parameter determination!

Warning: When tuning is finished successful eCtrlState is set to eCTRL_STATE_TUNED. Controller waits for new command. If control mode is set eCTRL_MODE_ACTIVE the controller starts in Closed-Loop-mode with the new parameter set from tuning.

  • Linking the Internal Control Parameters with the External Connections

The controller parameters determined in the tuning process can be supplied again to the controller as external parameters. This may be necessary if the Tuning is only to be carried out once (e.g. only during the initial commissioning). To do this, the sParaControllerInternal structure is fed back to the controller's sParaControllerExternal input, and the bSelCtrlParameterSet flag set to TRUE.

  • Fine tuning

The control parameters determined in the Tuning process are designed to produce fast settling, with about 10% overshoot. If only very little overshoot is permitted, or even none at all, then the following parameters from the ST_ControllerParameter structure can be used to perform fine tuning. These values should be considered only as a guide.

Behaviour | fTuneKp | fTuneTn | fTuneTv | fTuneTd
Fast settling with overshoots of 10%-20% | 1.2 | 2.0 | 0.42 | 0.25
Slower settling with low overshoot | 1.0 | 2.5 | 0.42 | 0.25
Almost asymptotic settling with extremely small overshoot | 0.5 | 3.0 | 1.0 | 0.25


FB_TempController

TS4110 | TwinCAT PLC Temperature Controller

FB_CTRL_TempController

The temperature controller block FB_CTRL_TempController has a variety of inputs and outputs that are described below. All the controller's parameters are passed to it via structures. The structures and enums are defined here.

Function Block

Interface

VAR_INPUT
    eCtrlMode : E_CTRL_MODE; (* controller mode: passive, activ,
check *)
    bSelSetpoint : BOOL; (* FALSE = setpoint 1, TRUE = setpoint 2
*)
    fW1 : FLOAT; (* first setpoint *)
    fW2 : FLOAT; (* second setpoint *)
    fX : FLOAT; (* actual value *)
    fYManual : FLOAT; (* manual control value *)
    (* alarming inputs *)
    bOpenThermocouple : BOOL; (* thermocouple *)
    bReverseThermocouple : BOOL;
    bBackVoltage : BOOL;
    bLeakage : BOOL; (* heating system *)
    bShortCircuit : BOOL;
    bOpenCircuit : BOOL;
    sParaControllerExternal : ST_CTRL_ParaController; (* external
controller parameter set *)
END_VAR
VAR_IN_OUT
    sControllerParameter : ST_CTRL_TempCtrlParameter; (* controller
parameter set *)
END_VAR
VAR_OUTPUT
    (* control output *)
    fYAnalog : FLOAT; (* control value analog *)
    bYPWMPos : BOOL; (* control value PWM *)
    bYPWMNeg : BOOL; (* control value PWM *)
    bYDigPos : BOOL; (* 3-Point: control value digital positive
*)
    bYDigNeg : BOOL; (* 3-Point: control value digital
negative*)
    (* alarming *)
    dwAlarm : DWORD; (* max. 32 alarms *)
    (*quality of control*)
    fMaxOverShoot : FLOAT;
    tStartUpTime : TIME;
    (* state *)
    eCtrlState : E_CTRL_STATE := eCTRL_STATE_IDLE;
    (* controller parameter *)
    sParaControllerInternal : ST_CTRL_ParaController;
    (* general errors *)
    bError : BOOL;
    eErrorId : E_CTRL_ErrorCodes;
END_VAR

Inputs

Name | Unit | Range | Description
eControlMode | 1 | E_CTRL_MODE | Switches modes.
bSelSetpoint | 1 | [TRUE,FALSE] | Selects one of two possible set values. FALSE selects the normal set value, while TRUE selects the standby set value.
fW1 | °C | LREAL | Setpoint
fW2 | °C | LREAL | Standby set value, generally smaller than fW1. fSelSetpoint can be used to switch between fW1 and fW2.
fX | °C | LREAL | Actual value. This value must be converted to LREAL.
fYManual | -100% - +100% | LREAL | Control value in manual mode.
bOpenThermocouple | 1 | [TRUE,FALSE] | The thermocouple is open if TRUE. Must be indicated by the hardware (e.g. KLxxxx).
bReverseThermocouple | 1 | [TRUE,FALSE] | TRUE indicates that the thermocouple has been connected with the wrong polarity. Must be indicated by the hardware.
bBackVoltage | 1 | [TRUE,FALSE] | TRUE indicates that the input voltage at the thermocouple is too high. Must be indicated by the hardware.
bLeakage | 1 | [TRUE,FALSE] | TRUE indicates that leakage current has been detected at the heating element. Must be indicated by the hardware.
bShortCircuit | 1 | [TRUE,FALSE] | TRUE indicates that a short circuit has been detected at the heating element. Must be indicated by the hardware.
bOpenCircuit | 1 | [TRUE,FALSE] | TRUE indicates that an open circuit has been detected at the heating element. Must be indicated by the hardware.
sControllerParameter | none | Structure | General parameters (sampling rate etc.) are passed to the block in this structure.
sParaControllerExternal | none | Structure | An external controller parameter set is passed to the block in this structure.

Outputs

Name | Unit | Range | Description
fYAnalog | none | LREAL | Analogue control value.
bYPWMPos | none | [TRUE,FALSE] | Boolean output, pulse width modulated (positive, heating)
bYPWMNeg | none | [TRUE,FALSE] | Boolean output, pulse width modulated (negative, cooling)
bYDigPos | none | [TRUE,FALSE] | Boolean output of a three-point controller (TRUE control value 100%, FALSE control value off)
bYDigNeg | none | [TRUE,FALSE] | Boolean output of a three-point controller (TRUE control value -100%, FALSE control value off)
dwAlarm | none | DWORD | Alarm signals (see ENUM ...)
fMaxOverShoot | °C | LREAL | max. overshoot in °C under/over setpoint
tStartUpTime | TIME | - | rising time until the first time reaching the setpoint.
eCtrlState | none | E_CTRL_STATE | actuel state of the controller (s. ENUM ...)
sParaControllerInternal | none | Struktur | PID controller parameter from tuning.
bError | none | [TRUE,FALSE] | If an error is present, then bError is TRUE.
iErrorId | none | INT | If bError is TRUE, then iErrorId provides an error code (see ENUM ...)


Structure definitions

ST_ControllerParameter

TYPE ST_CTRL_TempCtrlParameter:
STRUCT

(***********************************************************************)

    (* general parameters *)
    iMode : E_CTRL_ControlMode; (* 1=heating, 2=cooling,
3=heating&cooling *)
    iReactionOnFailure : E_CTRL_ReactionOnFailure; (* 0=controller
off, 1=manual op, 2=yMin, 3=yMax *)
    bSelCtrlParameterSet : BOOL; (* FALSE = internal set, TRUE =
external set *)
    dwAlarmSupp : DWORD; (* alarm suppression *)
    tCtrlCycleTime : TIME; (* controller cycle time *)
    tTaskCycleTime : TIME; (* plc task cycle time *)

(***********************************************************************)

    (* tuning parameteer *)
    iTuningMode : E_CTRL_TuneMode; (* only heating, only cooling,
first heating then cooling or vice versa *)
    tTuneStabilisation : TIME := t#20s; (* wait for a stable system
*)
    fEndTunePercentHeating : FLOAT := 80.0; (* switch to closed
loop control when X > 0.8*W *)
    fYTuneHeating : FLOAT; (* step change while tuning operation
*)
    fYStableHeating : FLOAT; (* tuning operation *)
    fEndTunePercentCooling : FLOAT := 20.0; (* switch to closed
loop control when X < 0.2*W *)
    fYTuneCooling : FLOAT; (* step change while tuning operation
*)
    fYStableCooling : FLOAT; (* tuning operation *)
    fScalingFactor : FLOAT := 1.0; (* Scaling factor for KP
heating/cooling *)

(***********************************************************************)

    (* setpoint parameters  *)
    fWMin : FLOAT; (* lower limit *)
    fWMax : FLOAT; (* upper limit *)
    (* start up *)
    bEnableSoftStart : BOOL; (* FALSE = no soft start, TRUE = soft
start *)
    bEnableRamping : BOOL; (* FALSE = no ramping, TRUE = ramping
*)
    fWStartUp : FLOAT; (* soft start plateau setpoint *)
    tStartUp : TIME; (* soft start waiting time*)
    bStartUpRamping : BOOL; (* enable ramping while start up phase
*)
    fWStartUpVeloPos : FLOAT; (* max gradient for increasing
setpoint in start up phase*)
    fWStartUpVeloNeg : FLOAT; (* max gradient for decreasing
setpoint in start up phase *)
    fWVeloPos : FLOAT; (* max gradient for increasing setpoint
*)
    fWVeloNeg : FLOAT; (* max gradient for decreasing setpoint
*)

(***********************************************************************)

    (* actual value parameters      *)
    bFilter : BOOL;
    tFilter : TIME;

(***********************************************************************)

    (* deadband parameters      *)
    bDeadband : BOOL;
    fEDeadband : FLOAT; (* deadband *)

(***********************************************************************)

    (* control value parameters      *)
    fYMin : FLOAT; (* lower limit *)
    fYMax : FLOAT; (* upper limit *)
    fYManual : FLOAT;  (* manual operation*)
    fYOnFailure : FLOAT; (* control value on failure *)
    tPWMCycleTime : TIME; (* PWM: period *)
    tPWMMinOffTime : TIME; (* PWM: min off time *)
    tPWMMinOnTime : TIME; (* PWM: min on time *)
    tPWMWaitingTime : TIME; (* PWM: min waiting time *) (* not yet
implemented !!!!*)
    fYThresholdOff : FLOAT; (* 3-Point: Off threshold *)
    fYThresholdOn : FLOAT; (* 3-Point: On threshold *)
    nCyclesForSwitchOver : INT := 100;

(***********************************************************************)

    (* controller settings       *)
    bEnablePreController: BOOL; (* enable precontroller *)
    bEnableZones : BOOL; (* enable zone around setpoint with open
loop control *)
    bEnableCVFilter : BOOL; (* enable filter for CV (type see
iFilterType) *)
    iFilterType : E_CTRL_FilterType; (* filtertype of CV filter
*)
    iControllerType : E_CTRL_ControllerType; (* used controller
normally PID *)

(***********************************************************************)

    (* min max temperatures       *)
    TempLow          : FLOAT;
    TempLowLow : FLOAT;
    TempHigh : FLOAT;
    TempHighHigh : FLOAT;
    TempAbsoluteHigh : FLOAT;
    TempAbsoluteLow : FLOAT;

(***********************************************************************)

    (* internal tuning parameters *)
    fTuneKp : FLOAT := 1.2;
    fTuneTn : FLOAT := 2.0;
    fTuneTv : FLOAT := 0.42;
    fTuneTd : FLOAT := 0.25;
END_STRUCT
END_TYPE

Description

Name | Unit | Range | Description
General Parameters |  |  |
iMode | none | INT | Controller operating mode (1 = heating, 2 = cooling, 3 = heating & cooling) (see below)
iReactionOnFailure | none | INT | Parameterisable reaction to errors (see below)
bSelCtrlParameterSet | none | BOOL | TRUE = external parameter set, FALSE = internal parameter set (from tuning)
dwAlarmSupp | none | DWORD | Masks out the alarms (see below)
tCtrlCycleTime | s | TIME | Controller's sampling time. In the course of the sampling time the controller re-calculates the control value.
tTaskCycleTime | s | TIME | Task cycle time. The FB is called with this time interval.
tuning parameters |  |  |
iTuningMode | K | E_CTRL_TuneMode | Selects how tuning should be done (see below)
tTuneStabilisation | s | TIME | Waiting time (stabilisation of process) until step for tuning is switched on.
fEndTunePercentHeating | % | (L)REAL | percent of setpoint when controller stops tuning and waits for switching to closed loop control
fYTuneCooling | K | (L)REAL | Control value for tuning step in cooling mode.
fYStableCooling | K | (L)REAL | Control value for stabilizise process before cooling tuning starts.
fScalingFactor | none | (L)REAL | Scaling factor: if only heating tuning was done cooling parameters are heating parameter*scaling factor
setpoint parameters |  |  |
fWMin | K | (L)REAL | Minimum value of the control variable.
fWMax | K | (L)REAL | Maximum value of the control variable.
bEnableSoftStart | none | BOOL | FALSE = no soft start, TRUE = soft start
bEnableRamping | none | BOOL | FALSE = no ramping, TRUE = ramping
fWStartUp | K | (L)REAL | Setpoint while soft start phase
tStartUp | s | TIME | Waiting time in soft start phase
bStartUpRamping | none | [TRUE,FALSE] | Enables ramping in soft start phase
fWStartUpVeloPos | K/s | (L)REAL | Rate of rise (of ramp) during the start-up phase.
fWStartUpVeloNeg | K/s | (L)REAL | Rate of fall (of ramp) during the start-up phase.
fWVeloPos | K/s | (L)REAL | Rate of rise (of ramp).
fWVeloNeg | K/s | (L)REAL | Rate of fall (of ramp).
actual value parameters |  |  |
tFilter | s | TIME | Time constant of the actual value filter (first order P-T1 filter)
bFilter | none | [TRUE,FALSE] | The actual value filter is actuated if TRUE.
deadband parameters |  |  |
bDeadband | none | [TRUE,FALSE] | TRUE = Deadband on, FALSE = Deadband off
fEDeadband | K | (L)REAL | Size of deadband in °C
control value parameters |  |  |
fYMin | none | (L)REAL | Minimum value of the control variable.
fYMax | none | (L)REAL | Maximum value of the control variable.
fYManual | none | (L)REAL | Control value in manual operation.
fYOnFailure | none | (L)REAL | Control value in case of error (parameterisable).
tPWMCycleTime | s | TIME | Cycle time of the PWM signal.
tPWMMinOffTime | s | TIME | PWM: minimal off time
tPWMMinOnTime | s | TIME | PWM: minimal on time
tPWMWaitingTime | s | TIME | PWM: waiting time before switching vorm heating to cooling and vice versa
fYThresholdOff | % | (L)REAL | 3-Step: Off threshold
fYThresholdOn | % | (L)REAL | 3-Step: On threshold
nCyclesForSwitchOver | none | INT | Number of cycles in which a change of parameter set is done (smooth switching)
controller Parameters |  |  |
bEnablePreController | none | [TRUE,FALSE] | Switches pre-controller on
bEnableZones | none | [TRUE,FALSE] | Switches open loop characteristic on until close to set value.
bEnableCVFilter | none | [TRUE,FALSE] | Switches on control value filter following the main controller.
iFilterType | none | ENUM | Selection of a filter type for the control value filter following the main controller (see below).
iControllerType | none | ENUM | Selection of a control algorithm (see below).
alarming parameters |  |  |
TempLow | K | (L)REAL | Relative lower temperature limit in the first band.
TempLowLow | K | (L)REAL | Relative lower temperature limit in the second band.
TempHigh | K | (L)REAL | Relative upper temperature limit in the first band.
TempHighHigh | K | (L)REAL | Relative upper temperature limit in the second band.
TempAbsoluteHigh | K | (L)REAL | Absolute upper temperature limit.
TempAbsoluteLow | K | (L)REAL | Absolute lower temperature limit.
for experts only parameters |  |  |
fTuneKp | none | (L)REAL | FineTuning parameter for PID controller
fTuneTn | none | (L)REAL | FineTuning parameter for PID controller
fTuneTv | none | (L)REAL | FineTuning parameter for PID controller
fTuneTd | none | (L)REAL | FineTuning parameter for PID controller

Description

ST_CTRL_ParaController

TYPE ST_CTRL_ParaController :
STRUCT
    (* Controller parameter set - heating *)
    KpHeat : FLOAT;
    TnHeat : TIME;
    TvHeat : TIME;
    TdHeat : TIME;
    (* Controller parameter set - cooling *)
    KpCool : FLOAT;
    TnCool : TIME;
    TvCool : TIME;
    TdCool : TIME;
END_STRUCT
END_TYPE

Description

Name | Unit | Range | Description
KpHeat | keine | (L)REAL | Heating: Amplification factor for the main controller.
TnHeat | s | TIME | Heating: Integral-action time for main controller (I component).
TvHeat | s | TIME | Heating: Derivative action time for main controller (D component).
TdHeat | s | TIME | Heating: Damping time for the main controller.
KpCool | keine | (L)REAL | Cooling: Amplification factor for the main controller.
TnCool | s | TIME | Cooling: Integral-action time for main controller (I component).
TvCool | s | TIME | Cooling: Derivative action time for main controller (D component).
TdCool | s | TIME | Cooling: Damping time for the main controller.

ENUM: E_CTRL_ERRORCODES

s. Documentation of TcControllerToolbox

ENUM: E_CTRL_ReactionOnFailure

Name | Description
eCTRL_ReactionOnFailure_NoFailure | No error..
eCTRL_ReactionOnFailure_StopController | If there is an error (an alarm) the controller will stop.
eCTRL_ReactionOnFailure_SetManMode | If there is an error (an alarm) the controller will switch to manual operation.
eCTRL_ReactionOnFailure_SetYMax | If there is an error (an alarm) set the control value to its maximum.
eCTRL_ReactionOnFailure_SetYMin | If there is an error (an alarm) set the control value to its minimum.
eCTRL_ReactionOnFailure_SetYMean | If there is an error (an alarm) set the control value to the average control value (not yet implemented)

ENUM: E_CTRL_ControllerStateInternal

Name | Description
E_CTRL_ControllerStateInternalHeating | internal
E_CTRL_ControllerStateInternalCooling | internal

ENUM: E_CTRL_ControlMode

Name | Description
eCTRL_ControlMode_HEATING | Heating only.
eCTRL_ControlMode_COOLING | Cooling only.
eCTRL_ControlMode_HEATING_COOLING | Heating and cooling.

ENUM: E_CTRL_STATE

s. Documentation of TcControllerToolbox.

ENUM: E_CTRL_STATE_TUNING

Name | Description
eCTRL_STATE_TUNING_INIT | Tuning: Initialisation
eCTRL_STATE_TUNING_IDLE | Tuning: wainting for a stable actual value
eCTRL_STATE_TUNING_PULSE | Tuning: not yet realized
eCTRL_STATE_TUNING_STEP | Tuning: Tuning with step reponse
eCTRL_STATE_TUNING_READY | Tuning: Calculation of parameters
eCTRL_STATE_TUNING_ERROR | Tuning: Error while tuning.

ENUM: E_CTRL_TuneMode

Name | Description
eCTRL_TuneMode_HEATING | Tuning: only heating
eCTRL_TuneMode_COOLING | Tuning: only cooling
eCTRL_TuneMode_HEATING_COOLING | Tuning: first heating, then cooling
eCTRL_TuneMode_COOLING_HEATING | Tuning: first cooling, then heating
eCTRL_TuneMode_OSCILLATION | Tuning: on-the-fly tuning with a defined oscillation (in planning)

ENUM: E_CTRL_FilterType

Name | Description
eCTRL_FilterType_FIRSTORDER | first order filter
eCTRL_FilterType_AVERAGE | moving average filter

ENUM: E_CTRL_ControllerType

Name | Description
eCTRL_ControllerType_PID | Standard-PID controller
eCTRL_ControllerType_PI | Standard-PI controller
eCTRL_ControllerType_PID_Pre | Standard-PID controller with pre-controller(in preparation).
eCTRL_ControllerType_PIDD2 | Special PID controller (in preparation)

Bit-Masken für Alarme

Name | Mask | Description
nAlarmOpenThermocouple | 2#0000_0000_0000_0000_0000_0000_0000_0001 | Hardware: open temperature sensor
nAlarmReverseThermocouple | 2#0000_0000_0000_0000_0000_0000_0000_0010 | Hardware: reverse connected temperature sensor
nAlarmBackVoltage | 2#0000_0000_0000_0000_0000_0000_0000_0100 | Hardware: excessive voltage at temperature sensor
nAlarmLeakageCurrent | 2#0000_0000_0000_0000_0000_0000_0000_1000 | Hardware: leakage current measured
nAlarmShortCircuit | 2#0000_0000_0000_0000_0000_0000_0001_0000 | Hardware: short circuit
nAlarmOpenCircuit | 2#0000_0000_0000_0000_0000_0000_0010_0000 | Hardware: no current
nAlarmLimitLow | 2#0000_0000_0000_0000_0000_0001_0000_0000 | Software: fallen below first lower relative temperature
nAlarmLimitLowLow | 2#0000_0000_0000_0000_0000_0010_0000_0000 | Software: fallen below second lower relative temperature
nAlarmLimitHigh | 2#0000_0000_0000_0000_0000_0100_0000_0000 | Software: first upper relative temperature exceeded
nAlarmLimitHighHigh | 2#0000_0000_0000_0000_0000_1000_0000_0000 | Software: second upper relative temperature exceeded
nAlarmAbsoluteHigh | 2#0000_0000_0000_0000_0001_0000_0000_0000 | Software: upper absolute temperature exceeded
nAlarmAbsoluteLow | 2#0000_0000_0000_0000_0010_0000_0000_0000 | Software: fallen below lower absolute temperature


FB_TempController

The temperature controller block FB_TempController has a variety of inputs and outputs that are described below. All the controller's parameters are passed to it via structures. The structures and enums are defined here.

Function Block

Interface

VAR_INPUT
    bOn : BOOL; (* start closed loop operating *)
    bInit : BOOL; (* init controller *)
    bTune : BOOL; (* start self tuning *)
    bManual : BOOL; (* manual operation *)
    bSelSetpoint : BOOL; (* FALSE = setpoint 1, TRUE = setpoint 2
*)
    bSelCtrlParameterSet : BOOL; (* FALSE = internal set, TRUE =
external set *)
    bEnableSoftStart : BOOL; (* FALSE = no soft start, TRUE = soft
start *)
    bEnableRamping : BOOL; (* FALSE = no ramping, TRUE = ramping
*)
    fW1 : LREAL; (* first setpoint *)
    fW2 : LREAL; (* second setpoint *)
    fX : LREAL; (* actual value *)
    (* alarming inputs *)
    bOpenThermocouple : BOOL; (* thermocouple *)
    bReverseThermocouple : BOOL;
    bBackVoltage : BOOL;
    bLeakage : BOOL; (* heating system *)
    bShortCircuit : BOOL;
    bOpenCircuit : BOOL;
    sParaControllerExternal : ST_ParaController; (* external
controller parameter set *)
    (* logging *)
    sLogData : ST_LogData := (bLog := FALSE, strLogFileName :=
'', strLogString := '' );
END_VAR
VAR_IN_OUT
    sControllerParameter : ST_ControllerParameter; (* parameters
*)
END_VAR
VAR_OUTPUT
    fYAnalog : LREAL; (* control value analog *)
    bYPWM : BOOL; (* control value PWM *)
    bYDig : BOOL; (* 2-Point *)
    bYDigPos : BOOL; (* 3-Point: control value digital positive
*)
    bYDigNeg : BOOL; (* 3-Point: control value digital
negative*)
    (* alarming *)
    dwAlarm : DWORD; (* max. 32 alarms *)
    (* state *)
    iState : States := TC_STATE_IDLE;
    (* general errors *)
    bError : BOOL;
    iErrorId : ErrorCodes;
END_VAR

Inputs

Name | Unit | Value range | Description
bOn | 1 | [TRUE,FALSE] | TRUE switches the controller on.
bInit | 1 | [TRUE,FALSE] | Initialisation flag, which must be active (TRUE) for precisely the first cycle in which the controller is called.
bTune | 1 | [TRUE,FALSE] | A rising edge switches the self-tuning on. If it is switched to FALSE during the self-tuning process then the self-tuning is aborted and the controller continues operation using the old parameters (if they are still present).
bManual | 1 | [TRUE,FALSE] | TRUE switches manual operation on. If the signal goes FALSE again, the controller returns to automatic mode.
bSelSetpoint | 1 | [TRUE,FALSE] | Selects one of two possible set values. FALSE selects the normal set value, while TRUE selects the standby set value.
bSelCtrlParameterSet | 1 | [TRUE,FALSE] | Selects one of two parameter sets. FALSE causes the internal (determined) parameter set to be used, while TRUE switches to one provided externally.
bEnableSoftStart | 1 | [TRUE,FALSE] | The soft start-up process is used if TRUE.
bEnableRamping | 1 | [TRUE,FALSE] | TRUE causes each jump in the set value to be converted to a ramp.
fW1 | °C | LREAL | Set value.
fW2 | °C | LREAL | Standby set value, generally smaller than fW1. fSelSetpoint can be used to switch between fW1 and fW2.
fX | °C | LREAL | Actual value. This value must be converted to LREAL.
bOpenThermocouple | 1 | [TRUE,FALSE] | The thermocouple is open if TRUE. Must be indicated by the hardware (e.g. KLxxxx).
bReverseThermocouple | 1 | [TRUE,FALSE] | TRUE indicates that the thermocouple has been connected with the wrong polarity. Must be indicated by the hardware.
bBackVoltage | 1 | [TRUE,FALSE] | TRUE indicates that the input voltage at the thermocouple is too high. Must be indicated by the hardware.
bLeakage | 1 | [TRUE,FALSE] | TRUE indicates that leakage current has been detected at the heating element. Must be indicated by the hardware.
bShortCircuit | 1 | [TRUE,FALSE] | TRUE indicates that a short circuit has been detected at the heating element. Must be indicated by the hardware.
bOpenCircuit | 1 | [TRUE,FALSE] | TRUE indicates that an open circuit has been detected at the heating element. Must be indicated by the hardware.
sControllerParameter | none | Struktur | General parameters (sampling rate etc.) are passed to the block in this structure.
sParaControllerExternal | none | Structure | An external controller parameter set is passed to the block in this structure.
sLogData | none | Structure | This structure passes parameters for logging to the block (filenames etc.).

Outputs

Name | Unit | Value range | Description
fYAnalog | none | LREAL | Analogue control value.
bYPWM | none | [TRUE,FALSE] | Boolean output, pulse width modulated.
bYDig | none | [TRUE,FALSE] | Boolean output of a two-point controller (TRUE control value 100%, FALSE control value off)
bYDigPos | none | [TRUE,FALSE] | Boolean output of a three-point controller (TRUE control value 100%, FALSE control value off)
bYDigNeg | none | [TRUE,FALSE] | Boolean output of a three-point controller (TRUE control value -100%, FALSE control value off)
dwAlarm | none | DWORD | Alarm signals (see ENUM ...)
iState | none | INT | Present controller status (see ENUM ...)
bError | none | [TRUE,FALSE] | If an error is present, then bError is TRUE.
iErrorId | none | INT | If bError is TRUE, then iErrorId provides an error code (see ENUM ...)


Structure Definitions

ST_ControllerParameter

TYPE ST_ParaControlValue :
STRUCT

(***********************************************************************)

    (* general parameters *)
    iMode : E_ControlMode; (* 1=heating, 2=cooling,
3=heating&cooling *)
    iReactionOnFailure : E_ReactionOnFailure; (* 0=controller off,
1=manual op, 2=yMin, 3=yMax *)
    fYTune : LREAL; (* step change while tuning operation *)
    fYStable : LREAL; (* tuning operation *)
    dwAlarmSupp : DWORD; (* alarm suppression *)
    tCtrlCycleTime : TIME; (* controller cycle time *)
    tTaskCycleTime : TIME; (* plc task cycle time *)

(***********************************************************************)

    (* setpoint parameters *)
    fWMin : LREAL; (* lower limit *)
    fWMax : LREAL; (* upper limit *)
    (* start up *)
    fWStartUp : LREAL; (* soft start plateau setpoint *)
    tStartUp : TIME; (* soft start waiting time*)
    bStartUpRamping : BOOL; (* enable ramping while start up phase
*)
    fWStartUpVeloPos : LREAL; (* max gradient for increasing
setpoint in start up phase*)
    fWStartUpVeloNeg : LREAL; (* max gradient for decreasing
setpoint in start up phase *)
    fWVeloPos : LREAL; (* max gradient for increasing setpoint
*)
    fWVeloNeg : LREAL; (* max gradient for decreasing setpoint
*)

(***********************************************************************)

    (* actual value parameters *)
    bFilter : BOOL;
    tFilter : TIME;

(***********************************************************************)

    (* control value parameters *)
    fYMin : LREAL; (* lower limit *)
    fYMax : LREAL; (* upper limit *)
    fYManual : LREAL; (* manual operation*)
    fYOnFailure : LREAL; (* control value on failure *)
    tPWMCycleTime : TIME; (* PWM *)

(***********************************************************************)

    (* controller settings *)
    bEnablePreController : BOOL; (* enable precontroller *)
    bEnableZones : BOOL; (* enable zone around setpoint with open
loop control *)
    bEnableCVFilter : BOOL; (* enable filter for CV (type see
iFilterType) *)
    iFilterType : E_FilterType; (* filtertype of CV filter *)
    iControllerType : E_ControllerType; (* used controller normally
PID *)

(***********************************************************************)

    (* min max temperatures *)
    TempLow : LREAL;
    TempLowLow : LREAL;
    TempHigh : LREAL;
    TempHighHigh : LREAL;
    TempAbsoluteHigh : LREAL;
    TempAbsoluteLow : LREAL;
END_STRUCT
END_TYPE

Description

Name | Unit | Value range | Description
iMode | none | INT | Controller operating mode (1 = heating, 2 = cooling, 3 = heating & cooling) (see below)
iReactionOnFailure | none | INT | Parameterisable reaction to errors (see below)
fYTune | none | LREAL | Control value during the self-tuning (normally 100%)
fYStable | none | LREAL | Control value during the settling phase (normally 0%)
dwAlarmSupp | none | DWORD | Masks out the alarms (see below)
tCtrlCycleTime | s | TIME | Controller's sampling time. In the course of the sampling time the controller re-calculates the control value.
tTaskCycleTime | s | TIME | Task cycle time. The FB is called with this time interval.
fWMin | K | LREAL | Minimum set value.
fWMax | K | LREAL | Maximum set value.
fWVeloPos | K/s | LREAL | Rate of rise (of ramp).
fWVeloNeg | K/s | LREAL | Rate of fall (of ramp).
fWStartUp | K | LREAL | Set value at start-up.
tStartUp | s | TIME | Time with the fWStartUp set value.
bStartUpRamping | none | [TRUE,FALSE] | Switches on ramping during the start-up phase.
fWStartUpVeloPos | K/s | LREAL | Rate of rise (of ramp) during the start-up phase.
fWStartUpVeloNeg | K/s | LREAL | Rate of fall (of ramp) during the start-up phase.
fYMin | none | LREAL | Minimum value of the control variable.
fYMax | none | LREAL | Maximum value of the control variable.
fYManual | none | LREAL | Control value in manual operation.
fYOnFailure | none | LREAL | Control value in case of error (parameterisable).
tPWMCycleTime | s | TIME | Cycle time of the PWM signal.
tFilter | s | TIME | Time constant of the actual value filter (first order P-T1 filter)
bFilter | none | [TRUE,FALSE] | The actual value filter is actuated if TRUE.
bEnablePreController | none | [TRUE,FALSE] | Switches pre-controller on.
bEnableZones | none | [TRUE,FALSE] | Switches open loop characteristic on until close to set value.
bEnableCVFilter | none | [TRUE,FALSE] | Switches on control value filter following the main controller.
iFilterType | none | ENUM | Selection of a filter type for the control value filter following the main controller (see below).
iControllerType | none | ENUM | Selection of a control algorithm (see below).
TempLow | K | LREAL | Relative lower temperature limit in the first band.
TempLowLow | K | LREAL | Relative lower temperature limit in the second band.
TempHigh | K | LREAL | Relative upper temperature limit in the first band.
TempHighHigh | K | LREAL | Relative upper temperature limit in the second band.
TempAbsoluteHigh | K | LREAL | Absolute upper temperature limit.
TempAbsoluteLow | K | LREAL | Absolute lower temperature limit.

Description

ST_ParaController

TYPE ST_ParaController :
STRUCT
    (* Main Controller parameter set *)
    KpMain : LREAL;
    TnMain : LREAL;
    TvMain : LREAL;
    TdMain : LREAL;
    (* Pre Controller parameter set *)
    KpPre : LREAL;
    TvPre : LREAL;
    TdPre : LREAL;
END_STRUCT
END_TYPE

Description

Name | Unit | Value range | Description
KpMain | none | LREAL | Amplification factor for the main controller.
TnMain | s | TIME | Integral-action time for main controller (I component).
TvMain | s | TIME | Derivative action time for main controller (D component).
TdMain | s | TIME | Damping time for the main controller.
KpPre | none | LREAL | Amplification factor for the pre-controller.
TvPre | s | TIME | Derivative action time for pre-controller (D component).
TdPre | s | TIME | Damping time for the pre-controller.

ENUM: Errorcodes

Name | Description
TC_ERR_NOERROR | No error.
TC_ERR_INVALIDPARAM | Invalid parameter.
TC_ERR_NO_INIT | Missing block initialisation.
TC_ERR_NO_INFLECTION_POINT | No inflection was found during self-tuning. No parameters could be determined.
TC_ERR_INVALID_PARAM | Invalid parameter.
TC_ERR_INVALID_CYCLETIME | Invalid combination of cycle times (sampling times and PWM cycle times).
TC_ERR_WRONG_TU | A valid value for the Tu parameter could not be found due to faulty or aborted self-tuning.

ENUM: ReactionOnFailure

Name | Description
TC_OnFailureNoFailure | No error.
TC_OnFailureStopController | If there is an error (an alarm) the controller will stop.
TC_OnFailureSetManMode | If there is an error (an alarm) the controller will switch to manual operation.
TC_OnFailureSetYMax | If there is an error (an alarm) set the control value to its maximum.
TC_OnFailureSetYMin | If there is an error (an alarm) set the control value to its minimum.

ENUM: ST_ControlMode

Name | Description
CTRLMODE_HEATING | Heating only.
CTRLMODE_COOLING | Cooling only.
CTRLMODE_HEATING_COOLING | Heating and cooling.

ENUM: states

Name | Description
TC_STATE_IDLE | Controller switched off.
TC_STATE_INIT | Controller is being initialised.
TC_STATE_OFF | Controller switched off, was previously switched on.
TC_STATE_TUNE | Controller in tuning / self adjustment state.
TC_STATE_MANUAL_OPERATION | Controller in manual operation.
TC_STATE_CLOSED_LOOP | Controller in automatic operation.
TC_STATE_TUNE_IDLE | Tuning started but not yet running. Waiting for idle.
TC_STATE_TUNE_PULSE | Pulse for determination of delay time.
TC_STATE_TUNE_STEP | Step for determination of delay time and maximum speed.
TC_STATE_TUNE_READY | Self-tuning complete.
TC_STATE_ERROR | Error (logical error).

ENUM: E_FilterType

Name | Description
E_FilterType_FIRSTORDER | First order filter.
E_FilterType_AVERAGE | Mean value filter.

ENUM: E_ControllerType

Name | Description
E_ControllerType_PID | Standard PID control algorithm.
E_ControllerType_PIDD2 | Planned serial PID control algorithm.

Bit-masks for alarms

Name | Mask | Description
nAlarmOpenThermocouple | 2#0000_0000_0000_0000_0000_0000_0000_0001 | Hardware: open temperature sensor
nAlarmReverseThermocouple | 2#0000_0000_0000_0000_0000_0000_0000_0010 | Hardware: reverse connected temperature sensor
nAlarmBackVoltage | 2#0000_0000_0000_0000_0000_0000_0000_0100 | Hardware: excessive voltage at temperature sensor
nAlarmLeakageCurrent | 2#0000_0000_0000_0000_0000_0000_0000_1000 | Hardware: leakage current measured
nAlarmShortCircuit | 2#0000_0000_0000_0000_0000_0000_0001_0000 | Hardware: short circuit
nAlarmOpenCircuit | 2#0000_0000_0000_0000_0000_0000_0010_0000 | Hardware: no current
nAlarmLimitLow | 2#0000_0000_0000_0000_0000_0001_0000_0000 | Software: fallen below first lower relative temperature
nAlarmLimitLowLow | 2#0000_0000_0000_0000_0000_0010_0000_0000 | Software: fallen below second lower relative temperature
nAlarmLimitHigh | 2#0000_0000_0000_0000_0000_0100_0000_0000 | Software: first upper relative temperature exceeded
nAlarmLimitHighHigh | 2#0000_0000_0000_0000_0000_1000_0000_0000 | Software: second upper relative temperature exceeded
nAlarmAbsoluteHigh | 2#0000_0000_0000_0000_0001_0000_0000_0000 | Software: upper absolute temperature exceeded
nAlarmAbsoluteLow | 2#0000_0000_0000_0000_0010_0000_0000_0000 | Software: fallen below lower absolute temperature


Commissioning the Controller in Stages

The following steps must be taken:

  • The controller library must be added to the project using the library manager.

TcTempCtrl.lib is to be added in the library manager.

  • At least one instance of the controller must be programmed.

An instance of the FB_TempController controller block is to be created. It is also necessary for an instance of the ST_ControllerParameter structure to be created.

  • Perform the required external connection.

Name |  | Description
bOn | Connection necessary | TRUE switches the controller on. Can be permanently set to TRUE if the controller is always to be switched on.
bInit | Connection necessary | Initialisation flag, which must be active (TRUE) for precisely the first cycle in which the controller is called.
bTune | Connection necessary if tuning will be used | A rising edge switches the self-tuning on. If it is switched to FALSE during the self-tuning process then the self-tuning is aborted and the controller continues operation using the old parameters (if they are still present).
bManual | Connection optional | TRUE switches manual operation on. If the signal goes FALSE again, the controller returns to automatic mode.
bSelSetpoint | Connection optional | Selects one of two possible set values. FALSE selects the normal set value, while TRUE selects the standby set value.
bSelCtrlParameterSet | Connection optional | Selects one of two parameter sets. FALSE causes the internal (determined) parameter set to be used, while TRUE switches to one provided externally.
bEnableSoftStart | Connection optional | The soft start-up process is used if TRUE.
bEnableRamping | Connection optional | TRUE causes each jump in the set value to be converted to a ramp.
fW1 | Connection necessary | Set value.
fW2 | Connection optional | Standby set value, generally smaller than fW1. fSelSetpoint can be used to switch between fW1 and fW2.
fX | Connection necessary | Actual value. This value must be converted to LREAL.
bOpenThermocouple | Connection optional | The thermocouple is open if TRUE. Must be indicated by the hardware (e.g. KLxxxx).
bReverseThermocouple | Connection optional | TRUE indicates that the thermocouple has been connected with the wrong polarity. Must be indicated by the hardware.
bBackVoltage | Connection optional | TRUE indicates that the input voltage at the thermocouple is too high. Must be indicated by the hardware.
bLeakage | Connection optional | TRUE indicates that leakage current has been detected at the heating element. Must be indicated by the hardware.
bShortCircuit | Connection optional | TRUE indicates that a short circuit has been detected at the heating element. Must be indicated by the hardware.
bOpenCircuit | Connection optional | TRUE indicates that an open circuit has been detected at the heating element. Must be indicated by the hardware.
sControllerParameter | Connection necessary | General parameters (sampling rate etc.) are passed to the block in this structure.
sParaControllerExternal | Connection optional | An external controller parameter set is passed to the block in this structure.
sLogData | Connection optional | This structure passes parameters for logging to the block (filenames etc.).
  • Perform the necessary parameterisation of the controller via the structure.

The parameters can be specified through initial values, or by assignment. If initial values are used, then the instance of the structure with initial values looks like this:

sControllerParameter : ST_ControllerParameter :=
(
(***********************************************************************)
(* general parameters *)
iMode := CTRLMODE_HEATING, (* 1=heating, 2=cooling, 3=heating&cooling *)
iReactionOnFailure := TC_OnFailureStopController, (* controller off or manual op or yMin or yMax *)
fYTune := 100, (* step change while tuning operation *)
fYStable := 0.0, (* tuning operation *)
dwAlarmSupp := 16#ff_ff_ff_ff, (* alarm suppression *)
tCtrlCycleTime := t#100ms, (* controller cycle time *)
tTaskCycleTime := t#10ms, (* plc task cycle time *)
(***********************************************************************)
(* setpoint parameters *)
fWMin := 0.0, (* lower limit *)
fWMax := 200, (* upper limit *)

(* start up optional *)
fWStartUp := 0.0, (* soft start plateau setpoint *)
tStartUp := t#0s, (* soft start waiting time*)
bStartUpRamping := FALSE, (* enable ramping while start up phase *)
fWStartUpVeloPos := 0.0, (* max gradient for increasing setpoint in start up phase*)
fWStartUpVeloNeg := 0.0, (* max gradient for decreasing setpoint in start up phase *)

fWVeloPos := 0.0, (* max gradient for increasing setpoint *)
fWVeloNeg := 0.0, (* max gradient for decreasing setpoint *)
 (***********************************************************************)
(* actual value parameters *)
bFilter := FALSE,
tFilter := t#0s,
 (***********************************************************************)
(* control value parameters *)
fYMin := 0, (* lower limit *)
fYMax := 100, (* upper limit *)
fYManual := 0.0, (* manual operation*)
fYOnFailure := 0.0, (* control value on failure *)
tPWMCycleTime := t#100ms, (* PWM *)
(***********************************************************************)
(* controller settings *)
bEnablePreController := FALSE, (* enable precontroller *)
bEnableZones := FALSE, (* enable zone around setpoint with open loop control *)
bEnableCVFilter := FALSE, (* enable filter for CV (type see iFilterType) *)
iFilterType := E_FilterType_FIRSTORDER, (* filtertype of CV filter *)
 iControllerType := E_ControllerType_PID, (* used controller normally PID *)
(***********************************************************************)
(* min max temperatures *)
TempLow := 10,
TempLowLow := 20,
TempHigh := 10,
TempHighHigh := 20,
TempAbsoluteHigh := 200,
TempAbsoluteLow := 0,
(***********************************************************************)
(* internal tuning parameters *)
fTuneKp := 1.2,
fTuneTn := 2.0,
fTuneTv := 0.42,
fTuneTd := 0.25
 );

The marked parameters are optional, and only need to be initialised if they are needed.

Assignment in the code can look like the following in ST:

sControllerParameter.tPWMCycleTime := t#100ms;

  • Specification of the controller sampling time, that task cycle time and the PWM cycle time

The controller's sampling time must be adapted to the particular process. It should be selected to be equal to or less than one tenth of the loop's dominant time constants. The task cycle time is specified by the PLC task from which the controller block has been called. This value can be read from the task configuration (PLC Control: Resources Task Configuration). The PWM cycle time is usually equal to the controller cycle time. If the task cycle time is 10ms and the PWM cycle time (=controller sampling time) is chosen to be 100ms, then a total of 10 levels (PWM cycle time / task cycle time) are available.

  • Parameterisation of TwinCAT Scope

To check the results, a scope examination should always be made of the tuning process and of the closed loop regulation behaviour. To do this, TwinCAT Scope View should be started and parameterised. The following channels should be recorded: set value (fW1 or fW2), actual value (fX) and the analog control value (fYAnalog).

  • Switching off the Alarms during the Commissioning Phase

The alarms can be temporarily switched off during the commissioning phase. An appropriate bit mask must be written into the dwAlarmSupp data word. If a bit is set in this data word, the corresponding alarm is disabled. The assignment of the individual alarms is described here.

Warning: All the required alarms should be switched on again after the initial commissioning!

  • Starting the Controller with Tuning

If the controller parameters are to be determined with the aid of the Tuning system, the bOn and bTune inputs must both be TRUE. A fixed waiting period of 20s first elapses. During this waiting period the temperature is monitored to ensure that it remains within a +-1°C band. If the temperature goes outside this band, the waiting starts again. The process is then subjected to a step excitation with a magnitude of fYTune. The process then reacts with the step response. As long as 80% of the set value is not reached, the process parameters are determined using the inflectional tangent method. For safety reasons, after 80% of the set value has been reached, control is switched over to closed loop control. If the temperature reaches the 80% mark too quickly (with no clear inflection) then the value of fYTune is to be reduced. The parameters determined in this way are used for the PID controller, and are provided in a structure at the output of the controller.

Warning: A step of at least 40°C must be used for the purposes of tuning. Smaller steps can result in incorrect parameter determination!

  • Linking the Internal Control Parameters with the External Connections

The controller parameters determined in the tuning process can be supplied again to the controller as external parameters. This may be necessary if the Tuning is only to be carried out once (e.g. only during the initial commissioning). To do this, the sParaControllerInternal structure is fed back to the controller's sParaControllerExternal input, and the bSelCtrlParameterSet flag set to TRUE.

  • Fine tuning

The control parameters determined in the Tuning process are designed to produce fast settling, with about 10% overshoot. If only very little overshoot is permitted, or even none at all, then the following parameters from the ST_ControllerParameter structure can be used to perform fine tuning. These values should be considered only as a guide.

Behaviour | fTuneKp | fTuneTn | fTuneTv | fTuneTd
Fast settling with overshoots of 10%-20% | 1.2 | 2.0 | 0.42 | 0.25
Slower settling with low overshoot | 1.0 | 2.5 | 0.42 | 0.25
Almost asymptotic settling with extremely small overshoot | 0.5 | 3.0 | 1.0 | 0.25