-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpid.h
41 lines (29 loc) · 938 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
40
41
#ifndef PID_H
#define PID_H
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
typedef struct _PIDdata {
volatile float setpoint;
//pid factors
volatile float Kp;
volatile float Ki;
volatile float Kd;
//pid terms
volatile float Perr;
volatile float Ierr;
volatile float Derr;
//pid terms limits
volatile float Perrmin;
volatile float Perrmax;
volatile float Ierrmin;
volatile float Ierrmax;
} PIDdata, *ptrPIDdata;
//functions
extern void PID_Init(ptrPIDdata pPd);
extern void PID_SetPID(ptrPIDdata pPd, float setpoint, float pidP, float pidI, float pidD);
extern void PID_SetLimitsPerr(ptrPIDdata pPd, float Perr_min, float Perr_max);
extern void PID_SetLimitsIerr(ptrPIDdata pPd, float Ierr_min, float Ierr_max);
extern void PID_ResetIerr(ptrPIDdata pPd);
extern float PID_Update(ptrPIDdata pPd, float input);
#endif