BroBot Code for ESE350 Lab6 part 3 (Skeleton)

Dependencies:   MPU6050_V3 mbed-rtos mbed

Fork of BroBot_RTOS_ESE350 by Carter Sharer

Revision:
4:2512939c10f0
Parent:
3:2f76ffbc5cef
Child:
6:62cdb7482b50
--- a/stepper_motors.h	Wed Oct 12 05:04:10 2016 +0000
+++ b/stepper_motors.h	Tue Oct 18 20:44:21 2016 +0000
@@ -18,22 +18,39 @@
 int16_t speed_M2;  //Speed of motor 2
 int16_t motor1, motor2;
 
+//Motor Position
+int pos_M1 = 0, pos_M2 = 0;
+
 // =============================================================================
 // ===                   Interrupt Service Soutine                           ===
 // =============================================================================
 //ISR to step motor 1
 void ISR1(void)
 {
+    //Step Motor
     step_M1 = 1;
     wait_us(1);
     step_M1 = 0;
+    
+    //Update Postion
+    if(dir_M1)
+        pos_M1++;
+    else
+        pos_M1--;    
 }
 //ISR to step motor 2
 void ISR2(void)
 {
+    //Step Motor
     step_M2 = 1;
     wait_us(1);
     step_M2 = 0;
+    
+    //Update Position
+    if(dir_M2)
+        pos_M2++;
+    else
+        pos_M2--;
 }
 
 //Set motor 1 speed. Speed [-100, +100]