Commisioning the Controller in Stages
The following steps must be taken:
- 1. Insert the controller library into the project via the library manager.
- Insert the Tc2_TempController in the library manager.
- 2. Program at least one instance of the controller.
- To do this, create an instance of the controller function block FB_TempController.
- Also create an instance of the structure ST_ControllerParameter.
- Insert library.
- 3. Create external wiring.
Name |
| Description |
---|---|---|
eCtrlMode | Connection necessary | Switches the controller to an operation mode (active, passive, tuning). |
bSelSetpoint | Connection optional | Selects one of two possible setpoints. FALSE selects the normal setpoint, while TRUE selects the standby setpoint. |
fW1 | Connection necessary | Setpoint |
fW2 | Connection optional | Standby setpoint is usually smaller than fW1. fSelSetpoint can be used to switch between fW1 and fW2. |
fX | Connection necessary | Actual value, expected as LREAL number. The actual value may first have to be converted to LREAL outside the function block. |
fYManual | Connection optional | Control value in manual operation |
bOpenThermocouple | Connection optional | The thermocouple is open if TRUE. Must be reported by the hardware (e.g. KL3xxx or EL3xxx). |
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 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. |
- 4. 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 can look like the following in ST:
sControllerParameter.tPWMCycleTime := t#100ms;
- 5. Set 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 loop'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 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.
- 6. Parameterization of TwinCAT Scope.
- To check the results, make a scope recording of the tuning process and the closed-loop control behavior.
- To do this, start and parameterize the TwinCAT Scope View.
- Record the following channels: setpoint (fW1 or fW2), actual value (fX) and the analog control value (fYAnalog).
- 7. Switch off alarms during the commissioning phase.
- The alarms can be temporarily switched off during the commissioning phase.
- Set a corresponding bit mask in 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.
Information: After initial commissioning, switch all required alarms back on.
- 8. Start the controller with tuning.
- If the controller parameters are to be determined by tuning, the control mode must be set to
eCTRL_MODE_TUNE
. - A fixed waiting time of 20s first elapses. During this waiting time 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 control value of fYTune. The process then reacts with the step response. As long as 80% of the setpoint is not reached, the process parameters are determined using the inflectional tangent method. For safety reasons, after 80% of the setpoint 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.
![]() | Setting the control mode Once the tuning has been completed successfully, the |
- 9. 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, trace the structure
sParaControllerInternal
to the input of the controllersParaControllerExternal
and set the flagbSelCtrlParameterSet
to TRUE.
- 10. Perform fine-tuning manually.
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 are guide values.
Behavior | 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 |
Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT 3.1.4016 | PC or CX | Tc2_TempController |