|
@@ -116,8 +116,6 @@
|
116
|
116
|
}
|
117
|
117
|
|
118
|
118
|
inline void parking_extruder_tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool no_move/*=false*/) {
|
119
|
|
- constexpr float z_raise = PARKING_EXTRUDER_SECURITY_RAISE;
|
120
|
|
-
|
121
|
119
|
if (!no_move) {
|
122
|
120
|
|
123
|
121
|
const float parkingposx[] = PARKING_EXTRUDER_PARKING_X,
|
|
@@ -140,7 +138,7 @@
|
140
|
138
|
SERIAL_ECHOLNPGM("Starting Autopark");
|
141
|
139
|
if (DEBUGGING(LEVELING)) DEBUG_POS("current position:", current_position);
|
142
|
140
|
#endif
|
143
|
|
- current_position[Z_AXIS] += z_raise;
|
|
141
|
+ current_position[Z_AXIS] += PARKING_EXTRUDER_SECURITY_RAISE;
|
144
|
142
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
145
|
143
|
SERIAL_ECHOLNPGM("(1) Raise Z-Axis ");
|
146
|
144
|
if (DEBUGGING(LEVELING)) DEBUG_POS("Moving to Raised Z-Position", current_position);
|
|
@@ -350,6 +348,8 @@ inline void invalid_extruder_error(const uint8_t e) {
|
350
|
348
|
|
351
|
349
|
#endif // DUAL_X_CARRIAGE
|
352
|
350
|
|
|
351
|
+#define DO_SWITCH_EXTRUDER (SWITCHING_EXTRUDER_SERVO_NR != SWITCHING_NOZZLE_SERVO_NR)
|
|
352
|
+
|
353
|
353
|
/**
|
354
|
354
|
* Perform a tool-change, which may result in moving the
|
355
|
355
|
* previous tool out of the way and the new tool into place.
|
|
@@ -381,127 +381,53 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
381
|
381
|
// Save current position to destination, for use later
|
382
|
382
|
set_destination_from_current();
|
383
|
383
|
|
|
384
|
+ #if HAS_LEVELING
|
|
385
|
+ // Set current position to the physical position
|
|
386
|
+ const bool leveling_was_active = planner.leveling_active;
|
|
387
|
+ set_bed_leveling_enabled(false);
|
|
388
|
+ #endif
|
|
389
|
+
|
384
|
390
|
#if ENABLED(DUAL_X_CARRIAGE)
|
385
|
391
|
|
386
|
392
|
dualx_tool_change(tmp_extruder, no_move); // Can modify no_move
|
387
|
393
|
|
388
|
394
|
#else // !DUAL_X_CARRIAGE
|
389
|
395
|
|
390
|
|
- #if ENABLED(PARKING_EXTRUDER)
|
|
396
|
+ #if ENABLED(PARKING_EXTRUDER) // Dual Parking extruder
|
391
|
397
|
parking_extruder_tool_change(tmp_extruder, no_move);
|
392
|
398
|
#endif
|
393
|
399
|
|
394
|
400
|
#if ENABLED(SWITCHING_NOZZLE)
|
395
|
|
- #define DONT_SWITCH (SWITCHING_EXTRUDER_SERVO_NR == SWITCHING_NOZZLE_SERVO_NR)
|
396
|
|
- // <0 if the new nozzle is higher, >0 if lower. A bigger raise when lower.
|
397
|
|
- const float z_diff = hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder],
|
398
|
|
- z_raise = 0.3 + (z_diff > 0.0 ? z_diff : 0.0);
|
399
|
|
-
|
400
|
|
- // Always raise by some amount
|
401
|
|
- current_position[Z_AXIS] += z_raise;
|
|
401
|
+ // Always raise by at least 0.3
|
|
402
|
+ const float z_diff = hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
|
|
403
|
+ current_position[Z_AXIS] += (z_diff > 0.0 ? z_diff : 0.0) + 0.3;
|
402
|
404
|
planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
|
403
|
405
|
move_nozzle_servo(tmp_extruder);
|
404
|
406
|
#endif
|
405
|
407
|
|
406
|
|
- /**
|
407
|
|
- * Set current_position to the position of the new nozzle.
|
408
|
|
- * Offsets are based on linear distance, so we need to get
|
409
|
|
- * the resulting position in coordinate space.
|
410
|
|
- *
|
411
|
|
- * - With grid or 3-point leveling, offset XYZ by a tilted vector
|
412
|
|
- * - With mesh leveling, update Z for the new position
|
413
|
|
- * - Otherwise, just use the raw linear distance
|
414
|
|
- *
|
415
|
|
- * Software endstops are altered here too. Consider a case where:
|
416
|
|
- * E0 at X=0 ... E1 at X=10
|
417
|
|
- * When we switch to E1 now X=10, but E1 can't move left.
|
418
|
|
- * To express this we apply the change in XY to the software endstops.
|
419
|
|
- * E1 can move farther right than E0, so the right limit is extended.
|
420
|
|
- *
|
421
|
|
- * Note that we don't adjust the Z software endstops. Why not?
|
422
|
|
- * Consider a case where Z=0 (here) and switching to E1 makes Z=1
|
423
|
|
- * because the bed is 1mm lower at the new position. As long as
|
424
|
|
- * the first nozzle is out of the way, the carriage should be
|
425
|
|
- * allowed to move 1mm lower. This technically "breaks" the
|
426
|
|
- * Z software endstop. But this is technically correct (and
|
427
|
|
- * there is no viable alternative).
|
428
|
|
- */
|
429
|
|
- #if ABL_PLANAR
|
430
|
|
- // Offset extruder, make sure to apply the bed level rotation matrix
|
431
|
|
- vector_3 tmp_offset_vec = vector_3(hotend_offset[X_AXIS][tmp_extruder],
|
432
|
|
- hotend_offset[Y_AXIS][tmp_extruder],
|
433
|
|
- 0),
|
434
|
|
- act_offset_vec = vector_3(hotend_offset[X_AXIS][active_extruder],
|
435
|
|
- hotend_offset[Y_AXIS][active_extruder],
|
436
|
|
- 0),
|
437
|
|
- offset_vec = tmp_offset_vec - act_offset_vec;
|
438
|
|
-
|
439
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
440
|
|
- if (DEBUGGING(LEVELING)) {
|
441
|
|
- tmp_offset_vec.debug(PSTR("tmp_offset_vec"));
|
442
|
|
- act_offset_vec.debug(PSTR("act_offset_vec"));
|
443
|
|
- offset_vec.debug(PSTR("offset_vec (BEFORE)"));
|
444
|
|
- }
|
445
|
|
- #endif
|
446
|
|
-
|
447
|
|
- offset_vec.apply_rotation(planner.bed_level_matrix.transpose(planner.bed_level_matrix));
|
448
|
|
-
|
449
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
450
|
|
- if (DEBUGGING(LEVELING)) offset_vec.debug(PSTR("offset_vec (AFTER)"));
|
451
|
|
- #endif
|
452
|
|
-
|
453
|
|
- // Adjustments to the current position
|
454
|
|
- const float xydiff[2] = { offset_vec.x, offset_vec.y };
|
455
|
|
- current_position[Z_AXIS] += offset_vec.z;
|
456
|
|
-
|
457
|
|
- #else // !ABL_PLANAR
|
458
|
|
-
|
459
|
|
- const float xydiff[2] = {
|
460
|
|
- hotend_offset[X_AXIS][tmp_extruder] - hotend_offset[X_AXIS][active_extruder],
|
461
|
|
- hotend_offset[Y_AXIS][tmp_extruder] - hotend_offset[Y_AXIS][active_extruder]
|
462
|
|
- };
|
463
|
|
-
|
464
|
|
- #if HAS_MESH && PLANNER_LEVELING
|
465
|
|
-
|
466
|
|
- if (planner.leveling_active) {
|
467
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
468
|
|
- if (DEBUGGING(LEVELING)) SERIAL_ECHOPAIR("Z before: ", current_position[Z_AXIS]);
|
469
|
|
- #endif
|
470
|
|
- float x2 = current_position[X_AXIS] + xydiff[X_AXIS],
|
471
|
|
- y2 = current_position[Y_AXIS] + xydiff[Y_AXIS],
|
472
|
|
- z1 = current_position[Z_AXIS], z2 = z1;
|
473
|
|
- planner.apply_leveling(current_position[X_AXIS], current_position[Y_AXIS], z1);
|
474
|
|
- planner.apply_leveling(x2, y2, z2);
|
475
|
|
- current_position[Z_AXIS] += z2 - z1;
|
476
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
477
|
|
- if (DEBUGGING(LEVELING))
|
478
|
|
- SERIAL_ECHOLNPAIR(" after: ", current_position[Z_AXIS]);
|
479
|
|
- #endif
|
480
|
|
- }
|
481
|
|
-
|
482
|
|
- #endif // HAS_MESH && PLANNER_LEVELING
|
483
|
|
-
|
484
|
|
- #endif // !HAS_ABL
|
|
408
|
+ const float xdiff = hotend_offset[X_AXIS][tmp_extruder] - hotend_offset[X_AXIS][active_extruder],
|
|
409
|
+ ydiff = hotend_offset[Y_AXIS][tmp_extruder] - hotend_offset[Y_AXIS][active_extruder];
|
485
|
410
|
|
486
|
411
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
487
|
412
|
if (DEBUGGING(LEVELING)) {
|
488
|
|
- SERIAL_ECHOPAIR("Offset Tool XY by { ", xydiff[X_AXIS]);
|
489
|
|
- SERIAL_ECHOPAIR(", ", xydiff[Y_AXIS]);
|
|
413
|
+ SERIAL_ECHOPAIR("Offset Tool XY by { ", xdiff);
|
|
414
|
+ SERIAL_ECHOPAIR(", ", ydiff);
|
490
|
415
|
SERIAL_ECHOLNPGM(" }");
|
491
|
416
|
}
|
492
|
417
|
#endif
|
493
|
418
|
|
494
|
419
|
// The newly-selected extruder XY is actually at...
|
495
|
|
- current_position[X_AXIS] += xydiff[X_AXIS];
|
496
|
|
- current_position[Y_AXIS] += xydiff[Y_AXIS];
|
|
420
|
+ current_position[X_AXIS] += xdiff;
|
|
421
|
+ current_position[Y_AXIS] += ydiff;
|
497
|
422
|
|
498
|
423
|
// Set the new active extruder
|
499
|
424
|
active_extruder = tmp_extruder;
|
500
|
425
|
|
501
|
426
|
#endif // !DUAL_X_CARRIAGE
|
502
|
427
|
|
503
|
|
- #if ENABLED(DEBUG_LEVELING_FEATURE)
|
504
|
|
- if (DEBUGGING(LEVELING)) DEBUG_POS("Sync After Toolchange", current_position);
|
|
428
|
+ #if HAS_LEVELING
|
|
429
|
+ // Restore leveling to re-establish the logical position
|
|
430
|
+ set_bed_leveling_enabled(leveling_was_active);
|
505
|
431
|
#endif
|
506
|
432
|
|
507
|
433
|
// Tell the planner the new "current position"
|
|
@@ -509,17 +435,11 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
509
|
435
|
|
510
|
436
|
#if ENABLED(DELTA)
|
511
|
437
|
//LOOP_XYZ(i) update_software_endstops(i); // or modify the constrain function
|
512
|
|
- // Do a small lift to avoid the workpiece in the move back (below)
|
513
|
438
|
const bool safe_to_move = current_position[Z_AXIS] < delta_clip_start_height - 1;
|
514
|
|
- if (safe_to_move && !no_move && IsRunning()) {
|
515
|
|
- ++current_position[Z_AXIS];
|
516
|
|
- planner.buffer_line_kinematic(current_position, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
|
517
|
|
- }
|
518
|
439
|
#else
|
519
|
440
|
constexpr bool safe_to_move = true;
|
520
|
441
|
#endif
|
521
|
442
|
|
522
|
|
- // Move to the "old position" (move the extruder into place)
|
523
|
443
|
#if ENABLED(SWITCHING_NOZZLE)
|
524
|
444
|
destination[Z_AXIS] += z_diff; // Include the Z restore with the "move back"
|
525
|
445
|
#endif
|
|
@@ -544,7 +464,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
544
|
464
|
#if ENABLED(EXT_SOLENOID) && !ENABLED(PARKING_EXTRUDER)
|
545
|
465
|
disable_all_solenoids();
|
546
|
466
|
enable_solenoid_on_active_extruder();
|
547
|
|
- #endif // EXT_SOLENOID
|
|
467
|
+ #endif
|
548
|
468
|
|
549
|
469
|
feedrate_mm_s = old_feedrate_mm_s;
|
550
|
470
|
|
|
@@ -565,7 +485,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
|
565
|
485
|
|
566
|
486
|
#endif // HOTENDS <= 1
|
567
|
487
|
|
568
|
|
- #if ENABLED(SWITCHING_EXTRUDER) && !DONT_SWITCH
|
|
488
|
+ #if DO_SWITCH_EXTRUDER
|
569
|
489
|
stepper.synchronize();
|
570
|
490
|
move_extruder_servo(active_extruder);
|
571
|
491
|
#endif
|