Previous implementation
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. 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 | Initialization flag, which must be active (TRUE) for precisely the first cycle in which the controller is called. |
bTune | Connection necessary if tuning is to 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 to FALSE again, the controller returns to automatic mode. |
bSelSetpoint | Connection optional | Selects one of two possible setpoints. FALSE selects the normal setpoint, while TRUE selects the standby setpoint. |
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 setpoint step-change to be converted to a ramp. |
fW1 | Connection necessary | Setpoint. |
fW2 | Connection optional | Standby setpoint, generally lower 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 reported by the hardware (e.g. KLxxxx). |
bReverseThermocouple | Connection optional | TRUE reports that the thermocouple has been connected with the wrong polarity. Must be reported by the hardware. |
bBackVoltage | Connection optional | TRUE indicates that the input voltage at the thermocouple is too high. Must be reported by the hardware. |
bLeakage | Connection optional | TRUE indicates that leakage current has been detected at the heating element. Must be reported by the hardware. |
bShortCircuit | Connection optional | TRUE indicates that a short circuit has been detected at the heating element. Must be reported by the hardware. |
bOpenCircuit | Connection optional | TRUE indicates that an open circuit has been detected at the heating element. Must be reported by the hardware. |
sControllerParameter | Connection necessary | General parameters (sampling time etc.) are passed to the function block in this structure. |
sParaControllerExternal | Connection optional | An external controller parameter set is passed to the function block in this structure. |
sLogData | Connection optional | This structure passes parameters for logging to the function block (filenames etc.). |
- Perform the necessary parameterization 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 have to be initialized if they are needed.
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 with the aid of the tuning system, the bOn and bTune inputs must both be TRUE. 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.
The section must perform a step of at least 40°C 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 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 |