P-controller geordend
Dependencies: Encoder HIDScope MODSERIAL mbed
Diff: main.cpp
- Revision:
- 14:5534b8282a06
- Parent:
- 13:eaaeb41e22d2
- Child:
- 15:a5849f3a60fc
--- a/main.cpp Thu Nov 02 20:16:38 2017 +0000 +++ b/main.cpp Thu Nov 02 22:25:35 2017 +0000 @@ -17,7 +17,7 @@ MODSERIAL pc(USBTX,USBRX); float PwmPeriod = 1.0/5000.0; //set up of PWM periode (5000 Hz, want 5000 periodes in 1 seconde) -const float Ts = 0.002; // tickettijd/ sample time +const float Ts = 0.1; // tickettijd/ sample time float e_prev = 0; float e_int = 0; @@ -64,7 +64,7 @@ float Derivative = kd*VelocityError; e_prev = error; - float ki = 0.00005; // kind of scaled. + float ki = 0.0005; // kind of scaled. e_int = e_int+Ts*error; float Integrator = ki*e_int; @@ -83,7 +83,7 @@ float Derivative2 = kd2*VelocityError2; e_prev2 = error2; - float ki2 = 0.0005; // kind of scaled. + float ki2 = 0.005; // kind of scaled. e_int2 = e_int2+Ts*error2; float Integrator2 = ki2*e_int2;