PIDMA – PID controller with moment autotuner

Block SymbolLicensing group: AUTOTUNING
Qt SVG Document Exported by REXYGEN Studio dv sp pv tv hv MAN IH TUNE TBRK TAFF ips mv dmv de SAT TBSY TE ite trem pk pti ptd pnd pb pc PIDMA

Function Description
The PIDU block serves as a foundational component for constructing a complete PID controller (P, I, PI, PD, PID, PI+D). In its simplest form, it can operate independently as a standard PID controller with two degrees of freedom, accommodating both automatic (MAN = off) and manual modes (MAN = on).

In automatic mode (MAN = off), the PIDMA block executes the PID control law with two degrees of freedom as follows:

U(s) = ±K bW(s) Y (s) + 1 Tis W(s) Y (s) + Tds Td N s + 1 cW(s) Y (s) + Z(s)

where U(s) is Laplace transform of the manipulated variable mv, W(s) is Laplace transform of the setpoint variable sp, Y (s) is Laplace transform of the process variable pv, Z(s) is Laplace transform of the feedforward control variable dv and K, Ti , Td, N, b and c are the parameters of the controller. The sign of the right hand side depends on the parameter RACT. The range of the manipulated variable mv (position controller output) is limited by parameters hilim, lolim. The parameter dz determines the dead zone in the integral part of the controller. The integral part of the control law can be switched off and fixed on the current value by the integrator hold input IH (IH = on). For the proper function of the controller, it is necessary to connect the output mv of the controller to the controller input tv and properly set the tracking time constant tt.

The recommended default value for the PID controller is tt Ti Td, and for the PI controller, it is tt Ti2. This ensures a bumpless transfer during switching between manual and automatic modes and correct anti-windup functionality when the output mv saturates. Adjusting the parameter tt allows for precise behaviour adjustment during saturation (e.g., bouncing off the limits due to noise) and when switching between multiple controllers (the size of the jump when switching, if there is a deviation error). A value of 0 sets recommended default values for PI and PID controllers. For controllers withou an integral part, it means disabling the tracking. To enable tracking for P or PD controllers (e.g., for control around a setpoint), set a positive value for tt higher than the sampling period. Disabling tracking for controllers with an integral part is not possible due to the risk of windup.

For the gain setting, a value of K = 0 disables the controller. Negative values are not allowed (use the RACT parameter for negative effect instead). Setting the integral time constant to Ti = 0 disables the integral component of the controller (same effect as disabling it with the irtype parameter). For Td = 0, the derivative component of the controller is disabled. The additional outputs dmv, de, and SAT sequentially provide the controller’s velocity output (difference of mv), the deviation error, and the saturation flag of the controller’s output mv.

The PIDMA block can be prepared for connection with other types of control blocks by using the icotype parameter. The icotype parameter can be set to the following values with the given meanings:

  • 1: Analog - standard block mode,
  • 2: PWM - mode suitable for connecting the output mv to the input of pulse-width modulated regulation PWM,
  • 3: SCU - mode for connection with a step controller with position feedback SCU,
  • 4: SCUV - mode for connection with a step controller without positional feedback SCUV.

For the last option, the meanings of the outputs mv, dmv, and SAT are modified in this case: the output mv equals the sum of the P and D components of the controller, while the output dmv provides the difference of its I component, and the output SAT carries information for the SCUV block whether the deviation error de in automatic mode is less than the dead zone dz. Additionally, for connecting the PIDMA and SCUV blocks, it is recommended to set the setpoint weighting factor for the derivative component c to zero.

In the manual mode (MAN = on), the input hv is copied to the output mv unless saturated. The overall control function of the PIDMA block is quite clear from the following diagram:

image/svg+xmlRACT RACT RACT AUT MAN dv sp pv tv hv MAN mv de SAT dmv IH 0 0 icotype=SCUV 0 1 1 0 1 0 0 1 0 1 4 3 2 1 1Tt 1s KTi KTd.sTd/N.s+1 NOT AND OR diff +−1 +−1 c K +−1 b 7 6 5 4 3 2 1

The block PIDMA extends the control function of the standard PID controller by the built in autotuning feature. Before start of the autotuner the operator have to reach the steady state of the process at a suitable working point (in manual or automatic mode) and specify the required type of the controller ittype (PI or PID) and other tuning parameters (iainf, DGC, tdg, tn, amp, dy and ispeed). The identification experiment is started by the rising edge off on on the input TUNE (input TBRK finishes the experiment). In this mode (TBSY = on), first of all the noise and possible drift gradient (DGC = on) are estimated during the user specified time (tdg + tn) and then the rectangle pulse is applied to the input of the process and the first three process moments are identified from the pulse response. The amplitude of the pulse is set by the parameter amp. The pulse is finished when the process variable pv deviates from the steady value more than the dy threshold defines. The threshold is an absolute difference, therefore it is always a positive value. The duration of the tuning experiment depends on the dynamic behavior of the process. The remaining time to the end of the tuning is provided by the output trem.

If the experiment ends successfully (TE = off), then depending on the input ips appears on the outputs:

  • 0: Designed parameters pk, pti, ptd, pnd, pb, pc.
  • 1: process moments: static gain (pk), resident time constant (pti), measure of the system response length (ptd).
  • 2: Three-parameter first-order plus dead-time model: static gain (pk), dead-time (pti), time constant (ptd). See the FOPDT block.
  • 3: Three-parameter second-order plus dead-time model with double time constant: static gain (pk), dead-time (pti), time constant (ptd). See the SOPDT block.
  • 4: Estimated boundaries for manual fine-tuning of the PID controller (irtype = 7) gain k: upper boundary khi (pk), lower boundary klo (pti).

Other values of the ips input are reserved for custom specific purposes. For (TE = on) the output ite specifies the experiment error more closely. The function of the autotuner is illustrated in the following picture.

image/svg+xml mv0+amp mv0 pv0+dy sp pv0 TBSY phase 0 1 2 3 4 0 t1 t2 t3 t4 t5

During the experiment, the output ite indicates the autotuner phases. In the phase of estimation of the response decay rate (ite = -4) the tuning experiment may be finished manually before its regular end. In this case the controller parameters are designed but the potential warning is indicated by setting the output ite=100.

Remark: The rising edge off on at TUNE input during the phases -2, -3 and -4 causes the finishing of the current phase and transition to the next one (or finishing the experiment in the phase -4).

At the end of the experiment (TBSY on off), the function of the controller depends on the current controller mode. If the TAFF = on the designed controller parameters are immediately accepted.

This block propagates the signal quality. More information can be found in the 1.4 section.

Input

dv

Feedforward control variable

Double (F64)

sp

Setpoint variable

Double (F64)

pv

Process variable

Double (F64)

tv

Tracking variable

Double (F64)

hv

Manual value

Double (F64)

MAN

Manual or automatic mode

Bool

off ..

Automatic mode

on ...

Manual mode

IH

Integrator hold

Bool

off ..

Integration enabled

on ...

Integration disabled

TUNE

Start the tuning experiment

Bool

TBRK

Stop the tuning experiment

Bool

TAFF

Tuning affirmation

Bool

off ..

Parameters are only computed

on ...

Parameters are set into the control law

ips

Meaning of the output signals

Long (I32)

0 ....

PID parameters

1 ....

process moments

2 ....

FOPDT model

3 ....

SOPDT model

4 ....

boundaries for manual tuning of controller gain

Parameter

irtype

Controller type (control law)  6

Long (I32)

1 ....

D

2 ....

I

3 ....

ID

4 ....

P

5 ....

PD

6 ....

PI

7 ....

PID

RACT

Reverse action flag

Bool

off ..

Higher mv -> higher pv

on ...

Higher mv -> lower pv

k

Controller gain   0.0 1.0

Double (F64)

ti

Integral time constant   0.0 4.0

Double (F64)

td

Derivative time constant   0.0 1.0

Double (F64)

nd

Derivative filtering parameter   0.0 10.0

Double (F64)

b

Setpoint weighting - proportional part   0.0  2.0 1.0

Double (F64)

c

Setpoint weighting - derivative part   0.0  2.0

Double (F64)

tt

Tracking time constant   0.0 1.0

Double (F64)

hilim

Upper limit of the controller output  1.0

Double (F64)

lolim

Lower limit of the controller output  -1.0

Double (F64)

dz

Dead zone

Double (F64)

icotype

Controller output type  1

Long (I32)

1 ....

Analog

2 ....

PWM

3 ....

SCU

4 ....

SCUV

ittype

Controller type to be designed  6

Long (I32)

6 ....

PI

7 ....

PID

iainf

Type of apriori information  1

Long (I32)

1 ....

Static process

2 ....

Astatic process

DGC

Drift gradient compensation  on

Bool

off ..

Disabled

on ...

Enabled

tdg

Drift gradient estimation time [s]  60.0

Double (F64)

tn

Length of noise estimation period [s]  5.0

Double (F64)

amp

Tuning pulse amplitude  0.5

Double (F64)

dy

Tuning pulse get down threshold   0.0 0.1

Double (F64)

ispeed

Desired closed loop speed  2

Long (I32)

1 ....

Slow closed loop

2 ....

Normal (middle fast) CL

3 ....

Fast closed loop

ipid

PID controller form  1

Long (I32)

1 ....

Parallel form

2 ....

Series form

Output

mv

Manipulated variable (controller output)

Double (F64)

dmv

Controller velocity output (difference)

Double (F64)

de

Deviation error

Double (F64)

SAT

Saturation flag

Bool

off ..

The controller implements a linear control law

on ...

The controller output is saturated

TBSY

Tuner busy flag

Bool

TE

Tuning error

Bool

off ..

Autotuning successful

on ...

An error occurred during the experiment

ite

Error code

Long (I32)

0 ....

No error or waiting for steady state

1 ....

Too small pulse getdown threshold

2 ....

Too large pulse amplitude

3 ....

Steady state condition violation

4 ....

Too small pulse amplitude

5 ....

Peak search procedure failure

6 ....

Output saturation occurred during experiment

7 ....

Selected controller type not supported

8 ....

Process not monotonous

9 ....

Extrapolation failure

10 ...

Unexpected values of moments (fatal)

11 ...

Abnormal manual termination of tuning

12 ...

Wrong direction of manipulated variable

13 ...

Invalid format of sParams input string

100 ..

Manual termination of tuning (warning)

-1 ...

Drift gradient and noise estimation phase

-2 ...

Pulse generation phase

-3 ...

Searching the peak of system response

-4 ...

Estimation of the system response decay rate

trem

Estimated time to finish the tuning experiment [s]

Double (F64)

pk

Proposed controller gain

Double (F64)

pti

Proposed integral time constant

Double (F64)

ptd

Proposed derivative time constant

Double (F64)

pnd

Proposed derivative component filtering

Double (F64)

pb

Proposed weighting factor - proportional component

Double (F64)

pc

Proposed weighting factor - derivative component

Double (F64)

2024 © REX Controls s.r.o., www.rexygen.com