a quadcopter code

Dependencies:   Pulse RangeFinder mbed

Committer:
Gendy
Date:
Tue Nov 24 19:57:06 2015 +0000
Revision:
0:4a55d0a21ea9
Quad_project PID on angle;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Gendy 0:4a55d0a21ea9 1 #ifndef PID_Dakrory_h
Gendy 0:4a55d0a21ea9 2 #define PID_Dakrory_h
Gendy 0:4a55d0a21ea9 3 #define LIBRARY_VERSION 1.0.0
Gendy 0:4a55d0a21ea9 4
Gendy 0:4a55d0a21ea9 5 class PID
Gendy 0:4a55d0a21ea9 6 {
Gendy 0:4a55d0a21ea9 7
Gendy 0:4a55d0a21ea9 8
Gendy 0:4a55d0a21ea9 9 public:
Gendy 0:4a55d0a21ea9 10
Gendy 0:4a55d0a21ea9 11
Gendy 0:4a55d0a21ea9 12 //commonly used functions **************************************************************************
Gendy 0:4a55d0a21ea9 13 PID(float *, float *, float *, // * constructor. links the PID to the Input, Output, and
Gendy 0:4a55d0a21ea9 14 float , float , float ); // Setpoint. Initial tuning parameters are also set here
Gendy 0:4a55d0a21ea9 15
Gendy 0:4a55d0a21ea9 16 void Compute(); // * performs the PID calculation. it should be
Gendy 0:4a55d0a21ea9 17 // called every time
Gendy 0:4a55d0a21ea9 18
Gendy 0:4a55d0a21ea9 19 void SetOutputLimits(float , float ); //clamps the output to a specific range. 0-255 by default, but
Gendy 0:4a55d0a21ea9 20 //it's likely the user will want to change this depending on
Gendy 0:4a55d0a21ea9 21 //the application
Gendy 0:4a55d0a21ea9 22
Gendy 0:4a55d0a21ea9 23 void SetIntegratorLimits(float );
Gendy 0:4a55d0a21ea9 24
Gendy 0:4a55d0a21ea9 25 //available but not commonly used functions ********************************************************
Gendy 0:4a55d0a21ea9 26 void SetTunings(float , float , // * While most users will set the tunings once in the
Gendy 0:4a55d0a21ea9 27 float ); // constructor, this function gives the user the option
Gendy 0:4a55d0a21ea9 28 // of changing tunings during runtime for Adaptive control
Gendy 0:4a55d0a21ea9 29 // once it is set
Gendy 0:4a55d0a21ea9 30
Gendy 0:4a55d0a21ea9 31
Gendy 0:4a55d0a21ea9 32 //Display functions ****************************************************************
Gendy 0:4a55d0a21ea9 33
Gendy 0:4a55d0a21ea9 34 float kp; // * (P)roportional Tuning Parameter
Gendy 0:4a55d0a21ea9 35 float ki; // * (I)ntegral Tuning Parameter
Gendy 0:4a55d0a21ea9 36 float kd; // * (D)erivative Tuning Parameter
Gendy 0:4a55d0a21ea9 37
Gendy 0:4a55d0a21ea9 38
Gendy 0:4a55d0a21ea9 39 float *myInput; // * Pointers to the Input, Output, and Setpoint variables
Gendy 0:4a55d0a21ea9 40 float *myOutput; // This creates a hard link between the variables and the
Gendy 0:4a55d0a21ea9 41 float *mySetpoint; // PID, freeing the user from having to constantly tell us
Gendy 0:4a55d0a21ea9 42 // what these values are. with pointers we'll just know.
Gendy 0:4a55d0a21ea9 43
Gendy 0:4a55d0a21ea9 44
Gendy 0:4a55d0a21ea9 45 float ITerm, lasterror;
Gendy 0:4a55d0a21ea9 46
Gendy 0:4a55d0a21ea9 47
Gendy 0:4a55d0a21ea9 48 float outMin, outMax;
Gendy 0:4a55d0a21ea9 49 float max;
Gendy 0:4a55d0a21ea9 50
Gendy 0:4a55d0a21ea9 51
Gendy 0:4a55d0a21ea9 52 };
Gendy 0:4a55d0a21ea9 53 #endif