dror balbul
/
pidtaurd
taurd for noam
PID.h@2:fd1023193cc4, 2019-12-20 (annotated)
- Committer:
- drorbalbul
- Date:
- Fri Dec 20 16:29:33 2019 +0000
- Revision:
- 2:fd1023193cc4
pidtaurd
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
drorbalbul | 2:fd1023193cc4 | 1 | |
drorbalbul | 2:fd1023193cc4 | 2 | #ifndef PID_H |
drorbalbul | 2:fd1023193cc4 | 3 | #define PID_H |
drorbalbul | 2:fd1023193cc4 | 4 | |
drorbalbul | 2:fd1023193cc4 | 5 | #include <stdbool.h> |
drorbalbul | 2:fd1023193cc4 | 6 | #include <stdint.h> |
drorbalbul | 2:fd1023193cc4 | 7 | |
drorbalbul | 2:fd1023193cc4 | 8 | typedef struct |
drorbalbul | 2:fd1023193cc4 | 9 | { // Input, output and setpoint |
drorbalbul | 2:fd1023193cc4 | 10 | float * input; |
drorbalbul | 2:fd1023193cc4 | 11 | float * output; |
drorbalbul | 2:fd1023193cc4 | 12 | float * setpoint; |
drorbalbul | 2:fd1023193cc4 | 13 | // Tuning parameters |
drorbalbul | 2:fd1023193cc4 | 14 | float Kp; |
drorbalbul | 2:fd1023193cc4 | 15 | float Ki; |
drorbalbul | 2:fd1023193cc4 | 16 | float Kd; |
drorbalbul | 2:fd1023193cc4 | 17 | // Output minimum and maximum values |
drorbalbul | 2:fd1023193cc4 | 18 | float minOutput; |
drorbalbul | 2:fd1023193cc4 | 19 | float maxOutput; |
drorbalbul | 2:fd1023193cc4 | 20 | // Variables for PID algorithm |
drorbalbul | 2:fd1023193cc4 | 21 | float sumError; |
drorbalbul | 2:fd1023193cc4 | 22 | float lastInput; |
drorbalbul | 2:fd1023193cc4 | 23 | float lastError; |
drorbalbul | 2:fd1023193cc4 | 24 | }pid; |
drorbalbul | 2:fd1023193cc4 | 25 | |
drorbalbul | 2:fd1023193cc4 | 26 | #ifdef __cplusplus |
drorbalbul | 2:fd1023193cc4 | 27 | extern "C" { |
drorbalbul | 2:fd1023193cc4 | 28 | #endif |
drorbalbul | 2:fd1023193cc4 | 29 | |
drorbalbul | 2:fd1023193cc4 | 30 | pid* pid_create(pid* pid, float* input, float* output, float* setoint, float kp, float ki, float kd); |
drorbalbul | 2:fd1023193cc4 | 31 | |
drorbalbul | 2:fd1023193cc4 | 32 | void pid_compute(pid* pid); |
drorbalbul | 2:fd1023193cc4 | 33 | |
drorbalbul | 2:fd1023193cc4 | 34 | |
drorbalbul | 2:fd1023193cc4 | 35 | void pid_tune(pid* pid, float kp, float ki, float kd); |
drorbalbul | 2:fd1023193cc4 | 36 | |
drorbalbul | 2:fd1023193cc4 | 37 | |
drorbalbul | 2:fd1023193cc4 | 38 | void pid_limits(pid* pid, float min, float max); |
drorbalbul | 2:fd1023193cc4 | 39 | |
drorbalbul | 2:fd1023193cc4 | 40 | |
drorbalbul | 2:fd1023193cc4 | 41 | |
drorbalbul | 2:fd1023193cc4 | 42 | #ifdef __cplusplus |
drorbalbul | 2:fd1023193cc4 | 43 | } |
drorbalbul | 2:fd1023193cc4 | 44 | #endif |
drorbalbul | 2:fd1023193cc4 | 45 | |
drorbalbul | 2:fd1023193cc4 | 46 | #endif |
drorbalbul | 2:fd1023193cc4 | 47 | // End of Header file |
drorbalbul | 2:fd1023193cc4 | 48 |