Biorobotics
/
Controller
Controller futhers (PI)
Diff: main.cpp
- Revision:
- 4:0844ab0d7d93
- Parent:
- 3:4abcd40682fa
- Child:
- 5:d1ab07fd3355
diff -r 4abcd40682fa -r 0844ab0d7d93 main.cpp --- a/main.cpp Thu Oct 08 13:10:32 2015 +0000 +++ b/main.cpp Fri Oct 09 11:29:40 2015 +0000 @@ -18,8 +18,8 @@ // Controller gain proportional and intergrator const double motor1_Kp = 5; // more or les random number. -const double motor1_Ki = 1; -const double M1_timestep = 0.01; // reason ticker works with 100 Hz. +const double motor1_Ki = 0; +const double M1_timestep = 0.001; // reason ticker works with 100 Hz. double motor1_error_integraal = 0; // initial value of integral error // calculating pulses to rotations in degree. @@ -38,7 +38,7 @@ e_int = e_int + Ts * error_normalised_rotation; - double PI_output = Kp * error_normalised_rotation + Ki * e_int; + double PI_output = Kp * error_normalised_rotation + Ki * e_int; // return PI_output; } // Next task, measure the error and apply the output to the plant @@ -78,8 +78,8 @@ int main() { - aansturen.attach( &motor1_Controller, 0.01f ); // 100 Hz - Printen.attach(&counts_showing,0.1f); // 10 Hz // printstatement here because printing cost to much time. the motor void wouldn't be completed + aansturen.attach( &motor1_Controller, 0.001f ); // 100 Hz + Printen.attach(&counts_showing,0.1); // 10 Hz // printstatement here because printing cost to much time. the motor void wouldn't be completed while( 1 ) { } }