Discrete-time proportional-derivative controller.
More...
#include <pd.h>
|
| | PD () |
| | Constructs a PD controller.
|
| T | get_dt () |
| | Gets the controller sampling time.
|
| T | get_e_k_1 () |
| | Gets the previous control error.
|
| T | get_Kd () |
| | Gets the derivative gain.
|
| T | get_Kp () |
| | Gets the proportional gain.
|
| T | get_u_max () |
| | Gets the maximum controller output.
|
| void | init (T dt_, T Kp_, T Kd_, T u_max_) |
| | Initializes the PD controller.
|
| void | merge (T u_k_1_) |
| | Merges an external controller output into the PD state.
|
| void | reset () |
| | Resets the PD controller state.
|
| void | set_dt (T dt_) |
| | Sets the controller sampling time.
|
| void | set_Kd (T Kd_) |
| | Sets the derivative gain.
|
| void | set_Kp (T Kp_) |
| | Sets the proportional gain.
|
| void | set_param (T dt_, T Kp_, T Kd_, T u_max_) |
| | Sets the PD controller parameters.
|
| void | set_u_max (T u_max_) |
| | Sets the maximum controller output.
|
| T | update (T x_0, T x) |
| | Computes the PD control output.
|
|
| T | dt = 0.0 |
| | Controller sampling time.
|
| T | e_k_1 = 0.0 |
| | Previous control error.
|
| T | Kd = 0.0 |
| | Derivative gain.
|
| T | Kp = 0.0 |
| | Proportional gain.
|
| bool | start = true |
| | Controller startup state.
|
| T | u_max = 9999999999 |
| | Maximum controller output.
|
template<typename T>
class control_system::pd::PD< T >
Discrete-time proportional-derivative controller.
The PD class implements a discrete-time proportional-derivative controller using configurable proportional and derivative gains.
The controller uses the sampling time for its discrete-time derivative action and maintains the previous control error as internal state.
- Template Parameters
-
| T | Numeric data type used for the controller. |
- Example
0.001,
100.0
);
double output = controller.
update(reference, measurement);
Discrete-time proportional-derivative controller.
void init(T dt_, T Kp_, T Kd_, T u_max_)
Initializes the PD controller.
T update(T x_0, T x)
Computes the PD control output.
Definition at line 74 of file pd.h.
◆ PD()
Constructs a PD controller.
Constructs the controller with its parameters and internal state initialized to their default values.
Definition at line 5 of file pd.h.
◆ get_dt()
Gets the controller sampling time.
- Returns
- Sampling time in seconds.
Definition at line 86 of file pd.h.
◆ get_e_k_1()
Gets the previous control error.
- Returns
- Control error from the previous controller iteration.
Definition at line 104 of file pd.h.
◆ get_Kd()
Gets the derivative gain.
- Returns
- Derivative gain.
Definition at line 98 of file pd.h.
◆ get_Kp()
Gets the proportional gain.
- Returns
- Proportional gain.
Definition at line 92 of file pd.h.
◆ get_u_max()
Gets the maximum controller output.
- Returns
- Maximum allowed controller output.
Definition at line 110 of file pd.h.
◆ init()
Initializes the PD controller.
- Parameters
-
| [in] | dt_ | Controller sampling time in seconds. |
| [in] | Kp_ | Proportional gain. |
| [in] | Kd_ | Derivative gain. |
| [in] | u_max_ | Maximum allowed controller output. |
Initializes the controller sampling time, proportional and derivative gains, and output limit.
Definition at line 15 of file pd.h.
◆ merge()
Merges an external controller output into the PD state.
- Parameters
-
| [in] | u_k_1_ | Previous or externally provided controller output. |
Updates the controller state using the specified previous controller output.
Definition at line 57 of file pd.h.
◆ reset()
Resets the PD controller state.
Resets the stored previous control error and startup state.
Definition at line 50 of file pd.h.
◆ set_dt()
Sets the controller sampling time.
- Parameters
-
| [in] | dt_ | Sampling time in seconds. |
Definition at line 62 of file pd.h.
◆ set_Kd()
Sets the derivative gain.
- Parameters
-
Definition at line 74 of file pd.h.
◆ set_Kp()
Sets the proportional gain.
- Parameters
-
| [in] | Kp_ | Proportional gain. |
Definition at line 68 of file pd.h.
◆ set_param()
Sets the PD controller parameters.
- Parameters
-
| [in] | dt_ | Controller sampling time in seconds. |
| [in] | Kp_ | Proportional gain. |
| [in] | Kd_ | Derivative gain. |
| [in] | u_max_ | Maximum allowed controller output. |
Updates the controller sampling time, proportional and derivative gains, and maximum output limit.
Definition at line 22 of file pd.h.
◆ set_u_max()
Sets the maximum controller output.
- Parameters
-
| [in] | u_max_ | Maximum allowed controller output. |
Definition at line 80 of file pd.h.
◆ update()
Computes the PD control output.
- Parameters
-
| [in] | x_0 | Reference or desired value. |
| [in] | x | Current or measured value. |
- Returns
- PD controller output limited by the configured maximum output.
Calculates the proportional and derivative contributions using the current control error and the stored previous control error.
Definition at line 31 of file pd.h.
◆ dt
Controller sampling time.
Sampling period of the discrete-time PD controller in seconds.
Definition at line 221 of file pd.h.
◆ e_k_1
Previous control error.
Stores the control error from the previous iteration.
Definition at line 229 of file pd.h.
◆ Kd
Derivative gain.
Definition at line 239 of file pd.h.
◆ Kp
Proportional gain.
Definition at line 234 of file pd.h.
◆ start
Controller startup state.
Indicates whether the controller is in its startup state.
Definition at line 247 of file pd.h.
◆ u_max
Maximum controller output.
Defines the maximum allowed magnitude of the controller output.
Definition at line 256 of file pd.h.
The documentation for this class was generated from the following files: