NOT FINISHED YET!!! My first try to get a self built fully working Quadrocopter based on an mbed, a self built frame and some other more or less cheap parts.

Dependencies:   mbed MODI2C

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PID.h Source File

PID.h

00001 // by MaEtUgR
00002 
00003 #include "mbed.h"
00004 
00005 #ifndef PID_H
00006 #define PID_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     private:
00016         float P,I,D; // PID Values
00017         
00018         Timer dtTimer;  // Timer to measure time between every compute
00019         float LastTime; // Time when last loop was
00020         
00021         float SetPoint; // the Point you want to reach
00022         float Integral; // the sum of all errors (constaind so it doesn't get infinite)
00023         float Integral_Max; // maximum that the sum of all errors can get (not important: last error not counted)
00024         float PreviousError; // the Error of the last computation to get derivative
00025         bool Integrate; // if the integral is used / the controller is in use
00026 };
00027 
00028 #endif