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: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
Diff: controller_copy.cpp
- Revision:
- 49:a9ed4f4cdef7
- Parent:
- 48:39f84359998a
- Child:
- 50:283a831f84a9
- Child:
- 51:4ff37a929849
--- a/controller_copy.cpp Mon Oct 14 20:05:57 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -//Gains -double e = 1.02; -double Ts = 0.92; - - double K_p = 1;//Position gain - double K_i = 1;//Integral gain - double K_d = 1;//Diverentiation gain - - //static double u_i = 0; - static double e_Prev = 0; - -double ControllerPID(double e, double Ts) -{ - double u_p = K_p*e; //Position action - double u_i = K_i*(e*Ts+u_i); //Integral action - double u_d = K_d*((e-e_Prev)/Ts); //Diverential action - - e_Prev = e; //Write error to previous error - - double u; - - u = u_p + u_i + u_d; - - return u; -} \ No newline at end of file