STM32F302R8 with Konrad's inverter boards for senior design.

Dependencies:   mbed

Fork of Blue_Board_Ticker by Brad VanderWilp

Revision:
9:af60c737a93e
Parent:
8:2f5dc29f9bb1
Child:
10:3012bacdfc55
--- a/main.cpp	Wed Apr 13 15:41:49 2016 +0000
+++ b/main.cpp	Wed Apr 13 15:57:56 2016 +0000
@@ -37,8 +37,8 @@
     revCount = 0;
     rpmPrintFlag = 1;
 }
-//to switch to old motor config, change letter of interrupts. old:ABC, new:BCA
-void Arise()    //state1, A0 B- C+
+//original names: CBA CBA, new names: BAC BAC
+void Brise()    //state1, A0 B- C+
 {   
     phaseAEN = 0;
     phaseBEN = 1;
@@ -49,7 +49,7 @@
     revCount++;
 }
 
-void Cfall()    //state2, A+ B- C0
+void Afall()    //state2, A+ B- C0
 {
     phaseCEN = 0;
     phaseC.write(0);
@@ -59,7 +59,7 @@
     phaseBEN = 1;
 }
 
-void Brise()    //state3, A+ B0 C-
+void Crise()    //state3, A+ B0 C-
 {
     phaseBEN = 0;
     phaseCEN = 1;
@@ -68,7 +68,7 @@
     phaseAEN = 1;
 }
 
-void Afall()    //state4, A0 B+ C-
+void Bfall()    //state4, A0 B+ C-
 {
     phaseAEN = 0;
     phaseA.write(0);
@@ -79,7 +79,7 @@
 //    redLed = ! redLed;
 }
 
-void Crise()    //state5, A- B+ C0
+void Arise()    //state5, A- B+ C0
 {
     phaseCEN = 0;
     phaseAEN = 1;
@@ -88,7 +88,7 @@
     phaseBEN = 1;
 }
 
-void Bfall()    //state6, A- B0 C+
+void Cfall()    //state6, A- B0 C+
 {
     phaseBEN = 0;
     phaseB.write(0);
@@ -107,33 +107,33 @@
     //check where we start
     if(h1 == 0 && h2 == 1 && h3 == 1)   //state1
     {
+        Brise();
+        Afall();
+    }
+    else if(h1 == 0 && h2 == 0 && h3 == 1)  //state2
+    {
+        Afall();
+        Crise();
+    }
+    else if(h1 == 1 && h2 == 0 && h3 == 1)  //state3
+    {
         Crise();
         Bfall();
     }
-    else if(h1 == 0 && h2 == 0 && h3 == 1)  //state2
+    else if(h1 == 1 && h2 == 0 && h3 == 0)     //state4
     {
         Bfall();
         Arise();
     }
-    else if(h1 == 1 && h2 == 0 && h3 == 1)  //state3
+    else if(h1 == 1 && h2 == 1 && h3 == 0)  //state5
     {
         Arise();
         Cfall();
     }
-    else if(h1 == 1 && h2 == 0 && h3 == 0)     //state4
+    else    //(h1 == 0 && h2 == 1 && h3 == 0)state6
     {
         Cfall();
         Brise();
-    }
-    else if(h1 == 1 && h2 == 1 && h3 == 0)  //state5
-    {
-        Brise();
-        Afall();
-    }
-    else    //state6
-    {
-        Afall();
-        Crise();
     } 
 }