Engee documentation

Pid

Page in progress.

The PID controller is in parallel form.

Library

EngeeControlSystems

Description

The function creates a continuous or discrete proportional-integral-differential controller (PID controller) in parallel form:

where

  • — the gain factor of the proportional component;

  • — the gain factor of the integral component;

  • — gain factor of the differential component;

  • — filter time constant;

  • — discrete integrator of the integral part;

  • — discrete integrator of the differential part.

Syntax

Function call

  • c = Pid() creates a continuous PID controller with default parameters. You can change the parameter values using the function setproperty!.

  • c = Pid(kp) creates a continuous proportional regulator (P-regulator).

  • c = Pid(kp, ki) creates a continuous proportional-integral regulator (PI-regulator).

  • c = Pid(0, ki) creates a continuous integrated regulator (I-regulator).

  • c = Pid(kp, 0, kd) creates a continuous proportional-differential regulator (PD-regulator).

  • c = Pid(kp, ki, kd) creates a continuous PID controller.

  • c = Pid(kp, 0, kd, tf) creates a continuous PD controller with a first-order filter.

  • c = Pid(kp, ki, kd, tf) - creates a continuous PID controller with a first-order filter.

  • c = Pid(kp, ki, kd, 0, ts) creates a discrete PID controller.

  • c = Pid(kp, ki, kd, tf, ts) creates a discrete PID controller with a first-order filter.

  • c = Pid(kp, ki, kd, tf, ts, iformula) creates a discrete PID controller with a first-order filter, while the method of integrating the integral component is explicitly specified.

  • c = Pid(kp, ki, kd, tf, ts, iformula, dformula) creates a discrete PID controller with a first-order filter, while the integration methods of the integral and differential components are specified explicitly.

Arguments

Input arguments

# kp is the gain factor of the proportional component

+ 1.0 (default) | scalar

Details

The gain factor of the proportional component. The value must be a finite number.

Data types

Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64

Support for complex numbers

None

# ki is the gain factor of the integral component

+ 0.0 (by default) | scalar

Details

The gain factor of the integral component. The value must be a finite number.

Data types

Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64

Support for complex numbers

None

# kd is the gain factor of the differential component

+ 0.0 (by default) | scalar

Details

The gain factor of the differential component. The value must be a finite number.

The creation of a D-regulator is not provided.
Data types

Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64

Support for complex numbers

None

# tf is the time constant of the filter

+ 0.0 (by default) | scalar

Details

The time constant of the first-order filter of the differential component of the regulator. The value must be a finite number.

The value of this parameter must be equal to 0 when the regulator has no differential component.
Data types

Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64

Support for complex numbers

None

# ts is the sampling period

+ nothing (by default) | scalar

Details

The sampling period of the controller. For a continuous regulator, the argument takes the value nothing, and for a discrete controller, the value of the argument can be any positive number.

The value of this parameter must be equal to 0 when the regulator has no differential component.
Data types

Nothing, Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64

Support for complex numbers

None

# iformula is a method for integrating an integral component

+ nothing (default) | :forward_euler | :backward_euler | :trapezoidal

Details

The method of integrating the integral component discrete PID controller

The argument takes the following values:

  • :forward_euler — the direct Euler method

    It is recommended to use this method when the sampling period is short, i.e. if the Nyquist frequency is much higher than the bandwidth of the controller. For large values of the sampling period, using the direct Euler method can make the regulator unstable, even if a similar continuous regulator is stable.

  • :backward_euler — the inverse Euler method

    This method guarantees the stability of a discrete regulator when sampling a stable continuous regulator.

  • :trapezoidal — the trapezoid method

    This method guarantees the stability of a discrete regulator when sampling a stable continuous regulator. The trapezoid method allows to obtain a better correspondence of the frequency characteristics of continuous and discrete regulators in comparison with the Euler method.

For a continuous regulator, this argument takes the value nothing.
Data types

Nothing, Symbol

# dformula is a method for integrating the differential component

+ nothing (by default) | :forward_euler | :backward_euler | :trapezoidal

Details

The method of integrating the integral component discrete PID controller

The argument takes the following values:

  • :forward_euler — the direct Euler method

    It is recommended to use this method when the sampling period is short, i.e. if the Nyquist frequency is much higher than the bandwidth of the controller. For large values of the sampling period, using the direct Euler method can make the regulator unstable, even if a similar continuous regulator is stable.

  • :backward_euler — the inverse Euler method

    This method guarantees the stability of a discrete regulator when sampling a stable continuous regulator.

  • :trapezoidal — the trapezoid method

    This method guarantees the stability of a discrete regulator when sampling a stable continuous regulator. The trapezoid method allows to obtain a better correspondence of the frequency characteristics of continuous and discrete regulators in comparison with the Euler method.

For a continuous regulator, this argument takes the value nothing.
Data types

Nothing, Symbol

Output arguments

# c — PID controller in parallel form

+ Pid

Details

The PID controller is in parallel form. The structure of the regulator depends on the specified parameters.

Data types

Pid