forked from pms67/PID
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PID.h
39 lines (28 loc) · 718 Bytes
/
PID.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef PID_CONTROLLER_H
#define PID_CONTROLLER_H
typedef struct {
/* Controller gains */
float Kp;
float Ki;
float Kd;
/* 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;
/* Controller "memory" */
float integrator;
float prevError; /* Required for integrator */
float differentiator;
float prevMeasurement; /* Required for differentiator */
/* Controller output */
float out;
} PIDController;
void PIDController_Init(PIDController *pid);
float PIDController_Update(PIDController *pid, float setpoint, float measurement);
#endif