No.9 Robotics / Mbed 2 deprecated Robotics_DCMotor

Dependencies:   mbed

Fork of Robotics_Lab_DCMotor by LDSC_Robotics

Files at this revision

API Documentation at this revision

Comitter:
ChangYuHsuan
Date:
Thu Apr 14 09:29:00 2016 +0000
Parent:
5:ff3b5f31a9ce
Child:
9:85cbef9febe7
Child:
10:7954ec17021d
Commit message:
Yu Hsuan;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Apr 14 08:51:41 2016 +0000
+++ b/main.cpp	Thu Apr 14 09:29:00 2016 +0000
@@ -27,6 +27,8 @@
 
 Ticker timer1;
 void timer1_interrupt(void);
+int  timer1_counter;
+
 void CN_interrupt(void);
 
 void init_TIMER(void);
@@ -49,6 +51,7 @@
 
 int main() {
     
+    init_BLUETOOTH();
     init_TIMER();
     init_PWM();
     init_CN();
@@ -131,6 +134,16 @@
     TIM1->CCER |= 0x40;
     
     PIout_2_old = PIout_2;
+    
+    timer1_counter ++;
+    if (timer1_counter == 5)
+    {
+       timer1_counter = 0;
+       if(bluetooth.writeable())
+       {
+           bluetooth.printf("V1: %f  V2: %f\n",v1,v2);
+       }
+    }
 }
 
 void CN_interrupt(void)
@@ -143,16 +156,16 @@
     if (stateA_1 == 0)
     {
         if (stateB_1 == 0)
-            state_1 = 1;
+            state_1 = 0;
         else
-            state_1 = 2;
+            state_1 = 1;
     }
     else
     {
         if (stateB_1 == 1)
-            state_1 = 3;
+            state_1 = 2;
         else
-            state_1 = 4;
+            state_1 = 3;
     }
     
     //Forward: v1Count +1
@@ -172,16 +185,16 @@
     if (stateA_2 == 0)
     {
         if (stateB_2 == 0)
-            state_2 = 1;
+            state_2 = 0;
         else
-            state_2 = 2;
+            state_2 = 1;
     }
     else
     {
         if (stateB_2 == 1)
-            state_2 = 3;
+            state_2 = 2;
         else
-            state_2 = 4;
+            state_2 = 3;
     }
     
     //Forward: v2Count +1
@@ -195,6 +208,7 @@
 void init_TIMER(void)
 {
     timer1.attach_us(&timer1_interrupt, 10000);//10ms interrupt period (100 Hz)
+    timer1_counter = 0;
 }         
    
 void init_PWM(void)