A simple stepper motor driver library, supporting micro-stepping drivers.
Dependents: Test_LCDTS_UI_StepperMove
Table.cpp@2:97b1bc1f0b5f, 2020-11-14 (annotated)
- Committer:
- Abdel64
- Date:
- Sat Nov 14 11:44:18 2020 +0000
- Revision:
- 2:97b1bc1f0b5f
Compile OK incl. Table class
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Abdel64 | 2:97b1bc1f0b5f | 1 | #include "Table.h" |
Abdel64 | 2:97b1bc1f0b5f | 2 | |
Abdel64 | 2:97b1bc1f0b5f | 3 | table::table(table_pins tablepin):stepper_X(0),steppers_Y(0) |
Abdel64 | 2:97b1bc1f0b5f | 4 | { |
Abdel64 | 2:97b1bc1f0b5f | 5 | stepper_X = new stepper(tablepin.X_en,tablepin.X_stepPin,tablepin.X_dir); |
Abdel64 | 2:97b1bc1f0b5f | 6 | steppers_Y = new steppers(tablepin.Y_en,tablepin.Y_stepPin,tablepin.Y_dirG,tablepin.Y_dirD); |
Abdel64 | 2:97b1bc1f0b5f | 7 | } |
Abdel64 | 2:97b1bc1f0b5f | 8 | |
Abdel64 | 2:97b1bc1f0b5f | 9 | void table::move(position pos_current, position pos_togo, float speed) |
Abdel64 | 2:97b1bc1f0b5f | 10 | { |
Abdel64 | 2:97b1bc1f0b5f | 11 | while (pos_current == pos_togo) |
Abdel64 | 2:97b1bc1f0b5f | 12 | { |
Abdel64 | 2:97b1bc1f0b5f | 13 | if (pos_current.X > pos_togo.X) { |
Abdel64 | 2:97b1bc1f0b5f | 14 | stepper_X->step(1,speed); |
Abdel64 | 2:97b1bc1f0b5f | 15 | pos_current.X = pos_current.X - 0.25; |
Abdel64 | 2:97b1bc1f0b5f | 16 | } else if (pos_current.X < pos_togo.X) { |
Abdel64 | 2:97b1bc1f0b5f | 17 | stepper_X->step(0,speed); |
Abdel64 | 2:97b1bc1f0b5f | 18 | pos_current.X = pos_current.X + 0.25; |
Abdel64 | 2:97b1bc1f0b5f | 19 | } |
Abdel64 | 2:97b1bc1f0b5f | 20 | if (pos_current.Y > pos_togo.Y) { |
Abdel64 | 2:97b1bc1f0b5f | 21 | steppers_Y->step(1,speed); |
Abdel64 | 2:97b1bc1f0b5f | 22 | pos_current.Y = pos_current.Y - 0.25; |
Abdel64 | 2:97b1bc1f0b5f | 23 | } else if (pos_current.Y < pos_togo.Y) { |
Abdel64 | 2:97b1bc1f0b5f | 24 | steppers_Y->step(0,speed); |
Abdel64 | 2:97b1bc1f0b5f | 25 | pos_current.Y = pos_current.Y + 0.25; |
Abdel64 | 2:97b1bc1f0b5f | 26 | } |
Abdel64 | 2:97b1bc1f0b5f | 27 | } |
Abdel64 | 2:97b1bc1f0b5f | 28 | } |