Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MPU6050_V3 mbed-rtos mbed
Fork of BroBot_RTOS_Development by
Diff: stepper_motors.h
- Revision:
- 4:2512939c10f0
- Parent:
- 3:2f76ffbc5cef
- Child:
- 6:62cdb7482b50
diff -r 2f76ffbc5cef -r 2512939c10f0 stepper_motors.h
--- 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]
