first commit
This commit is contained in:
51
PID.h
Normal file
51
PID.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef PID_CONTROLLER_H
|
||||
#define PID_CONTROLLER_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct {
|
||||
|
||||
/* Controller gains */
|
||||
float Kp;
|
||||
float Ki;
|
||||
float Kd;
|
||||
|
||||
/* Default controller gains */
|
||||
float KpDefault;
|
||||
float KiDefault;
|
||||
float KdDefault;
|
||||
|
||||
/* Derivative low-pass filter time constant */
|
||||
float tau;
|
||||
|
||||
/* Output limits */
|
||||
float limMin;
|
||||
float limMax;
|
||||
|
||||
/* Integrator limits */
|
||||
float limMinInt;
|
||||
float limMaxInt;
|
||||
|
||||
/* Sample time (in seconds) */
|
||||
float T;
|
||||
|
||||
bool enable;
|
||||
|
||||
/* Controller "memory" */
|
||||
float proportional;
|
||||
float integrator;
|
||||
float prevError; /* Required for integrator */
|
||||
float differentiator;
|
||||
float prevMeasurement; /* Required for differentiator */
|
||||
|
||||
/* Controller output */
|
||||
float out;
|
||||
|
||||
} PidController;
|
||||
|
||||
void pidControllerInit(PidController *pid, float Kp, float Ki, float Kd, float tau, float limMin, float limMax,
|
||||
float limMinInt, float limMaxInt, float T);
|
||||
|
||||
float pidControllerUpdate(PidController *pid, float setpoint, float measurement);
|
||||
|
||||
#endif //PID_CONTROLLER_H
|
||||
Reference in New Issue
Block a user