Dependencies:   DebounceIn mbed

Files at this revision

API Documentation at this revision

Comitter:
cadiamond1
Date:
Tue Jul 28 00:12:29 2015 +0000
Parent:
1:357e2c6d4e66
Commit message:
avec PWM

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 357e2c6d4e66 -r 53177e0d0c43 main.cpp
--- a/main.cpp	Mon Jul 13 23:17:35 2015 +0000
+++ b/main.cpp	Tue Jul 28 00:12:29 2015 +0000
@@ -2,13 +2,15 @@
 #include "DebounceIn.h"
 
 DigitalOut myled(LED1); //Indicator light to indicate the program is running
-//PwmOut motor(D2); //To MOSFET
-DigitalOut motor(D2); //Direct Drive the motor
+PwmOut motor(D2); //To MOSFET
+//DigitalOut motor(D2); //Direct Drive the motor
+DigitalOut clutch(D3); //Clutch power
 DigitalOut indicRe(LED2); //Indicate Rear Switch State
 DigitalOut indicFr(LED3); //Indicate Front Switch State
-//DigitalOut indicHa(LED4); //Indicate Hall Switch State
+DigitalOut indicHOLD(LED4);
 DebounceIn swiRe(D5); //Rear Limit Switch
 DebounceIn swiFr(D6); //Front Sensor Switch
+DebounceIn swiONOFF(D15); // Reset program switch
 
 Timer t; //timer for last fr hit
 int cuttFr = 1000; //ms time front
@@ -32,33 +34,31 @@
     t.start();
     printf("Start!\n");
     while(1) {
+        if (swiONOFF) {
+            wait(.5);
+            while(~swiONOFF){
+                indicHOLD = 0;
+                }
+            NVIC_SystemReset();
+            }
         if (swiFr){
             indicFr = 0;
-            wait(.75);
+            wait(.2);
             if (swiRe==0){
                 indicFr = 0;
                 indicRe = 1;
-                /*
-                myled = 0;
-                motor.write(0.25f);
-                wait(.2);
-                motor.write(0.35f);
-                wait(.2);
-                motor.write(0.45f);
-                wait(.2);
-                motor.write(0.55f);
+                clutch = 1;
+                wait(.05);
+                motor.write(0.20f);
+                wait(.1);
+                motor.write(0.40f);
                 wait(.1);
-                motor.write(0.65f);
-                wait(.1);
-                motor.write(0.75f);
-                wait(.1);
-                motor.write(0.85f);
+                motor.write(0.60f);
                 wait(.1);
-                motor.write(0.95f);
+                motor.write(0.80f);
                 wait(.1);
-                motor.write(1.00f);
-                } */
-                motor = 1;}
+                motor.write(1.00f);                
+                }
             while (swiRe==0){
                 indicFr = 0;
                 indicRe = 1;
@@ -68,7 +68,7 @@
             indicRe = 0;
             indicFr = 1;
             myled = 1;
-            //wait(1);
+            clutch = 0;
             motor= 0;
             count++;
             printf("Motor State Switch!! %d cycles \n",count);