Browse Source

[ToolChanger] Lock the current tool at power-up (#17093)

MangaValk 4 years ago
parent
commit
57f488738b
No account linked to committer's email address
3 changed files with 18 additions and 5 deletions
  1. 5
    1
      Marlin/src/MarlinCore.cpp
  2. 9
    4
      Marlin/src/module/tool_change.cpp
  3. 4
    0
      Marlin/src/module/tool_change.h

+ 5
- 1
Marlin/src/MarlinCore.cpp View File

@@ -165,7 +165,7 @@
165 165
   #include "feature/fanmux.h"
166 166
 #endif
167 167
 
168
-#if DO_SWITCH_EXTRUDER || ANY(SWITCHING_NOZZLE, PARKING_EXTRUDER, MAGNETIC_PARKING_EXTRUDER, ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
168
+#if DO_SWITCH_EXTRUDER || ANY(SWITCHING_NOZZLE, PARKING_EXTRUDER, MAGNETIC_PARKING_EXTRUDER, ELECTROMAGNETIC_SWITCHING_TOOLHEAD, SWITCHING_TOOLHEAD)
169 169
   #include "module/tool_change.h"
170 170
 #endif
171 171
 
@@ -1110,6 +1110,10 @@ void setup() {
1110 1110
     pe_solenoid_init();
1111 1111
   #endif
1112 1112
 
1113
+  #if ENABLED(SWITCHING_TOOLHEAD)
1114
+    swt_init();
1115
+  #endif
1116
+
1113 1117
   #if ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
1114 1118
     est_init();
1115 1119
   #endif

+ 9
- 4
Marlin/src/module/tool_change.cpp View File

@@ -368,11 +368,16 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a
368 368
 
369 369
 #if ENABLED(SWITCHING_TOOLHEAD)
370 370
 
371
+  inline void swt_lock(const bool locked=true) {
372
+    const uint16_t swt_angles[2] = SWITCHING_TOOLHEAD_SERVO_ANGLES;
373
+    MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, swt_angles[locked ? 0 : 1]);
374
+  }
375
+
376
+  void swt_init() { swt_lock(); }
377
+
371 378
   inline void switching_toolhead_tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
372 379
     if (no_move) return;
373 380
 
374
-    constexpr uint16_t angles[2] = SWITCHING_TOOLHEAD_SERVO_ANGLES;
375
-
376 381
     constexpr float toolheadposx[] = SWITCHING_TOOLHEAD_X_POS;
377 382
     const float placexpos = toolheadposx[active_extruder],
378 383
                 grabxpos = toolheadposx[new_tool];
@@ -406,7 +411,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a
406 411
 
407 412
     planner.synchronize();
408 413
     if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(2) Unlock and Place Toolhead");
409
-    MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[1]);
414
+    swt_lock(false);
410 415
     safe_delay(500);
411 416
 
412 417
     current_position.y = SWITCHING_TOOLHEAD_Y_POS;
@@ -451,7 +456,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a
451 456
     // Wait for move to finish, pause 0.2s, move servo, pause 0.5s
452 457
     planner.synchronize();
453 458
     safe_delay(200);
454
-    MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[0]);
459
+    swt_lock();
455 460
     safe_delay(500);
456 461
 
457 462
     current_position.y -= SWITCHING_TOOLHEAD_Y_CLEAR;

+ 4
- 0
Marlin/src/module/tool_change.h View File

@@ -97,6 +97,10 @@
97 97
   void est_init();
98 98
 #endif
99 99
 
100
+#if ENABLED(SWITCHING_TOOLHEAD)
101
+  void swt_init();
102
+#endif
103
+
100 104
 /**
101 105
  * Perform a tool-change, which may result in moving the
102 106
  * previous tool out of the way and the new tool into place.

Loading…
Cancel
Save