a easy way to control stepper
Dependents: Ex_stepper Example_for_learning_easy
Diff: stepper.cpp
- Revision:
- 1:9a7c41e82ca5
- Parent:
- 0:7caa07ab8d77
- Child:
- 2:8f2ae2b5c552
--- a/stepper.cpp Fri Sep 07 13:52:14 2018 +0000 +++ b/stepper.cpp Fri Sep 07 14:09:04 2018 +0000 @@ -2,8 +2,8 @@ const int unit_xy = 100; //单位长度(xy移动一格)对应unit_xy转 大约10cm/3圈/9600step 约96mm/9600step=0.1mm/10step -const int unit_x = 103; //单位长度(xy移动一格)对应unit_x转 大约10cm/3圈/9600step 约96mm/9600step=0.1mm/10step -const int unit_y = 103; //单位长度(xy移动一格)对应unit_y转 大约10cm/3圈/9600step 约96mm/9600step=0.1mm/10step +//const int unit_x = 103; //单位长度(xy移动一格)对应unit_x转 大约10cm/3圈/9600step 约96mm/9600step=0.1mm/10step +//const int unit_y = 103; //单位长度(xy移动一格)对应unit_y转 大约10cm/3圈/9600step 约96mm/9600step=0.1mm/10step float now_x = 0, now_y = 0; @@ -19,16 +19,16 @@ } for (int i = 0; i < pix; i++) { stepper.step = 1; - wait(step_halfperiod); + wait(half_period); stepper.step = 0; - wait(step_halfperiod); + wait(half_period); } } void moveTo(Stepper xStepper, Stepper yStepper, double period, float x, float y) { - rotate(xStepper, (x - now_x)*unit_xy); - rotate(yStepper, (y - now_y)*unit_xy); + rotate(xStepper, period, (x - now_x)*unit_xy); + rotate(yStepper, period, (y - now_y)*unit_xy); now_x = x; now_y = y; }