code for testing the pixy

Dependencies:   mbed

Committer:
huynh270
Date:
Tue May 30 09:56:04 2017 +0000
Revision:
0:214d306295fa
hello

Who changed what in which revision?

UserRevisionLine numberNew contents of line
huynh270 0:214d306295fa 1 /*
huynh270 0:214d306295fa 2 * PIDControl.h
huynh270 0:214d306295fa 3 *
huynh270 0:214d306295fa 4 * Created on: 16.04.2017
huynh270 0:214d306295fa 5 * Author: chris
huynh270 0:214d306295fa 6 */
huynh270 0:214d306295fa 7
huynh270 0:214d306295fa 8 #ifndef COMMON_PID_CONTROL_H_
huynh270 0:214d306295fa 9 #define COMMON_PID_CONTROL_H_
huynh270 0:214d306295fa 10
huynh270 0:214d306295fa 11 /**
huynh270 0:214d306295fa 12 * This class calculates a PID control
huynh270 0:214d306295fa 13 */
huynh270 0:214d306295fa 14 class PID_Control
huynh270 0:214d306295fa 15 {
huynh270 0:214d306295fa 16 public:
huynh270 0:214d306295fa 17 PID_Control();
huynh270 0:214d306295fa 18 virtual ~PID_Control();
huynh270 0:214d306295fa 19
huynh270 0:214d306295fa 20 float calc(float e, float period);
huynh270 0:214d306295fa 21 void setPIDValues(float p, float i, float d, float max, float min, float _iMax);
huynh270 0:214d306295fa 22
huynh270 0:214d306295fa 23 private:
huynh270 0:214d306295fa 24 /**
huynh270 0:214d306295fa 25 * the proportional gain
huynh270 0:214d306295fa 26 */
huynh270 0:214d306295fa 27 float kp;
huynh270 0:214d306295fa 28
huynh270 0:214d306295fa 29 /**
huynh270 0:214d306295fa 30 * integral gain
huynh270 0:214d306295fa 31 */
huynh270 0:214d306295fa 32 float ki;
huynh270 0:214d306295fa 33
huynh270 0:214d306295fa 34 /**
huynh270 0:214d306295fa 35 * differential gain
huynh270 0:214d306295fa 36 */
huynh270 0:214d306295fa 37 float kd;
huynh270 0:214d306295fa 38
huynh270 0:214d306295fa 39 /**
huynh270 0:214d306295fa 40 * Sum of all the errors
huynh270 0:214d306295fa 41 */
huynh270 0:214d306295fa 42 float iSum;
huynh270 0:214d306295fa 43
huynh270 0:214d306295fa 44 /**
huynh270 0:214d306295fa 45 * Error value one iteration befor
huynh270 0:214d306295fa 46 */
huynh270 0:214d306295fa 47 float eOld;
huynh270 0:214d306295fa 48
huynh270 0:214d306295fa 49 float max;
huynh270 0:214d306295fa 50 float min;
huynh270 0:214d306295fa 51 float iMax;
huynh270 0:214d306295fa 52
huynh270 0:214d306295fa 53 };
huynh270 0:214d306295fa 54
huynh270 0:214d306295fa 55 #endif /* COMMON_PID_CONTROL_H_ */