Biorobotics
/
Controller
Controller futhers (PI)
Diff: main.cpp
- Revision:
- 5:d1ab07fd3355
- Parent:
- 4:0844ab0d7d93
- Child:
- 6:8ab07cce3098
--- a/main.cpp Fri Oct 09 11:29:40 2015 +0000 +++ b/main.cpp Wed Oct 14 10:33:34 2015 +0000 @@ -28,7 +28,20 @@ double Rotation = 2; // rotation in degree double movement = Rotation * 360 * resolution; // times 360 to make Rotations degree. +// defining flags +volatile bool flag_motor = false; +volatile bool flag_pcprint = false; +// making flags. +void Go_flag_motor() +{ + flag_motor = true; +} + +void Go_flag_pcprint() +{ + flag_pcprint = true; +} // Reusable P controller double PI(double error, const double Kp, const double Ki, double Ts, double &e_int) @@ -78,9 +91,21 @@ int main() { - 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 ) { } + aansturen.attach( &Go_flag_motor, 0.001f ); // 100 Hz // timer 0.00001f motor keeps spinning + Printen.attach(&Go_flag_pcprint,0.1f); // 10 Hz // printstatement here because printing cost to much time. the motor void wouldn't be completed + while( 1 ) { + + if(flag_motor) { + flag_motor = false; + motor1_Controller(); + } + + if(flag_pcprint) { + flag_pcprint = false; + counts_showing(); + } + + } }