add pid controller
parent
eb680bac89
commit
836d2e3e6e
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* pid_controller.h
|
||||
*
|
||||
* Created on: Apr 24, 2016
|
||||
* Author: subham roy
|
||||
*/
|
||||
|
||||
#ifndef __PID_CONTROLLER_H
|
||||
#define __PID_CONTROLLER_H
|
||||
|
||||
typedef struct {
|
||||
/* PID controller parameters */
|
||||
double Kp;
|
||||
double Ki;
|
||||
double Kd;
|
||||
|
||||
/* max output limits for the PID controller */
|
||||
double output_max;
|
||||
double output_min;
|
||||
|
||||
/* below are session variables for the PID controller */
|
||||
double _integral_sum;
|
||||
double _prev_err;
|
||||
double _dt;
|
||||
} PID_vars;
|
||||
|
||||
|
||||
#define PID_VARS_INIT(x) PID_vars x = {.Kp=1.0,.Ki=0.00,.Kd=0.1,.output_max=15000.0, \
|
||||
.output_min=-15000.0,._integral_sum=0.0,._prev_err=0.0,._dt=1.0}
|
||||
|
||||
/* Function Prototypes */
|
||||
double pid(PID_vars *vars, double current_err);
|
||||
|
||||
#endif
|
||||
Reference in New Issue