Browse Source

CORExx endstop detection fixes

1. The CORExx printers were checking more endstop axis than needed.

2. Removed all the CORE_xx_NOT logic.  The motor_direction(xx) routine
always returns the correct data so it is not needed.  It was actually
cause the wrong direction to be checked in some cases.

3. Made the logic/defines for X, Y & Z axis all the same.  The old logic
checked inappropriate configurations for Y and didn't check all the
correct configurations on Z.

4. Added a check for zero steps before the X, Y & Z axis.  Previously
would check the they axis even if there were no movement.
Bob-the-Kuhn 7 years ago
parent
commit
445d39e95a
1 changed files with 68 additions and 37 deletions
  1. 68
    37
      Marlin/endstops.cpp

+ 68
- 37
Marlin/endstops.cpp View File

@@ -266,39 +266,48 @@ void Endstops::update() {
266 266
     } while(0)
267 267
 
268 268
   #if ENABLED(G38_PROBE_TARGET) && PIN_EXISTS(Z_MIN_PROBE) && !(CORE_IS_XY || CORE_IS_XZ)
269
-  // If G38 command then check Z_MIN_PROBE for every axis and every direction
269
+    // If G38 command is active check Z_MIN_PROBE for ALL movement
270 270
     if (G38_move) {
271 271
       UPDATE_ENDSTOP_BIT(Z, MIN_PROBE);
272 272
       if (TEST_ENDSTOP(_ENDSTOP(Z, MIN_PROBE))) {
273
-        if      (stepper.current_block->steps[_AXIS(X)] > 0) {_ENDSTOP_HIT(X); stepper.endstop_triggered(_AXIS(X));}
274
-        else if (stepper.current_block->steps[_AXIS(Y)] > 0) {_ENDSTOP_HIT(Y); stepper.endstop_triggered(_AXIS(Y));}
275
-        else if (stepper.current_block->steps[_AXIS(Z)] > 0) {_ENDSTOP_HIT(Z); stepper.endstop_triggered(_AXIS(Z));}
273
+        if      (stepper.current_block->steps[_AXIS(X)] > 0) { _ENDSTOP_HIT(X); stepper.endstop_triggered(_AXIS(X)); }
274
+        else if (stepper.current_block->steps[_AXIS(Y)] > 0) { _ENDSTOP_HIT(Y); stepper.endstop_triggered(_AXIS(Y)); }
275
+        else if (stepper.current_block->steps[_AXIS(Z)] > 0) { _ENDSTOP_HIT(Z); stepper.endstop_triggered(_AXIS(Z)); }
276 276
         G38_endstop_hit = true;
277 277
       }
278 278
     }
279 279
   #endif
280 280
 
281
-  #if CORE_IS_XY || CORE_IS_XZ
282
-    #if ENABLED(COREYX) || ENABLED(COREZX)
281
+    #if ENABLED(COREXY) || ENABLED(COREXZ)
282
+      #define CORE_X_CMP ==
283
+    #elif ENABLED(COREYX) || ENABLED(COREZX)
283 284
       #define CORE_X_CMP !=
284
-      #define CORE_X_NOT !
285
+    #endif
286
+
287
+    /**
288
+     * Head direction in -X axis for CoreXY and CoreXZ bots.
289
+     *
290
+     * If steps differ, both axes are moving.
291
+     * If DeltaA == -DeltaB, the movement is only in the 2nd axis (Y or Z, handled below)
292
+     * If DeltaA ==  DeltaB, the movement is only in the 1st axis (X)
293
+     */
294
+    #if CORE_IS_XY || CORE_IS_XZ
295
+      if (stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]
296
+        || (    stepper.current_block->steps[CORE_AXIS_1] > 0
297
+             && stepper.motor_direction(CORE_AXIS_1) CORE_X_CMP stepper.motor_direction(CORE_AXIS_2)
298
+           )
299
+      ) {
300
+        if (stepper.motor_direction(X_HEAD))
285 301
     #else
286
-      #define CORE_X_CMP ==
287
-      #define CORE_X_NOT
302
+      if (stepper.current_block->steps[X_AXIS] > 0)
303
+        if (stepper.motor_direction(X_AXIS))   // stepping along -X axis (regular Cartesian bot)
288 304
     #endif
289
-    // Head direction in -X axis for CoreXY and CoreXZ bots.
290
-    // If steps differ, both axes are moving.
291
-    // If DeltaA == -DeltaB, the movement is only in the 2nd axis (Y or Z, handled below)
292
-    // If DeltaA ==  DeltaB, the movement is only in the 1st axis (X)
293
-    if (stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2] || stepper.motor_direction(CORE_AXIS_1) CORE_X_CMP stepper.motor_direction(CORE_AXIS_2)) {
294
-      if (CORE_X_NOT stepper.motor_direction(X_HEAD))
295
-  #else
296
-      if (stepper.motor_direction(X_AXIS))   // stepping along -X axis (regular Cartesian bot)
297
-  #endif
298 305
       { // -direction
299 306
         #if ENABLED(DUAL_X_CARRIAGE)
300 307
           // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
301
-          if ((stepper.current_block->active_extruder == 0 && X_HOME_DIR < 0) || (stepper.current_block->active_extruder != 0 && X2_HOME_DIR < 0))
308
+          if ( (stepper.current_block->active_extruder == 0 && X_HOME_DIR < 0)
309
+            || (stepper.current_block->active_extruder != 0 && X2_HOME_DIR < 0)
310
+          )
302 311
         #endif
303 312
           {
304 313
             #if HAS_X_MIN
@@ -309,7 +318,9 @@ void Endstops::update() {
309 318
       else { // +direction
310 319
         #if ENABLED(DUAL_X_CARRIAGE)
311 320
           // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
312
-          if ((stepper.current_block->active_extruder == 0 && X_HOME_DIR > 0) || (stepper.current_block->active_extruder != 0 && X2_HOME_DIR > 0))
321
+          if ( (stepper.current_block->active_extruder == 0 && X_HOME_DIR > 0)
322
+            || (stepper.current_block->active_extruder != 0 && X2_HOME_DIR > 0)
323
+          )
313 324
         #endif
314 325
           {
315 326
             #if HAS_X_MAX
@@ -322,22 +333,28 @@ void Endstops::update() {
322 333
   #endif
323 334
 
324 335
   // Handle swapped vs. typical Core axis order
325
-  #if ENABLED(COREYX) || ENABLED(COREZY) || ENABLED(COREZX)
336
+  #if ENABLED(COREYX) || ENABLED(COREYZ)
326 337
     #define CORE_YZ_CMP ==
327
-    #define CORE_YZ_NOT !
328
-  #elif CORE_IS_XY || CORE_IS_YZ || CORE_IS_XZ
338
+  #elif ENABLED(COREXY) || ENABLED(COREZY)
329 339
     #define CORE_YZ_CMP !=
330
-    #define CORE_YZ_NOT
331 340
   #endif
332 341
 
333 342
   #if CORE_IS_XY || CORE_IS_YZ
334
-    // Head direction in -Y axis for CoreXY / CoreYZ bots.
335
-    // If steps differ, both axes are moving
336
-    // If DeltaA ==  DeltaB, the movement is only in the 1st axis (X or Y)
337
-    // If DeltaA == -DeltaB, the movement is only in the 2nd axis (Y or Z)
338
-    if (stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2] || stepper.motor_direction(CORE_AXIS_1) CORE_YZ_CMP stepper.motor_direction(CORE_AXIS_2)) {
339
-      if (CORE_YZ_NOT stepper.motor_direction(Y_HEAD))
343
+    /**
344
+     * Head direction in -Y axis for CoreXY / CoreYZ bots.
345
+     *
346
+     * If steps differ, both axes are moving
347
+     * If DeltaA ==  DeltaB, the movement is only in the 1st axis (X or Y)
348
+     * If DeltaA == -DeltaB, the movement is only in the 2nd axis (Y or Z)
349
+     */
350
+    if (stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]
351
+      || (    stepper.current_block->steps[CORE_AXIS_1] > 0
352
+           && stepper.motor_direction(CORE_AXIS_1) CORE_YZ_CMP stepper.motor_direction(CORE_AXIS_2)
353
+         )
354
+    ) {
355
+      if (stepper.motor_direction(Y_HEAD))
340 356
   #else
357
+    if (stepper.current_block->steps[Y_AXIS] > 0)
341 358
       if (stepper.motor_direction(Y_AXIS))   // -direction
342 359
   #endif
343 360
       { // -direction
@@ -354,19 +371,33 @@ void Endstops::update() {
354 371
     }
355 372
   #endif
356 373
 
374
+
375
+  #if ENABLED(COREZX) || ENABLED(COREZY)
376
+    #define CORE_YZ_CMP ==
377
+  #elif ENABLED(COREXZ) || ENABLED(COREYZ)
378
+    #define CORE_YZ_CMP !=
379
+  #endif
380
+
357 381
   #if CORE_IS_XZ || CORE_IS_YZ
358
-    // Head direction in -Z axis for CoreXZ or CoreYZ bots.
359
-    // If steps differ, both axes are moving
360
-    // If DeltaA ==  DeltaB, the movement is only in the 1st axis (X or Y, already handled above)
361
-    // If DeltaA == -DeltaB, the movement is only in the 2nd axis (Z)
362
-    if (stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2] || stepper.motor_direction(CORE_AXIS_1) CORE_YZ_CMP stepper.motor_direction(CORE_AXIS_2)) {
363
-      if (CORE_YZ_NOT stepper.motor_direction(Z_HEAD))
382
+    /**
383
+     * Head direction in -Z axis for CoreXZ or CoreYZ bots.
384
+     *
385
+     * If steps differ, both axes are moving
386
+     * If DeltaA ==  DeltaB, the movement is only in the 1st axis (X or Y, already handled above)
387
+     * If DeltaA == -DeltaB, the movement is only in the 2nd axis (Z)
388
+     */
389
+    if (stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]
390
+      || (    stepper.current_block->steps[CORE_AXIS_1] > 0
391
+           && stepper.motor_direction(CORE_AXIS_1) CORE_YZ_CMP stepper.motor_direction(CORE_AXIS_2)
392
+         )
393
+    ) {
394
+      if (stepper.motor_direction(Z_HEAD))
364 395
   #else
396
+    if (stepper.current_block->steps[Z_AXIS] > 0)
365 397
       if (stepper.motor_direction(Z_AXIS))
366 398
   #endif
367 399
       { // Z -direction. Gantry down, bed up.
368 400
         #if HAS_Z_MIN
369
-
370 401
           #if ENABLED(Z_DUAL_ENDSTOPS)
371 402
 
372 403
             UPDATE_ENDSTOP_BIT(Z, MIN);

Loading…
Cancel
Save