`DiscretePIDs.DiscretePID`

— Type`DiscretePID{T}`

`DiscretePIDs.DiscretePID`

— Method`DiscretePID(; K = 1, Ti = false, Td = false, Tt = √(Ti*Td), N = 10, b = 1, umin = -Inf, umax = Inf, Ts, I = 0, D = 0, yold = 0)`

A discrete-time PID controller with set-point weighting and integrator anti-windup. The controller is implemented on the standard form

\[u = K \left( e + \dfrac{1}{Ti} \int e dt + T_d \dfrac{de}{dt} \right)\]

\[U(s) = K \left( bR(s) - Y(s) + \dfrac{1}{sT_i} \left( R(s) Y(s) \right) - \dfrac{sT_d}{1 + s T_d / N}Y(s)\]

Call the controller like this

```
u = pid(r, y, uff) # uff is optional
u = calculate_control!(pid, r, y, uff) # Equivalent to the above
```

**Arguments:**

`K`

: Proportional gain`Ti`

: Integral time`Td`

: Derivative time`Tt`

: Reset time for anti-windup`N`

: Maximum derivative gain`b`

: Fraction of set point in proportional term`umin`

: Low output limit`umax`

: High output limit`Ts`

: Sampling period`I`

: Integral part`D`

: Derivative part`yold`

: Last measurement signal

See also `calculate_control!`

, `set_K!`

, `set_Ti!`

, `set_Td!`

`DiscretePIDs.calculate_control!`

— Method```
u = calculate_control!(pid::DiscretePID, r, y, uff=0)
(pid)(r, y, uff=0) # Alternative syntax
```

Calculate the control output from the PID controller when `r`

is the reference (set point), `y`

is the latest measurement and `uff`

is the feed-forward contribution. If the type of the input arguments differ from the numeric type used by the PID controller, they will be converted before computations are performed.

`DiscretePIDs.set_K!`

— Method`set_K!(pid::DiscretePID, K, r, y)`

Update `K`

in the PID controller. This function takes the current reference and measurement as well in order to provide bumpless transfer. This is realized by updating the internal state `I`

.

`DiscretePIDs.set_Td!`

— Method`set_Td!(pid::DiscretePID, Td)`

Update `Td`

in the PID controller.

`DiscretePIDs.set_Ti!`

— Method`set_Ti!(pid::DiscretePID, Ti)`

Update `Ti`

in the PID controller.