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
controller function block is to be created. Also create an instance of the structure ST_ControllerParameter
.
- Perform the required external connection.
Name |
| Description |
---|---|---|
| Connection necessary | Switches the controller to an operation mode (active, passive, tuning) |
| Connection optional | Selects one of two possible setpoints. FALSE selects the normal setpoint, while TRUE selects the standby setpoint. |
| Connection necessary | Setpoint. |
| Connection optional | Standby setpoint, generally lower than fW1. fSelSetpoint can be used to switch between fW1 and fW2. |
| Connection necessary | Actual value. This value must be converted to LREAL. |
| Connection optional | Control value in manual operation. |
| Connection optional | The thermocouple is open if TRUE. Must be reported by the hardware (e.g. KLxxxx). |
| Connection optional | TRUE reports that the thermocouple has been connected with the wrong polarity. Must be reported by the hardware. |
| Connection optional | TRUE indicates that the input voltage at the thermocouple is too high. Must be reported by the hardware. |
| Connection optional | TRUE indicates that leakage current has been detected at the heating element. Must be reported by the hardware. |
| Connection optional | TRUE indicates that a short circuit has been detected at the heating element. Must be reported by the hardware. |
| Connection optional | TRUE indicates that an open circuit has been detected at the heating element. Must be reported by the hardware. |
| Connection necessary | General parameters (sampling time etc.) are passed to the function block in this structure. |
| Connection optional | An external controller parameter set is passed to the function block in this structure. |
- Perform the necessary parameterization of the controller via the structure.
The parameters can be specified through initial values, or by assignment. If the parameters are assigned by initial values, it could look like this, for example:
(* 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
);
Assignment in the code may look as follows in ST:
sControllerParameter.tPWMCycleTime :=
t#100ms;
- Specification of the controller sampling time, the task cycle time and the PWM cycle time
The controller's sampling time must be adapted to the section. It should be selected to be equal to or less than one tenth of the section's dominant time constants. The task cycle time is specified by the PLC task from which the controller function 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 10 ms and the chosen PWM cycle time (=controller sampling time) is 100 ms, then a total of 10 levels (PWM cycle time / task cycle time) are available.
- Parameterization of TwinCAT Scope
To check the results, a scope recording should always be made of the tuning process and the closed loop control behavior. To do this, TwinCAT Scope View should be started and parameterized. The following channels should be recorded: setpoint (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 Dword. If a bit is set in this Dword, the corresponding alarm is disabled. The assignment of the individual alarms is described here.
![]() | All required alarms should be switched on again after initial commissioning! |
- Starting the controller with tuning
If the controller parameters are to be determined by tuning, the control mode must be set to eCTRL_MODE_TUNE
. Firstly, a fixed waiting time of 20 s elapses. During this waiting time, the temperature of the section is monitored to ensure that it remains within a +-1°C band. If the temperature goes outside this band, the waiting time starts again. The section is then subjected to a step excitation with a control value of fYTune
. The section then reacts with the step response. As long as 80% of the setpoint has not been reached, the section parameters are determined using the inflectional tangent method. For safety reasons, control is switched over to closed control loop once 80% of the setpoint has been reached. If the temperature reaches the 80% mark too quickly (with no clear inflection) then the value of fYTune
is to be reduced. The determined parameters are used for the PID controller, and are provided in a structure at the output of the controller.
Note | |
The section must perform a step of at least 40°C for the purposes of tuning. Smaller steps can result in incorrect parameter determination! |
Note | |
Once the tuning has been completed successfully, the |
- Linking the internal control parameters with the external connections
The controller parameters determined in the tuning process can be supplied to the controller´again 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.
Behavior | fTuneKp | fTuneTn | fTuneTv | fTuneTd |
---|---|---|---|---|
Fast settling with an overshoot of 10% – 20% | 1.2 | 2.0 | 0.42 | 0.25 |
Slower settling with less overshoot | 1.0 | 2.5 | 0.42 | 0.25 |
Almost asymptotic settling with extremely low overshoot | 0.5 | 3.0 | 1.0 | 0.25 |