# The ATV method

The ATV method (Auto Tuning Variation) is a simple method to automatically calibrate PID controllers without automatic control knowledge, through a simple experiment on the model of the channel, canal or river.

The method applies by default to a variable Y, with its possible setpoint YT. This setpoint trajectory should be used with caution because ATV must be applied in the absence of disturbances other than those generated by ATV, to capture the dynamics to be controlled. But there may be small differences at the start of the transient that we want to remove by moving the variable Y of this gap precisely by using YT. It is also possible to apply the ATV method not on Y(1), but on a linear combination of Z. By default the coefficients of the linear combination are the same (1/number of Z), which gives the arithmetic average. But it is possible to choose other coefficients by writing them, 1 per line, in an ATV.TXT file. This can be useful for stalling the PID coefficients of a Bival regulator for example.

Example of ATV.TXT file:

`0.4`

0.6

In this case, the controlled variable will be 0.4*Z(1)+0.6*Z(2)

For the ATV method we read 6 parameters (Format of the line PS : `(5(F8.2,1X),F8.2)`

) which are, in the following order:

`* R METH CYCLE UouZ MG MP`

PS= 0.20 1.00 0.00 0.00 0.00 0.00

- $R$ is the switch value (in meters, or $m^3/s$ if there is a master-slave controller structure). It is positive for the classical feedback counter-reaction (e.g. downstream control) and negative for inverse configuration (e.g. upstream control).
- METH is the method used to calculate the P, PI and PID coefficients:
- 1 = Astrom p. 137 Table 4.2
- 2 = Astrom p.141-142 (r=0.5, Phi = 20°)
- 3 = Astrom p.141-142 (r=0.41, Phi = 61°)
- 4 = Astrom p.141-142 (r=0.29, Phi = 46°)
- 5 = Flaus p. 72, Table 2.7
- 6 = Flaus p. 72, Table 2.8 slight overshot
- 7 = Flaus p. 72, Table 2.8 without overshot
- 8 = Cemagref from gain and phase margins

- CYCLE is the number of cycles you want (or manual validation if = 0)
- UouZ allows (si =1) to use the measure Z instead of the control action U to compute Ku (this is usefull in case you have a saturation of the U, or if you have a limited precision of the actuators and that you are using real data using the SCADA link). In this case you define the corresponding Z as the measure of the gate opening, and this way you will get the real applied gate opening instead of the theoretical one.
- MG is the desired Gain Margin (for option 8)
- MP is the desired Phase Margin (for option 8)

The $K$, $T_i$ and $T_d$ coefficients of the PID are obtained from $K_u$ and $T_u$ of the ATV method using the following below.

$T_u$ is the period of the oscillation cycles. $K_u$ is computed by $K_u=4 \frac{R}{\pi E_{max}}$. If UouZ=0 $R$ is the value of the desired relay and if UouZ=1 $R$ is the value of the relay actually measured on the channel ($=Z(1)$). The values of the coefficients $K$, $T_i$ and $T_d$ of the PID are then calculated from $K_u$ and $T_u$ of the ATV method as follows:

Astrom p. 137, Table 4.2:

K | Ti | Td | |
---|---|---|---|

P | 0.5 Ku | ||

PI | 0.4 Ku | 0.8 Tu | |

PID | 0.6 Ku | 0.5 Tu | 0.125 Tu |

Astrom p. 141-142, r=0.5, Phi=20°:

K | Ti | Td | |
---|---|---|---|

P | 0.5 Ku | ||

PI | 0.47 Ku | 0.4373 Tu | |

PID | 0.47 Ku | 0.4546 Tu | 0.1136 Tu |

Astrom p. 141-142, r=0.41, Phi=61°:

K | Ti | Td | |
---|---|---|---|

P | 0.5 Ku | ||

PI | 0.1988 Ku | 0.0882 Tu | |

PID | 0.1988 Ku | 1.23 Tu | 0.3077 Tu |

Astrom p. 141-142, r=0.29, Phi=46°:

K | Ti | Td | |
---|---|---|---|

P | 0.5 Ku | ||

PI | 0.2015 Ku | 0.1537 Tu | |

PID | 0.2015 Ku | 0.7878 Tu | 0.197 Tu |

Flaus p. 72, table 2.7:

K | Ti | Td | |
---|---|---|---|

P | 0.5 Ku | ||

PI | 0.45 Ku | 0.833 Tu | |

PID | 0.6 Ku | 0.5 Tu | 0.125 Tu |

Flaus p. 72, table 2.8, slight overshot:

K | Ti | Td | |
---|---|---|---|

P | 0.5 Ku | ||

PI | 0.45 Ku | 0.833 Tu | |

PID | 0.33 Ku | 0.5 Tu | 0.333 Tu |

Flaus p. 72, table 2.8, without overshot:

K | Ti | Td | |
---|---|---|---|

P | 0.5 Ku | ||

PI | 0.45 Ku | 0.833 Tu | |

PID | 0.2 Ku | 0.5 Tu | 0.333 Tu |

For the method "Cemagref from gain and phase margins" we specify the desired performance in terms of gain and phase margin. When a value is given for a gain margin, the interface automatically offers the maximum phase margin that can be asked. You can decrease but not increase it (or it would lead to aberrant coefficients). Contact us for details or see our scientific publications on this topic.

Bibliographical references:

Cheng-Ching Yu. Autotuning of PID controllers. A relay feeback approach. 2nd Edition. Springer, 2006.

X. Litrico and P.-O. Malaterre. Test of auto-tuned automatic downstream controllers on gignac canal. In USCID conference on SCADA, editor, USCID conference on SCADA, Denver, 2007.

X. Litrico, P.-O. Malaterre, J.-P. Baume, P.-Y. Vion, and J. Ribot-Bruno. Automatic tuning of PI controllers for an irrigation canal pool. Journal of Irrigation and Drainage Engineering, 133:27–37, February 2007.