My fully self designed first stable working Quadrocopter Software.

Dependencies:   mbed

Dependents:   fluy343

/media/uploads/maetugr/dsc09031.jpg

Committer:
maetugr
Date:
Mon Aug 31 20:20:50 2015 +0000
Revision:
10:14390c90c3f5
Parent:
7:ac2895479e34
before changing to MPU9250

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maetugr 0:12950aa67f2a 1 // by MaEtUgR
maetugr 0:12950aa67f2a 2
maetugr 1:5e2b81f2d0b4 3 #ifndef PID_H
maetugr 1:5e2b81f2d0b4 4 #define PID_H
maetugr 1:5e2b81f2d0b4 5
maetugr 0:12950aa67f2a 6 #include "mbed.h"
maetugr 0:12950aa67f2a 7
maetugr 0:12950aa67f2a 8 class PID {
maetugr 0:12950aa67f2a 9 public:
maetugr 0:12950aa67f2a 10 PID(float P, float I, float D, float Integral_Max);
maetugr 7:ac2895479e34 11 float compute(float SetPoint, float ProcessValue);
maetugr 0:12950aa67f2a 12 void setIntegrate(bool Integrate);
maetugr 0:12950aa67f2a 13 void setPID(float P, float I, float D);
maetugr 2:03e5f7ab473f 14
maetugr 2:03e5f7ab473f 15 float Value;
maetugr 0:12950aa67f2a 16
maetugr 0:12950aa67f2a 17 private:
maetugr 1:5e2b81f2d0b4 18 float P, I, D; // PID Values and limits
maetugr 0:12950aa67f2a 19
maetugr 0:12950aa67f2a 20 Timer dtTimer; // Timer to measure time between every compute
maetugr 0:12950aa67f2a 21 float LastTime; // Time when last loop was
maetugr 0:12950aa67f2a 22
maetugr 0:12950aa67f2a 23 float Integral; // the sum of all errors (constaind so it doesn't get infinite)
maetugr 0:12950aa67f2a 24 float Integral_Max; // maximum that the sum of all errors can get (not important: last error not counted)
maetugr 0:12950aa67f2a 25 bool Integrate; // if the integral is used / the controller is in use
maetugr 2:03e5f7ab473f 26
maetugr 7:ac2895479e34 27 float PreviousError; // the Error of the last computation to get derivative
maetugr 0:12950aa67f2a 28 };
maetugr 0:12950aa67f2a 29
maetugr 0:12950aa67f2a 30 #endif