Proj 324 Final

Fork of ELEC351_Group_T by Plymouth ELEC351 Group T

Revision:
53:71f59e195f06
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/STEPPER_MOTOR.cpp	Mon May 07 15:44:34 2018 +0000
@@ -0,0 +1,54 @@
+#include "mbed.h"           //Include the mbed libraries
+#include "STEPPER_MOTOR.hpp"          //Include the header file, this acts like a series of forward declarations
+#include "SERIAL_COMMANDS.hpp"
+
+//Constructor
+STEPPER_MOTOR::STEPPER_MOTOR(PinName STEP, PinName DIRECTION) : _STEP(STEP), _DIRECTION(DIRECTION) //Constructor
+{
+
+}
+
+STEPPER_MOTOR::~STEPPER_MOTOR(){}   //Destructor
+void STEPPER_MOTOR::Rotate_Steps(int Steps, int Direction)//Test this with the larger delay to see if that will increase the performance
+{
+       _DIRECTION = Direction;
+       for(int x =0 ; x < Steps; x++)
+        {
+            _STEP = 1;
+            //wait_us(500);
+            wait_ms(5);
+            //Thread::wait(1);//wait 1 ms 
+            _STEP = 0;
+            wait_ms(5);
+            //wait_us(500);
+            //Thread::wait(1);//wait 1ms
+        }
+        steps = 0;
+}
+void STEPPER_MOTOR::Permanent_Rotate_clock_wise()
+{
+    _DIRECTION = 1;
+    for(int x = 0; x< 200; x++)
+    {
+        _STEP = 1;
+        wait_us(500);
+        //Thread::wait(1);//wait 1 ms 
+        _STEP = 0;
+        wait_us(500);
+        //Thread::wait(1);//wait 1ms
+    }
+}
+void STEPPER_MOTOR::Permanent_Rotate_anti_clock_wise()
+{
+    _DIRECTION = 0;//For anti clockwise rotation
+    for(int x = 0; x< 200; x++)
+    {
+        _STEP = 1;
+        wait_us(500);
+        //Thread::wait(1);//wait 1 ms 
+        _STEP = 0;
+        wait_us(500);
+        //Thread::wait(1);//wait 1ms
+    }
+} 
+ 
\ No newline at end of file