Pid#
- group drv_pid
Implementation of a PID controller.
- Author
Alexandre Abadie alexandre.abadie@inria.fr
- Copyright
Inria, 2022
Enums
Functions
-
void db_pid_init(pid_t *pid, float input, float target, float kp, float ki, float kd, float output_min, float output_max, uint32_t sample_time, pid_mode_t mode, pid_direction_t direction)#
Initialize a PID control loop.
- Parameters:
pid – [in] Pointer to the pid struct
input – [in] Initial input value
target – [in] Target value
kp – [in] Gain applied to the input value
ki – [in] Gain applied to the integrated term
kd – [in] Gain applied to the derivative term
output_min – [in] Minimum output value
output_max – [in] Maximum output value
sample_time – [in] Sampling time of the pid (correspond to the update rate)
mode – [in] PID mode (manual or automatic)
direction – [in] Direction of the PID (direct or reversed)
-
void db_pid_update(pid_t *pid)#
Update the PID state.
Input attribute of the PID should be updated before calling this function
- Parameters:
pid – [inout] Pointer to the pid struct
-
void db_pid_set_gains(pid_t *pid, const pid_gains_t *gains)#
Set PID gains.
- Parameters:
pid – [in] Pointer to the pid struct
gains – [in] Pointer to the gains struct
-
void db_pid_set_sample_time(pid_t *pid, uint32_t sample_time)#
Set PID sample time (in milliseconds)
- Parameters:
pid – [in] Pointer to the pid struct
sample_time – [in] Sample time in milliseconds (must be > 0)
-
void db_pid_set_output_limits(pid_t *pid, float output_min, float output_max)#
Set PID output limits.
- Parameters:
pid – [in] Pointer to the pid struct
output_min – [in] Minimum value of output
output_max – [in] Maximum value of output
-
void db_pid_set_mode(pid_t *pid, pid_mode_t mode)#
Update the mode of the PID (manual or automatic)
- Parameters:
pid – [in] Pointer to the pid struct
mode – [in] New mode
-
void db_pid_set_direction(pid_t *pid, pid_direction_t direction)#
Update the direction of the PID.
- Parameters:
pid – [in] Pointer to the pid struct
direction – [in] New direction
-
struct pid_gains_t#
PID gains.
-
struct pid_state_t#
PID internal state.
-
struct pid_t#
PID instance.
Public Members
-
pid_gains_t gains#
Factor parameters of the PID.
-
pid_mode_t mode#
Current mode, auto or manual.
-
pid_direction_t direction#
Direction.
-
pid_state_t state#
Internal state.
-
uint32_t sample_time#
Sampling time in milliseconds.
-
float input#
Current input value.
-
float output#
Last computed output.
-
float target#
Current target.
-
float output_min#
Minimal value allowed for output.
-
float output_max#
Maximal value allowed for output.
-
pid_gains_t gains#