Discrete-time proportional-integral controller.
More...
#include <pi.h>
|
| | PI () |
| | Constructs a PI controller.
|
| T | get_dt () |
| | Gets the controller sampling time.
|
| T | get_Ki () |
| | Gets the integral gain.
|
| T | get_Kp () |
| | Gets the proportional gain.
|
| T | get_u_k_1 () |
| | Gets the previous controller output.
|
| T | get_u_max () |
| | Gets the maximum controller output.
|
| void | init (T dt_, T Kp_, T Ki_, T u_k_1_, T u_max_) |
| | Initializes the PI controller.
|
| void | merge (T u_k_1_) |
| | Merges an external controller output into the PI state.
|
| void | reset () |
| | Resets the PI controller state.
|
| void | set_dt (T dt_) |
| | Sets the controller sampling time.
|
| void | set_Ki (T Ki_) |
| | Sets the integral gain.
|
| void | set_Kp (T Kp_) |
| | Sets the proportional gain.
|
| void | set_param (T dt_, T Kp_, T Ki_, T u_k_1_, T u_max_) |
| | Sets the PI controller parameters.
|
| void | set_u_0 (T u_k_1_) |
| | Sets the previous controller output.
|
| void | set_u_max (T u_max_) |
| | Sets the maximum controller output.
|
| T | update (T x_0, T x) |
| | Computes the PI control output.
|
|
| T | dt = 0.0 |
| | Controller sampling time.
|
| T | e_k_1 = 0.0 |
| | Previous control error.
|
| T | Ki = 0.0 |
| | Integral gain.
|
| T | Kp = 0.0 |
| | Proportional gain.
|
| bool | start = true |
| | Controller startup state.
|
| T | u_k_1 = 0.0 |
| | Previous controller output.
|
| T | u_max = 9999999999 |
| | Maximum controller output.
|
template<typename T>
class control_system::pi::PI< T >
Discrete-time proportional-integral controller.
The PI class implements a discrete-time proportional-integral controller using configurable proportional and integral gains.
The controller uses the sampling time for its discrete-time integral action and maintains the previous control error and controller output as internal state.
- Template Parameters
-
| T | Numeric data type used for the controller. |
- Example
0.001,
0.0,
100.0
);
double output = controller.
update(reference, measurement);
Discrete-time proportional-integral controller.
T update(T x_0, T x)
Computes the PI control output.
void init(T dt_, T Kp_, T Ki_, T u_k_1_, T u_max_)
Initializes the PI controller.
Definition at line 76 of file pi.h.
◆ PI()
Constructs a PI controller.
Constructs the controller with its parameters and internal state initialized to their default values.
Definition at line 5 of file pi.h.
◆ get_dt()
Gets the controller sampling time.
- Returns
- Sampling time in seconds.
Definition at line 97 of file pi.h.
◆ get_Ki()
Gets the integral gain.
- Returns
- Integral gain.
Definition at line 109 of file pi.h.
◆ get_Kp()
Gets the proportional gain.
- Returns
- Proportional gain.
Definition at line 103 of file pi.h.
◆ get_u_k_1()
Gets the previous controller output.
- Returns
- Previous controller output.
Definition at line 115 of file pi.h.
◆ get_u_max()
Gets the maximum controller output.
- Returns
- Maximum allowed controller output.
Definition at line 121 of file pi.h.
◆ init()
Initializes the PI controller.
- Parameters
-
| [in] | dt_ | Controller sampling time in seconds. |
| [in] | Kp_ | Proportional gain. |
| [in] | Ki_ | Integral gain. |
| [in] | u_k_1_ | Previous controller output. |
| [in] | u_max_ | Maximum allowed controller output. |
Initializes the controller sampling time, proportional and integral gains, previous controller output, and output limit.
Definition at line 16 of file pi.h.
◆ merge()
Merges an external controller output into the PI state.
- Parameters
-
| [in] | u_k_1_ | Previous or externally provided controller output. |
Updates the internal previous-output state using the specified controller output.
Definition at line 61 of file pi.h.
◆ reset()
Resets the PI controller state.
Resets the stored previous control error, previous controller output, and startup state.
Definition at line 53 of file pi.h.
◆ set_dt()
Sets the controller sampling time.
- Parameters
-
| [in] | dt_ | Sampling time in seconds. |
Definition at line 67 of file pi.h.
◆ set_Ki()
Sets the integral gain.
- Parameters
-
Definition at line 79 of file pi.h.
◆ set_Kp()
Sets the proportional gain.
- Parameters
-
| [in] | Kp_ | Proportional gain. |
Definition at line 73 of file pi.h.
◆ set_param()
Sets the PI controller parameters.
- Parameters
-
| [in] | dt_ | Controller sampling time in seconds. |
| [in] | Kp_ | Proportional gain. |
| [in] | Ki_ | Integral gain. |
| [in] | u_k_1_ | Previous controller output. |
| [in] | u_max_ | Maximum allowed controller output. |
Updates the controller sampling time, gains, previous controller output, and maximum output limit.
Definition at line 23 of file pi.h.
◆ set_u_0()
Sets the previous controller output.
- Parameters
-
| [in] | u_k_1_ | Previous controller output. |
Definition at line 85 of file pi.h.
◆ set_u_max()
Sets the maximum controller output.
- Parameters
-
| [in] | u_max_ | Maximum allowed controller output. |
Definition at line 91 of file pi.h.
◆ update()
Computes the PI control output.
- Parameters
-
| [in] | x_0 | Reference or desired value. |
| [in] | x | Current or measured value. |
- Returns
- PI controller output limited by the configured maximum output.
Calculates the proportional and integral contributions using the current control error and the stored controller state.
Definition at line 33 of file pi.h.
◆ dt
Controller sampling time.
Sampling period of the discrete-time PI controller in seconds.
Definition at line 233 of file pi.h.
◆ e_k_1
Previous control error.
Stores the control error from the previous iteration.
Definition at line 249 of file pi.h.
◆ Ki
Integral gain.
Definition at line 259 of file pi.h.
◆ Kp
Proportional gain.
Definition at line 254 of file pi.h.
◆ start
Controller startup state.
Indicates whether the controller is in its startup state.
Definition at line 276 of file pi.h.
◆ u_k_1
Previous controller output.
Stores the controller output from the previous iteration.
Definition at line 241 of file pi.h.
◆ u_max
Maximum controller output.
Defines the maximum allowed magnitude of the controller output.
Definition at line 268 of file pi.h.
The documentation for this class was generated from the following files: