-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPID.h
More file actions
39 lines (35 loc) · 970 Bytes
/
Copy pathPID.h
File metadata and controls
39 lines (35 loc) · 970 Bytes
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
#pragma once
#ifndef H_PID
#define H_PID
#include <stdio.h>
/// @brief A PID controller.
/// @param Kp The proportional gain.
/// @param Ki The integral gain.
/// @param Kd The derivative gain.
/// @param Min The minimum output (to prevent windup).
/// @param Max The maximum output (to prevent windup).
/// @param Int The integrator value.
/// @param IntMin The minimum integrator value.
/// @param IntMax The maximum integrator value.
/// @param PreviousError The previous error.
/// @param Diff The differentiator value.
/// @param PreviousMeasurement The prvious measurement.
/// @param Output The PID output.
typedef struct PID {
float Kp;
float Ki;
float Kd;
float Min;
float Max;
float Int;
float IntMin;
float IntMax;
float PreviousError;
float Diff;
float PreviousMeasurement;
float Output;
} PID;
int PIDInit(PID* P);
int PIDStep(PID* P, float Setpoint, float Measurement);
void PIDPrint(const PID P);
#endif