![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
motor met PID controller, aangestuurd via pc.
Dependencies: HIDScope MODSERIAL QEI biquadFilter mbed
Fork of frdm_Motor_V2 by
Diff: main.cpp
- Revision:
- 8:69bde5e32dbf
- Parent:
- 7:67b50d4fb03c
- Child:
- 9:774fc3c6a39e
diff -r 67b50d4fb03c -r 69bde5e32dbf main.cpp --- a/main.cpp Tue Sep 29 12:19:51 2015 +0000 +++ b/main.cpp Tue Sep 29 12:45:26 2015 +0000 @@ -18,7 +18,7 @@ double Aantal_pulses; double Error; double refference; -const double Kp = 0.005; +const double Kp = 0.007; void ScopeSend()//Functie die de gegevens voor de scope uitleest en doorstuurt @@ -66,12 +66,27 @@ { motor2direction = 1; } - } } - - - - + if(c == 'f') + { + refference = refference - 10; + pc.printf("rx \n"); + Error = refference - Aantal_Degs; + while(abs(Error) > 1) + { + Error = refference - Aantal_Degs; + motor2speed = Kp*abs(Error); + pc.printf("reffence = %f,error = %f,Aantal degs = %f \n",refference,Error,Aantal_Degs); + if(Error > 0) + { + motor2direction = 0; + } + else + { + motor2direction = 1; + } + } + } } } \ No newline at end of file