![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
9/16
Dependencies: HCSR04_2 MPU6050_2 mbed SDFileSystem3
Fork of Autoflight2018_16 by
pid/pid.h@0:17f575135219, 2018-09-07 (annotated)
- Committer:
- HARUKIDELTA
- Date:
- Fri Sep 07 04:11:48 2018 +0000
- Revision:
- 0:17f575135219
SBUS_READ
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
HARUKIDELTA | 0:17f575135219 | 1 | #ifndef PID_MBED_H |
HARUKIDELTA | 0:17f575135219 | 2 | #define PID_MBED_H |
HARUKIDELTA | 0:17f575135219 | 3 | |
HARUKIDELTA | 0:17f575135219 | 4 | |
HARUKIDELTA | 0:17f575135219 | 5 | #include "mbed.h" |
HARUKIDELTA | 0:17f575135219 | 6 | |
HARUKIDELTA | 0:17f575135219 | 7 | class PID |
HARUKIDELTA | 0:17f575135219 | 8 | { |
HARUKIDELTA | 0:17f575135219 | 9 | public: |
HARUKIDELTA | 0:17f575135219 | 10 | double kp, ki, kd, max, min, dt; |
HARUKIDELTA | 0:17f575135219 | 11 | |
HARUKIDELTA | 0:17f575135219 | 12 | //コンストラクタ |
HARUKIDELTA | 0:17f575135219 | 13 | PID(); |
HARUKIDELTA | 0:17f575135219 | 14 | PID(double Pgain, double Igain, double Dgain); |
HARUKIDELTA | 0:17f575135219 | 15 | PID(double Pgain, double Igain, double Dgain, double Max, double Min); |
HARUKIDELTA | 0:17f575135219 | 16 | //デストラクタ |
HARUKIDELTA | 0:17f575135219 | 17 | ~PID(); |
HARUKIDELTA | 0:17f575135219 | 18 | |
HARUKIDELTA | 0:17f575135219 | 19 | void initialize(void); |
HARUKIDELTA | 0:17f575135219 | 20 | void setPIDgain(double Pgain, double Igain, double Dgain); |
HARUKIDELTA | 0:17f575135219 | 21 | void setMaxMin(double Max, double Min); |
HARUKIDELTA | 0:17f575135219 | 22 | void switchMaxMin(bool Maxcheck, bool Mincheck); |
HARUKIDELTA | 0:17f575135219 | 23 | double calcPID(double nowval, double targetval, double dt); |
HARUKIDELTA | 0:17f575135219 | 24 | |
HARUKIDELTA | 0:17f575135219 | 25 | |
HARUKIDELTA | 0:17f575135219 | 26 | private: |
HARUKIDELTA | 0:17f575135219 | 27 | double integral; |
HARUKIDELTA | 0:17f575135219 | 28 | double oldval[2], diff[2]; |
HARUKIDELTA | 0:17f575135219 | 29 | bool maxcheck, mincheck; |
HARUKIDELTA | 0:17f575135219 | 30 | }; |
HARUKIDELTA | 0:17f575135219 | 31 | |
HARUKIDELTA | 0:17f575135219 | 32 | #endif |