PID bijdrage
Dependencies: mbed
Revision 0:8c5ca301505f, committed 2018-10-26
- Comitter:
- s1574396
- Date:
- Fri Oct 26 09:42:50 2018 +0000
- Commit message:
- PID controler;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 8c5ca301505f main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Oct 26 09:42:50 2018 +0000 @@ -0,0 +1,34 @@ +#include "mbed.h" +const double Ts = // sample frequency + +//PID rotation - aanmaken van PID constanten en variabelen voor rotatie +const double = Rot_Kp = , Rot_Ki = , Rot_Kd = ; +double Rot_error = 0; +double Rot_prev_error = 0; + +//PID translation - aanmaken van PID constanten en variabelen voor translatie +const double = Trans_Kp = , Trans_Ki = , Trans_Kd = ; +double Trans_error = 0; +double Trans_prev_error = 0; + +// PID execution +double PID_control(double error, const double kp, const double ki, const double kd, +{ +// P control +double u_k = pk * error; + +// I control +error_int = error_int + (Ts * error); +double u_i = ki * error_int; + +// D control +double error_deriv = (error - error_prev); +double u_d = kd * error_deriv; +error_prev = error; + +return u_k + u_i + u_d; + +int main() +{ + +} \ No newline at end of file
diff -r 000000000000 -r 8c5ca301505f mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Oct 26 09:42:50 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187 \ No newline at end of file