My fully self designed first stable working Quadrocopter Software.

Dependencies:   mbed

Dependents:   fluy343

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PID.h Source File

PID.h

00001 // by MaEtUgR
00002 
00003 #ifndef PID_H
00004 #define PID_H
00005 
00006 #include "mbed.h"
00007 
00008 class PID {
00009     public:
00010         PID(float P, float I, float D, float Integral_Max);
00011         float compute(float SetPoint, float ProcessValue);
00012         void setIntegrate(bool Integrate);
00013         void setPID(float P, float I, float D);
00014         
00015         float Value;
00016     
00017     private:
00018         float P, I, D; // PID Values and limits
00019         
00020         Timer dtTimer;  // Timer to measure time between every compute
00021         float LastTime; // Time when last loop was
00022         
00023         float Integral; // the sum of all errors (constaind so it doesn't get infinite)
00024         float Integral_Max; // maximum that the sum of all errors can get (not important: last error not counted)
00025         bool Integrate; // if the integral is used / the controller is in use
00026         
00027         float PreviousError; // the Error of the last computation to get derivative
00028 };
00029 
00030 #endif