@@ -31,7 +31,7 @@ struct control_s controlY = {
31
31
32
32
// This means, the circle is executed in 360*4ms = 1440ms
33
33
#ifndef TIMESTEP_TICKS
34
- #define TIMESTEP_TICKS (TICKS_PER_S/4000 )
34
+ #define TIMESTEP_TICKS (TICKS_PER_S/250 )
35
35
#endif
36
36
37
37
// Table generated by python:
@@ -40,6 +40,8 @@ int16_t steps[91] = { 0, 27, 55, 83, 111, 139, 167, 194, 222, 250, 277, 305, 332
40
40
};
41
41
42
42
void setup () {
43
+ Serial.begin (115200 );
44
+ Serial.println (" Init" );
43
45
engine.init ();
44
46
stepperX = engine.stepperConnectToPin (stepPinStepperX);
45
47
stepperY = engine.stepperConnectToPin (stepPinStepperY);
@@ -49,9 +51,9 @@ void setup() {
49
51
}
50
52
}
51
53
stepperX->setDirectionPin (dirPinStepperX);
52
- stepperX->setEnablePin (enablePinStepperY );
54
+ stepperX->setEnablePin (enablePinStepperX );
53
55
stepperX->setAutoEnable (false );
54
- stepperY->setDirectionPin (dirPinStepperX );
56
+ stepperY->setDirectionPin (dirPinStepperY );
55
57
stepperY->setEnablePin (enablePinStepperY);
56
58
stepperY->setAutoEnable (false );
57
59
@@ -105,22 +107,44 @@ void moveStepper(FastAccelStepper *stepper, struct control_s *control) {
105
107
rc = stepper->moveTimed (steps,duration,&actual,true );
106
108
switch (rc) {
107
109
case MOVE_TIMED_EMPTY:
108
- Serial.println (" Empty" );
110
+ Serial.print (" Empty:" );
111
+ Serial.println (stepper->getStepPin () == dirPinStepperX ? ' X' :' Y' );
109
112
/* fallthrough */
110
113
case MOVE_TIMED_OK:
111
114
control->drift = duration-actual;
112
115
control->time += actual;
113
116
control->phi += 1 ;
114
117
break ;
115
118
case MOVE_TIMED_BUSY:
119
+ // Serial.println("Busy");
116
120
break ;
117
121
case MOVE_TIMED_TOO_LARGE_ERROR:
118
122
Serial.println (" Too large" );
119
123
break ;
124
+ case AQE_ERROR_TICKS_TOO_LOW:
125
+ Serial.print (" Ticks too low:" );
126
+ Serial.print (duration/steps);
127
+ Serial.print (" steps:" );
128
+ Serial.println (steps);
129
+ default :
130
+ Serial.println (rc);
120
131
}
121
132
}
122
133
134
+ uint32_t last_millis = 0 ;
135
+
123
136
void loop () {
137
+ if (last_millis != millis ()) {
138
+ Serial.print (uint32_t (controlX.time ));
139
+ Serial.print (' ' );
140
+ Serial.print (uint32_t (controlY.time ));
141
+ Serial.print (' ' );
142
+ Serial.print (stepperX->getPositionAfterCommandsCompleted ());
143
+ Serial.print (' ' );
144
+ Serial.println (millis ());
145
+ last_millis = millis ();
146
+ }
147
+
124
148
if (controlX.time < controlY.time ) {
125
149
moveStepper (stepperX, &controlX);
126
150
}
0 commit comments