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.
Loading...
Searching...
No Matches
control_system::derivative::D< T > Class Template Reference

Discrete-time derivative controller. More...

#include <d.h>

Public Member Functions

 D ()
 Constructs a derivative controller.
get_dt ()
 Gets the controller sampling time.
get_e_k_1 ()
 Gets the previous control error.
get_Kd ()
 Gets the derivative gain.
get_u_max ()
 Gets the maximum controller output.
void init (T dt_, T Kd_, T u_max_)
 Initializes the derivative controller.
void merge (T u_k_1_)
 Merges an external controller output into the derivative state.
void reset ()
 Resets the derivative controller state.
void set_dt (T dt_)
 Sets the controller sampling time.
void set_Kd (T Kd_)
 Sets the derivative gain.
void set_param (T dt_, T Kd_, T u_max_)
 Sets the derivative controller parameters.
void set_u_max (T u_max_)
 Sets the maximum controller output.
update (T x_0, T x)
 Computes the derivative control output.

Private Attributes

dt = 0.0
 Controller sampling time.
e_k_1 = 0.0
 Previous control error.
Kd = 0.0
 Derivative gain.
bool start = true
 Controller startup state.
u_max = 9999999999
 Maximum controller output.

Detailed Description

template<typename T>
class control_system::derivative::D< T >

Discrete-time derivative controller.

The D class implements a discrete-time derivative controller using a configurable derivative gain and sampling time.

The derivative contribution is calculated from the change in control error between successive controller iterations.

The previous control error is maintained as internal state and the controller output is limited by the configured maximum output value.

Template Parameters
TNumeric data type used for the controller.
Example
controller.init(
0.001,
Kd,
100.0
);
double output = controller.update(reference, measurement);
Discrete-time derivative controller.
Definition d.h:77
void init(T dt_, T Kd_, T u_max_)
Initializes the derivative controller.
Definition d.h:14
T update(T x_0, T x)
Computes the derivative control output.
Definition d.h:29
T Kd
Derivative gain.
Definition d.h:220

Definition at line 76 of file d.h.

Constructor & Destructor Documentation

◆ D()

template<typename T>
control_system::derivative::D< T >::D ( )

Constructs a derivative controller.

Constructs the controller with its parameters and internal state initialized to their default values.

Definition at line 5 of file d.h.

Member Function Documentation

◆ get_dt()

template<typename T>
T control_system::derivative::D< T >::get_dt ( )

Gets the controller sampling time.

Returns
Sampling time in seconds.

Definition at line 78 of file d.h.

◆ get_e_k_1()

template<typename T>
T control_system::derivative::D< T >::get_e_k_1 ( )

Gets the previous control error.

Returns
Control error from the previous controller iteration.

Definition at line 90 of file d.h.

◆ get_Kd()

template<typename T>
T control_system::derivative::D< T >::get_Kd ( )

Gets the derivative gain.

Returns
Derivative gain.

Definition at line 84 of file d.h.

◆ get_u_max()

template<typename T>
T control_system::derivative::D< T >::get_u_max ( )

Gets the maximum controller output.

Returns
Maximum allowed controller output.

◆ init()

template<typename T>
void control_system::derivative::D< T >::init ( T dt_,
T Kd_,
T u_max_ )

Initializes the derivative controller.

Parameters
[in]dt_Controller sampling time in seconds.
[in]Kd_Derivative gain.
[in]u_max_Maximum allowed controller output.

Initializes the controller sampling time, derivative gain, and output limit.

Definition at line 14 of file d.h.

◆ merge()

template<typename T>
void control_system::derivative::D< T >::merge ( T u_k_1_)

Merges an external controller output into the derivative 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 55 of file d.h.

◆ reset()

template<typename T>
void control_system::derivative::D< T >::reset ( )

Resets the derivative controller state.

Resets the stored previous control error and startup state.

Definition at line 48 of file d.h.

◆ set_dt()

template<typename T>
void control_system::derivative::D< T >::set_dt ( T dt_)

Sets the controller sampling time.

Parameters
[in]dt_Sampling time in seconds.

Definition at line 60 of file d.h.

◆ set_Kd()

template<typename T>
void control_system::derivative::D< T >::set_Kd ( T Kd_)

Sets the derivative gain.

Parameters
[in]Kd_Derivative gain.

Definition at line 66 of file d.h.

◆ set_param()

template<typename T>
void control_system::derivative::D< T >::set_param ( T dt_,
T Kd_,
T u_max_ )

Sets the derivative controller parameters.

Parameters
[in]dt_Controller sampling time in seconds.
[in]Kd_Derivative gain.
[in]u_max_Maximum allowed controller output.

Updates the controller sampling time, derivative gain, and maximum output limit.

Definition at line 21 of file d.h.

◆ set_u_max()

template<typename T>
void control_system::derivative::D< T >::set_u_max ( T u_max_)

Sets the maximum controller output.

Parameters
[in]u_max_Maximum allowed controller output.

Definition at line 72 of file d.h.

◆ update()

template<typename T>
T control_system::derivative::D< T >::update ( T x_0,
T x )

Computes the derivative control output.

Parameters
[in]x_0Reference or desired value.
[in]xCurrent or measured value.
Returns
Derivative controller output limited by the configured maximum output.

Calculates the derivative contribution from the change in control error between the current and previous controller iterations.

Definition at line 29 of file d.h.

Member Data Documentation

◆ dt

template<typename T>
T control_system::derivative::D< T >::dt = 0.0
private

Controller sampling time.

Sampling period of the discrete-time derivative controller in seconds.

Definition at line 207 of file d.h.

◆ e_k_1

template<typename T>
T control_system::derivative::D< T >::e_k_1 = 0.0
private

Previous control error.

Stores the control error from the previous iteration.

Definition at line 215 of file d.h.

◆ Kd

template<typename T>
T control_system::derivative::D< T >::Kd = 0.0
private

Derivative gain.

Definition at line 220 of file d.h.

◆ start

template<typename T>
bool control_system::derivative::D< T >::start = true
private

Controller startup state.

Indicates whether the controller is in its startup state.

Definition at line 228 of file d.h.

◆ u_max

template<typename T>
T control_system::derivative::D< T >::u_max = 9999999999
private

Maximum controller output.

Defines the maximum allowed magnitude of the controller output.

Definition at line 237 of file d.h.


The documentation for this class was generated from the following files:
  • include/derivative/d.h
  • src/derivative/d.tpp