update 1/27/16

Dependencies:   mbed

Fork of R5_StepperDrive by Jaime Martinez

Committer:
j_j205
Date:
Wed Jan 27 16:40:02 2016 +0000
Revision:
1:909572175aad
Parent:
0:266a770a17e9
Child:
2:80c0b2a5adc0
update 1/27/16

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jmar11 0:266a770a17e9 1 #ifndef _STEPPER_DRIVE_
jmar11 0:266a770a17e9 2 #define _STEPPER_DRIVE_
jmar11 0:266a770a17e9 3
jmar11 0:266a770a17e9 4 #include "mbed.h"
jmar11 0:266a770a17e9 5
jmar11 0:266a770a17e9 6 #define Ustep 16 //microstepping setup: 1, 2, 4, 8, or 16
jmar11 0:266a770a17e9 7
jmar11 0:266a770a17e9 8 class StepperDrive{
jmar11 0:266a770a17e9 9 public:
j_j205 1:909572175aad 10 StepperDrive(Serial &pc1, PinName in1, PinName in2, bool in3, PinName in4, PinName in5, bool in6, float in7, float in8, float in9 = 1000);
jmar11 0:266a770a17e9 11 //(stepPinLeft, dirPinLeft, invertLeft, stepPinRight, dirPinRight, invertRight, wheelCircum, wheelSepar, periodUs)
jmar11 0:266a770a17e9 12 int move(float distance, float angle);
jmar11 0:266a770a17e9 13 bool isMoveDone();
jmar11 0:266a770a17e9 14
j_j205 1:909572175aad 15 Serial &pc;
j_j205 1:909572175aad 16 int getRightSteps() { return rightSteps; }
j_j205 1:909572175aad 17 int getLeftSteps() { return leftSteps; }
j_j205 1:909572175aad 18
jmar11 0:266a770a17e9 19 private:
jmar11 0:266a770a17e9 20 Ticker pit; //periodic interrupt timer
jmar11 0:266a770a17e9 21
jmar11 0:266a770a17e9 22 void pitCallback();
jmar11 0:266a770a17e9 23
jmar11 0:266a770a17e9 24 void stepRight(bool dir);
jmar11 0:266a770a17e9 25 void stepLeft(bool dir);
jmar11 0:266a770a17e9 26
jmar11 0:266a770a17e9 27 DigitalOut leftStep;
jmar11 0:266a770a17e9 28 DigitalOut leftDir;
jmar11 0:266a770a17e9 29 DigitalOut rightStep;
jmar11 0:266a770a17e9 30 DigitalOut rightDir;
jmar11 0:266a770a17e9 31
jmar11 0:266a770a17e9 32 float wheelCircum; //wheel circumference
jmar11 0:266a770a17e9 33 float wheelSepar; //distance between wheels
jmar11 0:266a770a17e9 34 bool invertLeft; //software wheel direction inversion
jmar11 0:266a770a17e9 35 bool invertRight; //software wheel direction inversion
jmar11 0:266a770a17e9 36 bool moveComplete;
jmar11 0:266a770a17e9 37
jmar11 0:266a770a17e9 38 int leftSteps;
jmar11 0:266a770a17e9 39 int rightSteps;
jmar11 0:266a770a17e9 40 float leftStepsPC;
jmar11 0:266a770a17e9 41 float rightStepsPC;
jmar11 0:266a770a17e9 42 float leftError;
jmar11 0:266a770a17e9 43 float rightError;
jmar11 0:266a770a17e9 44 };
jmar11 0:266a770a17e9 45
jmar11 0:266a770a17e9 46 #endif