Self-Balancing bot for MAX32630 and two wheel car.
Dependencies: mbed BMI160 SDFileSystem max32630fthr
Diff: main.cpp
- Revision:
- 7:337faf16a8d6
- Parent:
- 6:9712c04e13bf
- Child:
- 8:810396d34da8
diff -r 9712c04e13bf -r 337faf16a8d6 main.cpp --- a/main.cpp Sun Jan 15 22:11:22 2017 +0000 +++ b/main.cpp Mon Jan 16 05:31:33 2017 +0000 @@ -284,9 +284,9 @@ //PID coefficients static const float DT = 0.00125F; - static const float KP = 2.0F; - static const float KI = (0.0F*DT); - static const float KD = (0.0F/DT); + static const float KP = 3.0F; + static const float KI = (30.0F*DT); + static const float KD = (0.06F/DT); float setPoint = 0.0F; float loopCoeffs[] = {setPoint, K, KP, KI, KD, DT}; @@ -576,4 +576,5 @@ float compFilter(float K, float pitch, float gyroX, float accY, float accZ, float DT) { return ((K * (pitch + (gyroX * DT))) + ((1.0F - K) * ((180.0F / 3.1459F) * atan(accY/accZ)))); + //return ((K * (pitch + (gyroX * DT))) + ((1.0F - K) * accY)); }