Exercise of motor control

Dependencies:   Encoder MODSERIAL mbed

Files at this revision

API Documentation at this revision

Comitter:
Technical_Muffin
Date:
Wed Sep 23 09:42:07 2015 +0000
Parent:
6:19b8a8d255dd
Commit message:
speed control exercise working

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 19b8a8d255dd -r 2142e17a49e8 main.cpp
--- a/main.cpp	Wed Sep 23 09:14:39 2015 +0000
+++ b/main.cpp	Wed Sep 23 09:42:07 2015 +0000
@@ -19,9 +19,10 @@
    //motor CCW = 1
    while(1){//while on, turn on motor
        speed1.period_us(100);//Set period of PWM to 100 us.
-       for(float cycle=0.0; cycle < maximum; cycle=cycle +0.1){
-            speed1.write(cycle);
-            }   
-   }
+       for(float cycle=0.5; cycle < maximum; cycle=cycle + 0.1){
+            speed1.write(cycle);//write the new speed to the motor
+            wait(1.0);// wait 1 second to switch to higher speed
+            }   //it only turns at the last 5 speeds, so about 0.6 till 1.0
+   }// the cause of this is the friction it has to work against during rotation
 }