PicoLowLevel
Loading...
Searching...
No Matches
PID.h
Go to the documentation of this file.
1#ifndef PID_H
2#define PID_H
3
4#include <Arduino.h>
5
9class PID {
10 public:
11 PID(float kp, float ki, float kd, float max_output, float alpha);
12 void updateReferenceValue(float ref);
13 void setKp(float kp);
14 void setKi(float ki);
15 void setKd(float kd);
16 float getOutput();
17 float getReferenceValue();
18 void calculate();
19 void updateFeedback(float fb);
20 void resetState();
21
22 private:
23 float kp, ki, kd; // gains
24 float max_output, alpha; // constants
25 float referenceValue, output, feedback; // variables
26 float old_fe, old_integral, old_error; // state
27 unsigned long tempo;
28};
29
30
31#endif
PID controller library.
Definition PID.h:9
void setKd(float kd)
Sets the derivative gain.
Definition PID.cpp:60
float getOutput()
Gets output computed from the last iteration of calculate()
Definition PID.cpp:68
void calculate()
Main PID routine.
Definition PID.cpp:93
void updateFeedback(float fb)
Updates the feedback for PID computation.
Definition PID.cpp:36
void resetState()
Resets the PID state, as if it was the first iteration.
Definition PID.cpp:83
void setKi(float ki)
Sets the integrative gain.
Definition PID.cpp:52
float getReferenceValue()
Gets the currently used reference value.
Definition PID.cpp:76
void setKp(float kp)
Sets the proportional gain.
Definition PID.cpp:44
void updateReferenceValue(float ref)
Sets the reference value.
Definition PID.cpp:28