Explorar el Código

Merge pull request #5931 from thinkyhead/rc_core_endstop_fix

Fix CoreYX / YZ / ZX endstop logic
Scott Lahteine hace 8 años
padre
commit
8a4e9d08a3
Se han modificado 2 ficheros con 36 adiciones y 14 borrados
  1. 2
    2
      .travis.yml
  2. 34
    12
      Marlin/endstops.cpp

+ 2
- 2
.travis.yml Ver fichero

@@ -226,10 +226,10 @@ script:
226 226
   - opt_enable COREXY
227 227
   - build_marlin
228 228
   #
229
-  # Enable COREXZ
229
+  # Enable COREYX (swapped)
230 230
   #
231 231
   - restore_configs
232
-  - opt_enable COREXZ
232
+  - opt_enable COREYX
233 233
   - build_marlin
234 234
   #
235 235
   # Enable Z_DUAL_STEPPER_DRIVERS, Z_DUAL_ENDSTOPS

+ 34
- 12
Marlin/endstops.cpp Ver fichero

@@ -273,17 +273,26 @@ void Endstops::update() {
273 273
   #endif
274 274
 
275 275
   #if CORE_IS_XY || CORE_IS_XZ
276
+    #if ENABLED(COREYX) || ENABLED(COREZX)
277
+      #define CORE_X_CMP !=
278
+      #define CORE_X_NOT !
279
+    #else
280
+      #define CORE_X_CMP ==
281
+      #define CORE_X_NOT
282
+    #endif
276 283
     // Head direction in -X axis for CoreXY and CoreXZ bots.
277
-    // If DeltaA == -DeltaB, the movement is only in Y or Z axis
278
-    if ((stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]) || (stepper.motor_direction(CORE_AXIS_1) == stepper.motor_direction(CORE_AXIS_2))) {
279
-      if (stepper.motor_direction(X_HEAD))
284
+    // If steps differ, both axes are moving.
285
+    // If DeltaA == -DeltaB, the movement is only in the 2nd axis (Y or Z, handled below)
286
+    // If DeltaA ==  DeltaB, the movement is only in the 1st axis (X)
287
+    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)) {
288
+      if (CORE_X_NOT stepper.motor_direction(X_HEAD))
280 289
   #else
281
-    if (stepper.motor_direction(X_AXIS))   // stepping along -X axis (regular Cartesian bot)
290
+      if (stepper.motor_direction(X_AXIS))   // stepping along -X axis (regular Cartesian bot)
282 291
   #endif
283 292
       { // -direction
284 293
         #if ENABLED(DUAL_X_CARRIAGE)
285 294
           // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
286
-          if ((stepper.current_block->active_extruder == 0 && X_HOME_DIR == -1) || (stepper.current_block->active_extruder != 0 && X2_HOME_DIR == -1))
295
+          if ((stepper.current_block->active_extruder == 0 && X_HOME_DIR < 0) || (stepper.current_block->active_extruder != 0 && X2_HOME_DIR < 0))
287 296
         #endif
288 297
           {
289 298
             #if HAS_X_MIN
@@ -294,7 +303,7 @@ void Endstops::update() {
294 303
       else { // +direction
295 304
         #if ENABLED(DUAL_X_CARRIAGE)
296 305
           // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
297
-          if ((stepper.current_block->active_extruder == 0 && X_HOME_DIR == 1) || (stepper.current_block->active_extruder != 0 && X2_HOME_DIR == 1))
306
+          if ((stepper.current_block->active_extruder == 0 && X_HOME_DIR > 0) || (stepper.current_block->active_extruder != 0 && X2_HOME_DIR > 0))
298 307
         #endif
299 308
           {
300 309
             #if HAS_X_MAX
@@ -306,11 +315,22 @@ void Endstops::update() {
306 315
     }
307 316
   #endif
308 317
 
318
+  // Handle swapped vs. typical Core axis order
319
+  #if ENABLED(COREYX) || ENABLED(COREZY) || ENABLED(COREZX)
320
+    #define CORE_YZ_CMP ==
321
+    #define CORE_YZ_NOT !
322
+  #elif CORE_IS_XY || CORE_IS_YZ || CORE_IS_XZ
323
+    #define CORE_YZ_CMP !=
324
+    #define CORE_YZ_NOT
325
+  #endif
326
+
309 327
   #if CORE_IS_XY || CORE_IS_YZ
310 328
     // Head direction in -Y axis for CoreXY / CoreYZ bots.
311
-    // If DeltaA == DeltaB, the movement is only in X or Y axis
312
-    if ((stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]) || (stepper.motor_direction(CORE_AXIS_1) != stepper.motor_direction(CORE_AXIS_2))) {
313
-      if (stepper.motor_direction(Y_HEAD))
329
+    // If steps differ, both axes are moving
330
+    // If DeltaA ==  DeltaB, the movement is only in the 1st axis (X or Y)
331
+    // If DeltaA == -DeltaB, the movement is only in the 2nd axis (Y or Z)
332
+    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)) {
333
+      if (CORE_YZ_NOT stepper.motor_direction(Y_HEAD))
314 334
   #else
315 335
       if (stepper.motor_direction(Y_AXIS))   // -direction
316 336
   #endif
@@ -330,9 +350,11 @@ void Endstops::update() {
330 350
 
331 351
   #if CORE_IS_XZ || CORE_IS_YZ
332 352
     // Head direction in -Z axis for CoreXZ or CoreYZ bots.
333
-    // If DeltaA == DeltaB, the movement is only in X or Y axis
334
-    if ((stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]) || (stepper.motor_direction(CORE_AXIS_1) != stepper.motor_direction(CORE_AXIS_2))) {
335
-      if (stepper.motor_direction(Z_HEAD))
353
+    // If steps differ, both axes are moving
354
+    // If DeltaA ==  DeltaB, the movement is only in the 1st axis (X or Y, already handled above)
355
+    // If DeltaA == -DeltaB, the movement is only in the 2nd axis (Z)
356
+    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)) {
357
+      if (CORE_YZ_NOT stepper.motor_direction(Z_HEAD))
336 358
   #else
337 359
       if (stepper.motor_direction(Z_AXIS))
338 360
   #endif

Loading…
Cancelar
Guardar