Plymouth ELEC351 Group T
/
ELEC351_Group_T
FINAL PROJECT isn't it
Fork of ELEC351 by
STEPPER_MOTOR.cpp
- Committer:
- thomasmorris
- Date:
- 2018-05-07
- Revision:
- 53:71f59e195f06
File content as of revision 53:71f59e195f06:
#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 } }