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.
PID/PID.h@40:2ca410923691, 2014-02-14 (annotated)
- Committer:
- maetugr
- Date:
- Fri Feb 14 14:17:32 2014 +0000
- Revision:
- 40:2ca410923691
- Parent:
- 33:fd98776b6cc7
now with MPU6050 before taking it too FlyBed2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maetugr | 30:021e13b62575 | 1 | // by MaEtUgR |
maetugr | 30:021e13b62575 | 2 | |
maetugr | 29:8b7362a2ee14 | 3 | #include "mbed.h" |
maetugr | 29:8b7362a2ee14 | 4 | |
maetugr | 29:8b7362a2ee14 | 5 | #ifndef PID_H |
maetugr | 29:8b7362a2ee14 | 6 | #define PID_H |
maetugr | 29:8b7362a2ee14 | 7 | |
maetugr | 29:8b7362a2ee14 | 8 | class PID { |
maetugr | 29:8b7362a2ee14 | 9 | public: |
maetugr | 29:8b7362a2ee14 | 10 | PID(float P, float I, float D, float Integral_Max); |
maetugr | 29:8b7362a2ee14 | 11 | float compute(float SetPoint, float ProcessValue); |
maetugr | 29:8b7362a2ee14 | 12 | void setIntegrate(bool Integrate); |
maetugr | 33:fd98776b6cc7 | 13 | void setPID(float P, float I, float D); |
maetugr | 29:8b7362a2ee14 | 14 | |
maetugr | 29:8b7362a2ee14 | 15 | private: |
maetugr | 29:8b7362a2ee14 | 16 | float P,I,D; // PID Values |
maetugr | 29:8b7362a2ee14 | 17 | |
maetugr | 29:8b7362a2ee14 | 18 | Timer dtTimer; // Timer to measure time between every compute |
maetugr | 29:8b7362a2ee14 | 19 | float LastTime; // Time when last loop was |
maetugr | 29:8b7362a2ee14 | 20 | |
maetugr | 29:8b7362a2ee14 | 21 | float SetPoint; // the Point you want to reach |
maetugr | 29:8b7362a2ee14 | 22 | float Integral; // the sum of all errors (constaind so it doesn't get infinite) |
maetugr | 29:8b7362a2ee14 | 23 | float Integral_Max; // maximum that the sum of all errors can get (not important: last error not counted) |
maetugr | 29:8b7362a2ee14 | 24 | float PreviousError; // the Error of the last computation to get derivative |
maetugr | 29:8b7362a2ee14 | 25 | bool Integrate; // if the integral is used / the controller is in use |
maetugr | 29:8b7362a2ee14 | 26 | }; |
maetugr | 29:8b7362a2ee14 | 27 | |
maetugr | 29:8b7362a2ee14 | 28 | #endif |