SMHCCA – Sliding mode heating/cooling controller with autotuner

Block SymbolLicensing group: AUTOTUNING

Function Description
The sliding mode heating/cooling controller (SMHCCA) is a novel high quality control algorithm with a built-in autotuner for automatic tuning of the controller parameters. The controller is mainly intended for temperature control of heating-cooling (possibly asymmetrical) processes with ON-OFF heaters and/or ON-OFF coolers. The plastic extruder heating/cooling system is a typical example of such process. However, it can also be applied to many similar cases, for example, to thermal systems where a conventional thermostat is normally employed. To provide the proper control function, the SMHCCA block must be combined with the PWM block (Pulse Width Modulation) as depicted in the following figure.


It is important to note that the block SMHCCA works with two time periods. The first period TS is the sampling time of the process temperature, and this period is equal to the period with which the block SMHCCA itself is executed. The other period TC = ipwmcTS is the control period with which the block SMHCCA generates the manipulated variable. This period TC is equal to the cycle time of PWM block. At every instant when the manipulated variable mv is changed by SMHCCA the PWM algorithm recalculates the width of the output pulse and starts a new PWM cycle. The time resolution TR of the PWM block is third time period involved in. This period is equal to the period with which the block PWM is executed and generally may be different from TS. To achieve the high quality of control it is recommended to choose TS as minimal as possible (ipwmc as maximal as possible), the ratio TCTS as maximal as possible but TC should be sufficiently small with respect to the process dynamics. An example of reasonable values for an extruder temperature control is as follows:

TS = 0.1,ipwmc = 50,TC = 5s,TR = 0.1s.

Notice however that for a faster controlled system the sampling periods TS, TC and TR must be shortened! More precisely, the three minimal time constant of the process are important for selection of these time periods (all real thermal process has at least three time constants). For example, the sampling period TS = 0.1 is sufficiently short for such processes that have at least three time constants, the minimal of them is greater than 10s and the maximal is greater than 100s. For the proper function of the controller it is necessary that these time parameters are suitably chosen by the user according to the actual dynamics of the process! If SMHCCA is implemented on a processor with floating point arithmetic then the accurate setting of the sampling periods TS, TC, TR and the parameter beta is critical for correct function of the controller. Also, some other parameters with the clear meaning described below have to be chosen manually. All the remaining parameters (xi, om, taup, taum, tauf) can be set by the built-in autotuner automatically. The autotuner uses the two methods for this purpose.

  • The first one is dedicated to situations where the asymmetry of the process is not enormous (approximately, it means that the gain ratio of heating/cooling or cooling/heating is less than 5).
  • The second method provides the tuning support for the strong asymmetric processes and is not implemented yet (So far, this method has been developed and tested in Simulink only).

Despite the fact that the first method of the tuning is based only on the heating regime, the resulting parameters are usually satisfactory for both heating and cooling regimes because of the strong robustness of sliding mode control. The tuning procedure is very quick and can be accomplished during the normal rise time period of the process temperature from cold state to the setpoint usually without any temporization or degradation of control performance. Thus the tuning procedure can be included in every start up from cold state to the working point specified by the sufficiently high temperature setpoint. Now the implemented procedure will be described in detail. The tuning procedure starts in the tuning mode or in the manual mode. If the tuning mode (TMODE = on) is selected the manipulated variable mv is automatically set to zero and the output TBSY is set to 1 for indication of the tuning stage of the controller. The cold state of the process is preserved until the initialization pulse is applied to the input TUNE (0 1). After some time (depending on beta), when the noise amplitude is estimated, the heating is switched on with the amplitude given by the parameter ut_p. The process temperature pv and its two derivatives (outputs t_pv, t_dpv, t_d2pv) are observed to obtain the optimal parameters of the controller. If the tuning procedure ends without errors, then TBSY is set to 0 and the controller begins to work in manual or automatic mode according to the input MAN. If MAN = off and affirmation input TAFF is set to 1, then the controller starts to work in automatic mode with the new parameter set provided by the tuner (if TAFF = off, then the new parameters are only displayed on the outputs p1..p6). If some error occurs during the tuning, then the tuning procedure stops immediately or stops after the condition pv>sp is fulfilled, the output TE is set to 1 and ite indicate the type of error. Also in this case, the controller starts to work in the mode determined by the input MAN. If MAN = off then works in automatic mode with the initial parameters before tuning! The tuning errors are usually caused either by an inappropriate setting of the parameter beta or by the too low value of sp. The suitable value of beta ranges in the interval (0.001,0.1). If a drift and noise in pv are large the small beta must be chosen especially for the tuning phase. The default value (beta=0.01) should work well for extruder applications. The correct value gives properly filtered signal of the second derivative of the process temperature t_d2pv. This well-filtered signal (corresponding to the low value of beta) is mainly necessary for proper tuning. For control, the parameter beta may be sometimes slightly increased. The tuning procedure may be also started from manual mode (MAN = off) with any constant value of the input hv. However, the steady state must be provided in this case. Again, the tuning is started by the initialization pulse at the input TUNE (0 1) and after the stop of tuning the controller continues in the manual mode. In both cases the resulting parameters appear on the outputs p1,...,p6.



The control law of the block SMHCCA in automatic mode (MAN = off) is based on the discrete dynamic sliding mode control technique and special 3rd order filters for estimation of the first and second derivatives of the control error.

The first control stage, after a setpoint change or upset, is the reaching phase when the dynamic sliding variable

sk=ëk + 2ξΩėk + Ω2e k

is forced to zero. In the above definition of the sliding variable, ek ,ėk,ëk denote the filtered deviation error (pvsp) and its first and second derivatives in the control period k, respectively, and ξ,Ω are the control parameters described below. In the second phase, sk is hold at the zero value (the sliding phase) by the proper control "bangs". Here, the heating action is alternated by cooling action and vice versa rapidly. The amplitudes of control actions are adapted appropriately to guarantee sk = 0 approximately. Thus, the hypothetical continuous dynamic sliding variable

s=ë + 2ξΩė + Ω2e

is approximately equal to zero at any time. Therefore the control deviation behaves according to the second order differential equation

s=ë + 2ξΩė + Ω2e = 0

describing so called zero sliding dynamics. From it follows that the evolution of e can be prescribed by the parameters ξ,Ω. For stable behavior, it must hold ξ > 0,Ω > 0. A typical optimal value of ξ ranges in the interval [4,8] and ξ about 6 is often a satisfactory value. The optimal value of Ω strongly depends on the controlled process. The slower processes the lower optimal Ω. The recommended value of Ω for start of tuning is π(5TC).

The manipulated variable mv usually ranges in the interval [1,1]. The positive (negative) value corresponds to heating (cooling). For example, mv = 1 means the full heating. The limits of mv can be reduced when needed by the controller parameters hilim_p and hilim_m. This reduction is probably necessary when the asymmetry between heating and cooling is significant. For example, if in the working zone the cooling is much more aggressive than heating, then these parameters should be set as hilim_p = 1 and hilim_m < 1. If we want to apply such limitation only in some time interval after a change of setpoint (during the transient response) then it is necessary to set initial value of the heating (cooling) action amplitude u0_p (u0_m) to the suitable value less than hilim_p (hilim_m). Otherwise set u0_p = hilim_p and u0_m = hilim_m.

The current amplitudes of heating and cooling uk_p, uk_m, respectively, are automatically adapted by the special algorithm to achieve so called quasi sliding mode, where the sign of sk alternately changes its value. In such a case the controller output isv alternates the values 1 and 1. The rate of adaptation of the heating (cooling) amplitude is given by time constant taup (taum). Both of these time constants have to be sufficiently high to provide the proper function of adaptation but the fine tuning is not necessary. Note for completeness that the manipulated variable mv is determined from the action amplitudes uk_p, uk_m by the following expression

if(sk < 0.0)thenmv = uk_pelsemv = uk_m.

Further, it is important to note that quasi sliding is seldom achievable because of a process dead time or disturbances. The suitable indicator of the quality of sliding is again the output isv. If the extraordinary fine tuning is required then it may be tried to find the better value for the bandwidth parameter beta of derivative filter, otherwise the default value 0.1 is preferred.

In the manual mode (MAN = on) the controller input hv is (after limitation to the range [hilim_m,hilim_p]) copied to the manipulated variable mv. The controller output mve provides the equivalent amplitude-modulated value of the manipulated variable mv for informative purposes. The output mve is obtained by the first order filter with the time constant tauf applied to mv.



Setpoint variable

Double (F64)


Process variable

Double (F64)


Manual value

Double (F64)


Manual or automatic mode


0 ....

Automatic mode

1 ....

Manual mode


Tuning mode



Start the tuning experiment: TUNE off on



Stop the tuning experiment: TBRK off on



Affirmation of the parameter set provided by the tuning procedure: TAFF = on



Meaning of the output signals p1,…,p6

Long (I32)

0 ....

Controller parameters

p1 … recommended control period TC

p2 … xi

p3 … om

p4 … taup

p5 … taum

p6 … tauf

1 ....

Auxiliary parameters

p1 … htp2 – time of the peak in the second derivative of pv

p2 … hpeak2 – peak value in the second derivative of pv

p3 … d2 – peak to peak amplitude of t_d2pv

p4 … tgain



Manipulated variable (controller output)

Double (F64)


Equivalent manipulated variable

Double (F64)


Deviation error

Double (F64)


Saturation flag


0 ....

Signal not limited

1 ....

Saturation limits active, mv hilim_p or mv -hilim_m


Number of the positive (+) or negative () sliding variable steps

Long (I32)


Current amplitude of heating

Double (F64)


Current amplitude of cooling

Double (F64)


Discrete dynamic sliding variable

Double (F64)


Filtered process variable pv by 3rd order filter

Double (F64)


Filtered first derivative of pv by 3rd order filter

Double (F64)


Filtered second derivative of pv by 3rd order filter

Double (F64)


Tuner busy flag (TBSY = on)



Tuning error


off ..

Autotuning successful

on ...

An error occured during the experiment


Error code

Long (I32)

0 ....

No error

1 ....

Noise level in pv too high, check the temperature input

2 ....

Incorrect parameter ut_p

3 ....

Setpoint sp too low

4 ....

The two minimal process time constants are probably too small with respect to the sampling period TS OR too high level of noise in the second derivative of pv (try to decrease the beta parameter)

5 ....

Premature termination of the tuning procedure (TBRK)


Identified parameters with respect to ips, i = 1,...,6

Double (F64)



PWM cycle (in sampling periods of the block, TCTS) 100

Long (I32)


Relative damping of sliding zero dynamics 0.5 8.01.0

Double (F64)


Natural frequency ω of sliding zero dynamics 0.00.01

Double (F64)


Time constant for adaptation of heating action amplitude [s] 700.0

Double (F64)


Time constant for adaptation of cooling action amplitude [s] 400.0

Double (F64)


Bandwidth parameter of the derivative filter 0.01

Double (F64)


Upper limit of the heating action amplitude 0.0 1.0 1.0

Double (F64)


Upper limit of the cooling action amplitude 0.0 1.0 1.0

Double (F64)


Initial amplitude of the heating action 1.0

Double (F64)


Initial amplitude of the cooling action 1.0

Double (F64)


Setpoint difference threshold for blocking of heating/cooling amplitudes reset 10.0

Double (F64)


Time constant of the filter for obtaining the equivalent manipulated variable 400.0

Double (F64)


Tuning method  1

Long (I32)

1 ....

Restricted to symmetrical processes

2 ....

Asymmetrical processes (not implemented yet)


Amplitude of heating for tuning experiment 0.0 1.0 1.0

Double (F64)


Amplitude of cooling for tuning experiment 0.0 1.0 1.0

Double (F64)

2020 © REX Controls s.r.o.,