Pat McC / Mbed 2 deprecated AUV_PIDusna

Dependencies:   mbed BNO055_fusion_AUV

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PID.h Source File

PID.h

00001 /*
00002  * PID class for mbed
00003  * US Naval Academy
00004  * Robotics and Control TSD
00005  * Patrick McCorkell
00006  *
00007  * Created: 2019 Dec 11
00008  * 
00009  */
00010 
00011 #include "mbed.h"
00012 
00013 typedef struct {
00014     float Kp;
00015     float Ki;
00016     float Kd;
00017 } PID_GAINS_TypeDef;
00018 
00019 class PID
00020 {
00021 public:
00022     PID (float Kp, float Ki, float Kd, float dt, float deadzone=0);
00023     void calculate_K(float Tu);
00024     void set_dt(float dt);
00025     void clear_integral(); 
00026     void clear_error();
00027     void clear_error_previous();
00028     void clear();
00029     void set_K(float Kp, float Ki=0, float Kd=0);
00030     void set_deadzone(float deadzone);
00031     float process(float setpoint, float measured);
00032     float process(float error);
00033     void get_gain_values(PID_GAINS_TypeDef *gains);
00034 
00035 protected:
00036     float _Kp;
00037     float _Ki;
00038     float _Kd;
00039     float _floor;
00040     float _deadzone;
00041     float _dt;
00042     float _error_previous;
00043     float _integral;
00044 
00045 //private:
00046 
00047 };
00048 
00049