|
PID Control 1.0
Discrete time implementation of P, PI, PD, PID. Including derivative filter, integral clamping, feed-forward, gain scheduling in standard and parallel form.
|
Discrete-time proportional-integral-derivative controller. More...
#include <pid.h>
Public Member Functions | |
| PID () | |
| Constructs a PID controller. | |
| T | get_dt () |
| Gets the controller sampling time. | |
| T | get_e_k_1 () |
| Gets the previous control error. | |
| T | get_e_k_2 () |
| Gets the control error from two iterations ago. | |
| T | get_Kd () |
| Gets the derivative gain. | |
| 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 Kd_, T u_k_1_, T u_max_) |
| Initializes the PID controller. | |
| void | merge (T u_k_1_) |
| Merges an external controller output into the PID state. | |
| void | reset () |
| Resets the PID controller state. | |
| void | set_dt (T dt_) |
| Sets the controller sampling time. | |
| void | set_Kd (T Kd_) |
| Sets the derivative gain. | |
| 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 Kd_, T u_k_1_, T u_max_) |
| Sets the PID 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 PID control output. | |
Private Attributes | |
| T | dt = 0.0 |
| Controller sampling time. | |
| T | e_k_1 = 0.0 |
| Previous control error. | |
| T | e_k_2 = 0.0 |
| Control error from two iterations ago. | |
| T | Kd = 0.0 |
| Derivative gain. | |
| T | Ki = 0.0 |
| Integral gain. | |
| T | Kp = 0.0 |
| Proportional gain. | |
| uint8_t | start = 0 |
| Controller startup state. | |
| T | u_k_1 = 0.0 |
| Previous controller output. | |
| T | u_max = 9999999999 |
| Maximum controller output. | |
Discrete-time proportional-integral-derivative controller.
The PID class implements a discrete-time PID controller using configurable proportional, integral, and derivative gains.
The controller uses the sampling time to calculate the discrete-time integral and derivative contributions.
The previous control output and previous error values are maintained internally as controller state.
| T | Numeric data type used for the controller. |
| control_system::pid::PID< T >::PID | ( | ) |
| T control_system::pid::PID< T >::get_dt | ( | ) |
| T control_system::pid::PID< T >::get_e_k_1 | ( | ) |
| T control_system::pid::PID< T >::get_e_k_2 | ( | ) |
| T control_system::pid::PID< T >::get_Kd | ( | ) |
| T control_system::pid::PID< T >::get_Ki | ( | ) |
| T control_system::pid::PID< T >::get_Kp | ( | ) |
| T control_system::pid::PID< T >::get_u_k_1 | ( | ) |
| T control_system::pid::PID< T >::get_u_max | ( | ) |
| void control_system::pid::PID< T >::init | ( | T | dt_, |
| T | Kp_, | ||
| T | Ki_, | ||
| T | Kd_, | ||
| T | u_k_1_, | ||
| T | u_max_ ) |
Initializes the PID controller.
| [in] | dt_ | Controller sampling time in seconds. |
| [in] | Kp_ | Proportional gain. |
| [in] | Ki_ | Integral gain. |
| [in] | Kd_ | Derivative gain. |
| [in] | u_k_1 | Previous controller output. |
| [in] | u_max_ | Maximum allowed controller output. |
Initializes the controller parameters and previous output state.
| void control_system::pid::PID< T >::merge | ( | T | u_k_1_ | ) |
| void control_system::pid::PID< T >::reset | ( | ) |
| void control_system::pid::PID< T >::set_dt | ( | T | dt_ | ) |
| void control_system::pid::PID< T >::set_Kd | ( | T | Kd_ | ) |
| void control_system::pid::PID< T >::set_Ki | ( | T | Ki_ | ) |
| void control_system::pid::PID< T >::set_Kp | ( | T | Kp_ | ) |
| void control_system::pid::PID< T >::set_param | ( | T | dt_, |
| T | Kp_, | ||
| T | Ki_, | ||
| T | Kd_, | ||
| T | u_k_1_, | ||
| T | u_max_ ) |
Sets the PID controller parameters.
| [in] | dt_ | Controller sampling time in seconds. |
| [in] | Kp_ | Proportional gain. |
| [in] | Ki_ | Integral gain. |
| [in] | Kd_ | Derivative gain. |
| [in] | u_k_1 | Previous controller output. |
| [in] | u_max_ | Maximum allowed controller output. |
Updates the controller gains, sampling time, previous output, and output limit.
| void control_system::pid::PID< T >::set_u_0 | ( | T | u_k_1_ | ) |
| void control_system::pid::PID< T >::set_u_max | ( | T | u_max_ | ) |
| T control_system::pid::PID< T >::update | ( | T | x_0, |
| T | x ) |
Computes the PID control output.
| [in] | x_0 | Reference or desired value. |
| [in] | x | Current or measured value. |
Calculates the control output from the proportional, integral, and derivative contributions using the current control error and the stored controller state.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |