P controller to make the motor follow pot1
Dependencies: HIDScope MODSERIAL QEI mbed
Revision 8:b30e7b255e97, committed 2015-09-24
- Comitter:
- Gerth
- Date:
- Thu Sep 24 16:28:56 2015 +0000
- Parent:
- 7:1d276d663e1e
- Commit message:
- works; controller values need to be tuned;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 1d276d663e1e -r b30e7b255e97 main.cpp --- a/main.cpp Thu Sep 24 10:47:35 2015 +0000 +++ b/main.cpp Thu Sep 24 16:28:56 2015 +0000 @@ -9,7 +9,7 @@ QEI encoder1 (D12,D13,NC,32); // first b then a for clockwise + //ingangen -AnalogIn pot1(A0); +AnalogIn pot1(A2); //uitgangen DigitalOut motor1_direction(D7);// draairichting motor 1 (1 is CW encoder als je daar op kijkt en CW shaft als je daar op kijkt) @@ -52,9 +52,9 @@ //scopedata void scopedata() { - scope.set(0,2*PI*pot1.read()); - scope.set(1,counttorad*encoder1.getPulses()); - scope.set(2,motor1_speed_control.read()); + scope.set(0,2*PI*pot1.read());//gewenste hoek in rad van potmeter + scope.set(1,counttorad*encoder1.getPulses());//hoek in rad van outputshaft + scope.set(2,motor1_speed_control.read());//pwm signaal naar motor toe scope.send(); }