Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HIDScope QEI biquadFilter mbed
Fork of NR_method by
Diff: PID_controler.h
- Revision:
- 2:f68fd7b1c655
- Parent:
- 1:fafea1d00d0c
diff -r fafea1d00d0c -r f68fd7b1c655 PID_controler.h
--- a/PID_controler.h Thu Nov 01 09:42:53 2018 +0000
+++ b/PID_controler.h Thu Nov 01 11:13:32 2018 +0000
@@ -1,20 +1,6 @@
-double PID_controller(double error, double Kp, double Ki, double Kd, double Ts)
-{
- static double error_integral = 0;
- static double error_prev = error;
- static BiQuad LowPassFilter(0.0640, 0.1279, 0.0640, -1.1683, 0.4241);
-
- //proportional part
- double u_k = Kp * error;
+#ifndef PID_controler
+#define PID_controler
- //Integral part
- error_integral = error_integral + error * Ts;
- double u_i = Ki * error_integral;
+ double PID_controller(double error, double Kp, double Ki, double Kd, double Ts);
- // Derivative part
- double error_derivative = (error - error_prev)/Ts;
- double filtered_error_derivative = LowPassFilter.step(error_derivative);
- double u_d = Kd * filtered_error_derivative;
- error_prev = error;
- return ((u_k + u_i + u_d)/10000);
-}
\ No newline at end of file
+#endif
\ No newline at end of file
