![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
3-26-2015 DSV
Fork of R5_StepperDrive by
StepperDrive.h@3:97bea13f40a9, 2016-02-23 (annotated)
- Committer:
- j_j205
- Date:
- Tue Feb 23 23:36:09 2016 +0000
- Revision:
- 3:97bea13f40a9
- Parent:
- 2:80c0b2a5adc0
- Child:
- 4:754c74beef20
2/23/16 JJ
Who changed what in which revision?
User | Revision | Line number | New 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); |
j_j205 | 2:80c0b2a5adc0 | 11 | //(serisl &, 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(); |
j_j205 | 3:97bea13f40a9 | 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 | 3:97bea13f40a9 | 18 | |
jmar11 | 0:266a770a17e9 | 19 | private: |
jmar11 | 0:266a770a17e9 | 20 | Ticker pit; //periodic interrupt timer |
j_j205 | 3:97bea13f40a9 | 21 | |
jmar11 | 0:266a770a17e9 | 22 | void pitCallback(); |
j_j205 | 3:97bea13f40a9 | 23 | |
jmar11 | 0:266a770a17e9 | 24 | void stepRight(bool dir); |
jmar11 | 0:266a770a17e9 | 25 | void stepLeft(bool dir); |
j_j205 | 3:97bea13f40a9 | 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; |
j_j205 | 3:97bea13f40a9 | 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; |
j_j205 | 3:97bea13f40a9 | 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 |