for noam

Dependencies:   mbed Map

Committer:
drorbalbul
Date:
Fri Dec 20 15:17:18 2019 +0000
Revision:
0:33b00fa05201
noam

Who changed what in which revision?

UserRevisionLine numberNew contents of line
drorbalbul 0:33b00fa05201 1
drorbalbul 0:33b00fa05201 2 #ifndef PID_H
drorbalbul 0:33b00fa05201 3 #define PID_H
drorbalbul 0:33b00fa05201 4
drorbalbul 0:33b00fa05201 5 #include <stdbool.h>
drorbalbul 0:33b00fa05201 6 #include <stdint.h>
drorbalbul 0:33b00fa05201 7
drorbalbul 0:33b00fa05201 8 typedef struct
drorbalbul 0:33b00fa05201 9 { // Input, output and setpoint
drorbalbul 0:33b00fa05201 10 float * input;
drorbalbul 0:33b00fa05201 11 float * output;
drorbalbul 0:33b00fa05201 12 float * setpoint;
drorbalbul 0:33b00fa05201 13 // Tuning parameters
drorbalbul 0:33b00fa05201 14 float Kp;
drorbalbul 0:33b00fa05201 15 float Ki;
drorbalbul 0:33b00fa05201 16 float Kd;
drorbalbul 0:33b00fa05201 17 // Output minimum and maximum values
drorbalbul 0:33b00fa05201 18 float minOutput;
drorbalbul 0:33b00fa05201 19 float maxOutput;
drorbalbul 0:33b00fa05201 20 // Variables for PID algorithm
drorbalbul 0:33b00fa05201 21 float sumError;
drorbalbul 0:33b00fa05201 22 float lastInput;
drorbalbul 0:33b00fa05201 23 float lastError;
drorbalbul 0:33b00fa05201 24 }pid;
drorbalbul 0:33b00fa05201 25
drorbalbul 0:33b00fa05201 26 #ifdef __cplusplus
drorbalbul 0:33b00fa05201 27 extern "C" {
drorbalbul 0:33b00fa05201 28 #endif
drorbalbul 0:33b00fa05201 29
drorbalbul 0:33b00fa05201 30 pid* pid_create(pid* pid, float* input, float* output, float* setoint, float kp, float ki, float kd);
drorbalbul 0:33b00fa05201 31
drorbalbul 0:33b00fa05201 32 void pid_compute(pid* pid);
drorbalbul 0:33b00fa05201 33
drorbalbul 0:33b00fa05201 34
drorbalbul 0:33b00fa05201 35 void pid_tune(pid* pid, float kp, float ki, float kd);
drorbalbul 0:33b00fa05201 36
drorbalbul 0:33b00fa05201 37
drorbalbul 0:33b00fa05201 38 void pid_limits(pid* pid, float min, float max);
drorbalbul 0:33b00fa05201 39
drorbalbul 0:33b00fa05201 40
drorbalbul 0:33b00fa05201 41
drorbalbul 0:33b00fa05201 42 #ifdef __cplusplus
drorbalbul 0:33b00fa05201 43 }
drorbalbul 0:33b00fa05201 44 #endif
drorbalbul 0:33b00fa05201 45
drorbalbul 0:33b00fa05201 46 #endif
drorbalbul 0:33b00fa05201 47 // End of Header file
drorbalbul 0:33b00fa05201 48