My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tool_change.cpp 36KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../inc/MarlinConfigPre.h"
  23. #include "tool_change.h"
  24. #include "probe.h"
  25. #include "motion.h"
  26. #include "planner.h"
  27. #include "temperature.h"
  28. #include "../MarlinCore.h"
  29. #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
  30. #include "../core/debug_out.h"
  31. #if EXTRUDERS > 1
  32. toolchange_settings_t toolchange_settings; // Initialized by settings.load()
  33. #endif
  34. #if ENABLED(SINGLENOZZLE)
  35. uint16_t singlenozzle_temp[EXTRUDERS];
  36. #if FAN_COUNT > 0
  37. uint8_t singlenozzle_fan_speed[EXTRUDERS];
  38. #endif
  39. #endif
  40. #if ENABLED(MAGNETIC_PARKING_EXTRUDER) || defined(EVENT_GCODE_AFTER_TOOLCHANGE) || (ENABLED(PARKING_EXTRUDER) && PARKING_EXTRUDER_SOLENOIDS_DELAY > 0)
  41. #include "../gcode/gcode.h"
  42. #endif
  43. #if ANY(SWITCHING_EXTRUDER, SWITCHING_NOZZLE, SWITCHING_TOOLHEAD)
  44. #include "servo.h"
  45. #endif
  46. #if ENABLED(EXT_SOLENOID) && DISABLED(PARKING_EXTRUDER)
  47. #include "../feature/solenoid.h"
  48. #endif
  49. #if ENABLED(MK2_MULTIPLEXER)
  50. #include "../feature/snmm.h"
  51. #endif
  52. #if ENABLED(MIXING_EXTRUDER)
  53. #include "../feature/mixing.h"
  54. #endif
  55. #if HAS_LEVELING
  56. #include "../feature/bedlevel/bedlevel.h"
  57. #endif
  58. #if HAS_FANMUX
  59. #include "../feature/fanmux.h"
  60. #endif
  61. #if ENABLED(PRUSA_MMU2)
  62. #include "../feature/mmu2/mmu2.h"
  63. #endif
  64. #if HAS_LCD_MENU
  65. #include "../lcd/ultralcd.h"
  66. #endif
  67. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  68. #include "../feature/pause.h"
  69. #endif
  70. #if DO_SWITCH_EXTRUDER
  71. #if EXTRUDERS > 3
  72. #define _SERVO_NR(E) ((E) < 2 ? SWITCHING_EXTRUDER_SERVO_NR : SWITCHING_EXTRUDER_E23_SERVO_NR)
  73. #else
  74. #define _SERVO_NR(E) SWITCHING_EXTRUDER_SERVO_NR
  75. #endif
  76. void move_extruder_servo(const uint8_t e) {
  77. planner.synchronize();
  78. #if EXTRUDERS & 1
  79. if (e < EXTRUDERS - 1)
  80. #endif
  81. {
  82. MOVE_SERVO(_SERVO_NR(e), servo_angles[_SERVO_NR(e)][e]);
  83. safe_delay(500);
  84. }
  85. }
  86. #endif // DO_SWITCH_EXTRUDER
  87. #if ENABLED(SWITCHING_NOZZLE)
  88. #if SWITCHING_NOZZLE_TWO_SERVOS
  89. inline void _move_nozzle_servo(const uint8_t e, const uint8_t angle_index) {
  90. constexpr int8_t sns_index[2] = { SWITCHING_NOZZLE_SERVO_NR, SWITCHING_NOZZLE_E1_SERVO_NR };
  91. constexpr int16_t sns_angles[2] = SWITCHING_NOZZLE_SERVO_ANGLES;
  92. planner.synchronize();
  93. MOVE_SERVO(sns_index[e], sns_angles[angle_index]);
  94. safe_delay(500);
  95. }
  96. void lower_nozzle(const uint8_t e) { _move_nozzle_servo(e, 0); }
  97. void raise_nozzle(const uint8_t e) { _move_nozzle_servo(e, 1); }
  98. #else
  99. void move_nozzle_servo(const uint8_t angle_index) {
  100. planner.synchronize();
  101. MOVE_SERVO(SWITCHING_NOZZLE_SERVO_NR, servo_angles[SWITCHING_NOZZLE_SERVO_NR][angle_index]);
  102. safe_delay(500);
  103. }
  104. #endif
  105. #endif // SWITCHING_NOZZLE
  106. inline void _line_to_current(const AxisEnum fr_axis, const float fscale=1) {
  107. line_to_current_position(planner.settings.max_feedrate_mm_s[fr_axis] * fscale);
  108. }
  109. inline void slow_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.5f); }
  110. inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis); }
  111. #if ENABLED(MAGNETIC_PARKING_EXTRUDER)
  112. float parkingposx[2], // M951 R L
  113. parkinggrabdistance, // M951 I
  114. parkingslowspeed, // M951 J
  115. parkinghighspeed, // M951 H
  116. parkingtraveldistance, // M951 D
  117. compensationmultiplier;
  118. inline void magnetic_parking_extruder_tool_change(const uint8_t new_tool) {
  119. const float oldx = current_position.x,
  120. grabpos = mpe_settings.parking_xpos[new_tool] + (new_tool ? mpe_settings.grab_distance : -mpe_settings.grab_distance),
  121. offsetcompensation = (0
  122. #if HAS_HOTEND_OFFSET
  123. + hotend_offset[active_extruder].x * mpe_settings.compensation_factor
  124. #endif
  125. );
  126. if (axis_unhomed_error(_BV(X_AXIS))) return;
  127. /**
  128. * Z Lift and Nozzle Offset shift ar defined in caller method to work equal with any Multi Hotend realization
  129. *
  130. * Steps:
  131. * 1. Move high speed to park position of new extruder
  132. * 2. Move to couple position of new extruder (this also discouple the old extruder)
  133. * 3. Move to park position of new extruder
  134. * 4. Move high speed to approach park position of old extruder
  135. * 5. Move to park position of old extruder
  136. * 6. Move to starting position
  137. */
  138. // STEP 1
  139. current_position.x = mpe_settings.parking_xpos[new_tool] + offsetcompensation;
  140. if (DEBUGGING(LEVELING)) {
  141. DEBUG_ECHOPAIR("(1) Move extruder ", int(new_tool));
  142. DEBUG_POS(" to new extruder ParkPos", current_position);
  143. }
  144. planner.buffer_line(current_position, mpe_settings.fast_feedrate, new_tool);
  145. planner.synchronize();
  146. // STEP 2
  147. current_position.x = grabpos + offsetcompensation;
  148. if (DEBUGGING(LEVELING)) {
  149. DEBUG_ECHOPAIR("(2) Couple extruder ", int(new_tool));
  150. DEBUG_POS(" to new extruder GrabPos", current_position);
  151. }
  152. planner.buffer_line(current_position, mpe_settings.slow_feedrate, new_tool);
  153. planner.synchronize();
  154. // Delay before moving tool, to allow magnetic coupling
  155. gcode.dwell(150);
  156. // STEP 3
  157. current_position.x = mpe_settings.parking_xpos[new_tool] + offsetcompensation;
  158. if (DEBUGGING(LEVELING)) {
  159. DEBUG_ECHOPAIR("(3) Move extruder ", int(new_tool));
  160. DEBUG_POS(" back to new extruder ParkPos", current_position);
  161. }
  162. planner.buffer_line(current_position, mpe_settings.slow_feedrate, new_tool);
  163. planner.synchronize();
  164. // STEP 4
  165. current_position.x = mpe_settings.parking_xpos[active_extruder] + (active_extruder == 0 ? MPE_TRAVEL_DISTANCE : -MPE_TRAVEL_DISTANCE) + offsetcompensation;
  166. if (DEBUGGING(LEVELING)) {
  167. DEBUG_ECHOPAIR("(4) Move extruder ", int(new_tool));
  168. DEBUG_POS(" close to old extruder ParkPos", current_position);
  169. }
  170. planner.buffer_line(current_position, mpe_settings.fast_feedrate, new_tool);
  171. planner.synchronize();
  172. // STEP 5
  173. current_position.x = mpe_settings.parking_xpos[active_extruder] + offsetcompensation;
  174. if (DEBUGGING(LEVELING)) {
  175. DEBUG_ECHOPAIR("(5) Park extruder ", int(new_tool));
  176. DEBUG_POS(" at old extruder ParkPos", current_position);
  177. }
  178. planner.buffer_line(current_position, mpe_settings.slow_feedrate, new_tool);
  179. planner.synchronize();
  180. // STEP 6
  181. current_position.x = oldx;
  182. if (DEBUGGING(LEVELING)) {
  183. DEBUG_ECHOPAIR("(6) Move extruder ", int(new_tool));
  184. DEBUG_POS(" to starting position", current_position);
  185. }
  186. planner.buffer_line(current_position, mpe_settings.fast_feedrate, new_tool);
  187. planner.synchronize();
  188. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Autopark done.");
  189. }
  190. #elif ENABLED(PARKING_EXTRUDER)
  191. void pe_solenoid_init() {
  192. LOOP_LE_N(n, 1)
  193. #if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
  194. pe_activate_solenoid(n);
  195. #else
  196. pe_deactivate_solenoid(n);
  197. #endif
  198. }
  199. void pe_set_solenoid(const uint8_t extruder_num, const uint8_t state) {
  200. switch (extruder_num) {
  201. case 1: OUT_WRITE(SOL1_PIN, state); break;
  202. default: OUT_WRITE(SOL0_PIN, state); break;
  203. }
  204. #if PARKING_EXTRUDER_SOLENOIDS_DELAY > 0
  205. gcode.dwell(PARKING_EXTRUDER_SOLENOIDS_DELAY);
  206. #endif
  207. }
  208. inline void parking_extruder_tool_change(const uint8_t new_tool, bool no_move) {
  209. if (!no_move) {
  210. constexpr float parkingposx[] = PARKING_EXTRUDER_PARKING_X;
  211. #if HAS_HOTEND_OFFSET
  212. const float x_offset = hotend_offset[active_extruder].x;
  213. #else
  214. constexpr float x_offset = 0;
  215. #endif
  216. const float midpos = (parkingposx[0] + parkingposx[1]) * 0.5f + x_offset,
  217. grabpos = parkingposx[new_tool] + (new_tool ? PARKING_EXTRUDER_GRAB_DISTANCE : -(PARKING_EXTRUDER_GRAB_DISTANCE)) + x_offset;
  218. /**
  219. * 1. Move to park position of old extruder
  220. * 2. Disengage magnetic field, wait for delay
  221. * 3. Move near new extruder
  222. * 4. Engage magnetic field for new extruder
  223. * 5. Move to parking incl. offset of new extruder
  224. * 6. Lower Z-Axis
  225. */
  226. // STEP 1
  227. if (DEBUGGING(LEVELING)) DEBUG_POS("Start PE Tool-Change", current_position);
  228. current_position.x = parkingposx[active_extruder] + x_offset;
  229. if (DEBUGGING(LEVELING)) {
  230. DEBUG_ECHOLNPAIR("(1) Park extruder ", int(active_extruder));
  231. DEBUG_POS("Moving ParkPos", current_position);
  232. }
  233. fast_line_to_current(X_AXIS);
  234. // STEP 2
  235. planner.synchronize();
  236. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(2) Disengage magnet");
  237. pe_deactivate_solenoid(active_extruder);
  238. // STEP 3
  239. current_position.x += active_extruder ? -10 : 10; // move 10mm away from parked extruder
  240. if (DEBUGGING(LEVELING)) {
  241. DEBUG_ECHOLNPGM("(3) Move near new extruder");
  242. DEBUG_POS("Move away from parked extruder", current_position);
  243. }
  244. fast_line_to_current(X_AXIS);
  245. // STEP 4
  246. planner.synchronize();
  247. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Engage magnetic field");
  248. #if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
  249. pe_activate_solenoid(active_extruder); // Just save power for inverted magnets
  250. #endif
  251. pe_activate_solenoid(new_tool);
  252. // STEP 5
  253. current_position.x = grabpos + (new_tool ? -10 : 10);
  254. fast_line_to_current(X_AXIS);
  255. current_position.x = grabpos;
  256. if (DEBUGGING(LEVELING)) {
  257. planner.synchronize();
  258. DEBUG_POS("(5) Unpark extruder", current_position);
  259. }
  260. slow_line_to_current(X_AXIS);
  261. // STEP 6
  262. current_position.x = midpos
  263. #if HAS_HOTEND_OFFSET
  264. - hotend_offset[new_tool].x
  265. #endif
  266. ;
  267. if (DEBUGGING(LEVELING)) {
  268. planner.synchronize();
  269. DEBUG_POS("(6) Move midway between hotends", current_position);
  270. }
  271. fast_line_to_current(X_AXIS);
  272. planner.synchronize(); // Always sync the final move
  273. if (DEBUGGING(LEVELING)) DEBUG_POS("PE Tool-Change done.", current_position);
  274. }
  275. else { // nomove == true
  276. // Only engage magnetic field for new extruder
  277. pe_activate_solenoid(new_tool);
  278. #if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
  279. pe_activate_solenoid(active_extruder); // Just save power for inverted magnets
  280. #endif
  281. }
  282. }
  283. #endif // PARKING_EXTRUDER
  284. #if ENABLED(SWITCHING_TOOLHEAD)
  285. inline void swt_lock(const bool locked=true) {
  286. const uint16_t swt_angles[2] = SWITCHING_TOOLHEAD_SERVO_ANGLES;
  287. MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, swt_angles[locked ? 0 : 1]);
  288. }
  289. void swt_init() { swt_lock(); }
  290. inline void switching_toolhead_tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
  291. if (no_move) return;
  292. constexpr float toolheadposx[] = SWITCHING_TOOLHEAD_X_POS;
  293. const float placexpos = toolheadposx[active_extruder],
  294. grabxpos = toolheadposx[new_tool];
  295. /**
  296. * 1. Move to switch position of current toolhead
  297. * 2. Unlock tool and drop it in the dock
  298. * 3. Move to the new toolhead
  299. * 4. Grab and lock the new toolhead
  300. */
  301. // 1. Move to switch position of current toolhead
  302. if (DEBUGGING(LEVELING)) DEBUG_POS("Start ST Tool-Change", current_position);
  303. current_position.x = placexpos;
  304. if (DEBUGGING(LEVELING)) {
  305. DEBUG_ECHOLNPAIR("(1) Place old tool ", int(active_extruder));
  306. DEBUG_POS("Move X SwitchPos", current_position);
  307. }
  308. fast_line_to_current(X_AXIS);
  309. current_position.y = SWITCHING_TOOLHEAD_Y_POS - (SWITCHING_TOOLHEAD_Y_SECURITY);
  310. if (DEBUGGING(LEVELING)) {
  311. planner.synchronize();
  312. DEBUG_POS("Move Y SwitchPos + Security", current_position);
  313. }
  314. fast_line_to_current(Y_AXIS);
  315. // 2. Unlock tool and drop it in the dock
  316. planner.synchronize();
  317. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(2) Unlock and Place Toolhead");
  318. swt_lock(false);
  319. safe_delay(500);
  320. current_position.y = SWITCHING_TOOLHEAD_Y_POS;
  321. if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
  322. slow_line_to_current(Y_AXIS);
  323. // Wait for move to complete, then another 0.2s
  324. planner.synchronize();
  325. safe_delay(200);
  326. current_position.y -= SWITCHING_TOOLHEAD_Y_CLEAR;
  327. if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
  328. fast_line_to_current(Y_AXIS); // move away from docked toolhead
  329. // 3. Move to the new toolhead
  330. current_position.x = grabxpos;
  331. if (DEBUGGING(LEVELING)) {
  332. planner.synchronize();
  333. DEBUG_ECHOLNPGM("(3) Move to new toolhead position");
  334. DEBUG_POS("Move to new toolhead X", current_position);
  335. }
  336. fast_line_to_current(X_AXIS);
  337. current_position.y = SWITCHING_TOOLHEAD_Y_POS - (SWITCHING_TOOLHEAD_Y_SECURITY);
  338. if (DEBUGGING(LEVELING)) {
  339. planner.synchronize();
  340. DEBUG_POS("Move Y SwitchPos + Security", current_position);
  341. }
  342. fast_line_to_current(Y_AXIS);
  343. // 4. Grab and lock the new toolhead
  344. current_position.y = SWITCHING_TOOLHEAD_Y_POS;
  345. if (DEBUGGING(LEVELING)) {
  346. planner.synchronize();
  347. DEBUG_ECHOLNPGM("(4) Grab and lock new toolhead");
  348. DEBUG_POS("Move Y SwitchPos", current_position);
  349. }
  350. slow_line_to_current(Y_AXIS);
  351. // Wait for move to finish, pause 0.2s, move servo, pause 0.5s
  352. planner.synchronize();
  353. safe_delay(200);
  354. swt_lock();
  355. safe_delay(500);
  356. current_position.y -= SWITCHING_TOOLHEAD_Y_CLEAR;
  357. if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
  358. fast_line_to_current(Y_AXIS); // Move away from docked toolhead
  359. planner.synchronize(); // Always sync the final move
  360. if (DEBUGGING(LEVELING)) DEBUG_POS("ST Tool-Change done.", current_position);
  361. }
  362. #elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
  363. inline void magnetic_switching_toolhead_tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
  364. if (no_move) return;
  365. constexpr float toolheadposx[] = SWITCHING_TOOLHEAD_X_POS,
  366. toolheadclearx[] = SWITCHING_TOOLHEAD_X_SECURITY;
  367. const float placexpos = toolheadposx[active_extruder],
  368. placexclear = toolheadclearx[active_extruder],
  369. grabxpos = toolheadposx[new_tool],
  370. grabxclear = toolheadclearx[new_tool];
  371. /**
  372. * 1. Move to switch position of current toolhead
  373. * 2. Release and place toolhead in the dock
  374. * 3. Move to the new toolhead
  375. * 4. Grab the new toolhead and move to security position
  376. */
  377. if (DEBUGGING(LEVELING)) DEBUG_POS("Start MST Tool-Change", current_position);
  378. // 1. Move to switch position current toolhead
  379. current_position.y = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR;
  380. if (DEBUGGING(LEVELING)) {
  381. SERIAL_ECHOLNPAIR("(1) Place old tool ", int(active_extruder));
  382. DEBUG_POS("Move Y SwitchPos + Security", current_position);
  383. }
  384. fast_line_to_current(Y_AXIS);
  385. current_position.x = placexclear;
  386. if (DEBUGGING(LEVELING)) {
  387. planner.synchronize();
  388. DEBUG_POS("Move X SwitchPos + Security", current_position);
  389. }
  390. fast_line_to_current(X_AXIS);
  391. current_position.y = SWITCHING_TOOLHEAD_Y_POS;
  392. if (DEBUGGING(LEVELING)) {
  393. planner.synchronize();
  394. DEBUG_POS("Move Y SwitchPos", current_position);
  395. }
  396. fast_line_to_current(Y_AXIS);
  397. current_position.x = placexpos;
  398. if (DEBUGGING(LEVELING)) {
  399. planner.synchronize();
  400. DEBUG_POS("Move X SwitchPos", current_position);
  401. }
  402. line_to_current_position(planner.settings.max_feedrate_mm_s[X_AXIS] * 0.25f);
  403. // 2. Release and place toolhead in the dock
  404. if (DEBUGGING(LEVELING)) {
  405. planner.synchronize();
  406. DEBUG_ECHOLNPGM("(2) Release and Place Toolhead");
  407. }
  408. current_position.y = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_RELEASE;
  409. if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Release", current_position);
  410. line_to_current_position(planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.1f);
  411. current_position.y = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_SECURITY;
  412. if (DEBUGGING(LEVELING)) {
  413. planner.synchronize();
  414. DEBUG_POS("Move Y SwitchPos + Security", current_position);
  415. }
  416. line_to_current_position(planner.settings.max_feedrate_mm_s[Y_AXIS]);
  417. // 3. Move to new toolhead position
  418. if (DEBUGGING(LEVELING)) {
  419. planner.synchronize();
  420. DEBUG_ECHOLNPGM("(3) Move to new toolhead position");
  421. }
  422. current_position.x = grabxpos;
  423. if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position);
  424. fast_line_to_current(X_AXIS);
  425. // 4. Grab the new toolhead and move to security position
  426. if (DEBUGGING(LEVELING)) {
  427. planner.synchronize();
  428. DEBUG_ECHOLNPGM("(4) Grab new toolhead, move to security position");
  429. }
  430. current_position.y = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_RELEASE;
  431. if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Release", current_position);
  432. line_to_current_position(planner.settings.max_feedrate_mm_s[Y_AXIS]);
  433. current_position.y = SWITCHING_TOOLHEAD_Y_POS;
  434. if (DEBUGGING(LEVELING)) {
  435. planner.synchronize();
  436. DEBUG_POS("Move Y SwitchPos", current_position);
  437. }
  438. _line_to_current(Y_AXIS, 0.2f);
  439. #if ENABLED(PRIME_BEFORE_REMOVE) && (SWITCHING_TOOLHEAD_PRIME_MM || SWITCHING_TOOLHEAD_RETRACT_MM)
  440. #if SWITCHING_TOOLHEAD_PRIME_MM
  441. current_position.e += SWITCHING_TOOLHEAD_PRIME_MM;
  442. planner.buffer_line(current_position, MMM_TO_MMS(SWITCHING_TOOLHEAD_PRIME_FEEDRATE), new_tool);
  443. #endif
  444. #if SWITCHING_TOOLHEAD_RETRACT_MM
  445. current_position.e -= SWITCHING_TOOLHEAD_RETRACT_MM;
  446. planner.buffer_line(current_position, MMM_TO_MMS(SWITCHING_TOOLHEAD_RETRACT_FEEDRATE), new_tool);
  447. #endif
  448. #else
  449. planner.synchronize();
  450. safe_delay(100); // Give switch time to settle
  451. #endif
  452. current_position.x = grabxclear;
  453. if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X + Security", current_position);
  454. _line_to_current(X_AXIS, 0.1f);
  455. planner.synchronize();
  456. safe_delay(100); // Give switch time to settle
  457. current_position.y += SWITCHING_TOOLHEAD_Y_CLEAR;
  458. if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
  459. fast_line_to_current(Y_AXIS); // move away from docked toolhead
  460. planner.synchronize(); // Always sync last tool-change move
  461. if (DEBUGGING(LEVELING)) DEBUG_POS("MST Tool-Change done.", current_position);
  462. }
  463. #elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
  464. inline void est_activate_solenoid() { OUT_WRITE(SOL0_PIN, HIGH); }
  465. inline void est_deactivate_solenoid() { OUT_WRITE(SOL0_PIN, LOW); }
  466. void est_init() { est_activate_solenoid(); }
  467. inline void em_switching_toolhead_tool_change(const uint8_t new_tool, bool no_move) {
  468. if (no_move) return;
  469. constexpr float toolheadposx[] = SWITCHING_TOOLHEAD_X_POS;
  470. const float placexpos = toolheadposx[active_extruder],
  471. grabxpos = toolheadposx[new_tool];
  472. const xyz_pos_t &hoffs = hotend_offset[active_extruder];
  473. /**
  474. * 1. Raise Z-Axis to give enough clearance
  475. * 2. Move to position near active extruder parking
  476. * 3. Move gently to park position of active extruder
  477. * 4. Disengage magnetic field, wait for delay
  478. * 5. Leave extruder and move to position near new extruder parking
  479. * 6. Move gently to park position of new extruder
  480. * 7. Engage magnetic field for new extruder parking
  481. * 8. Unpark extruder
  482. * 9. Apply Z hotend offset to current position
  483. */
  484. if (DEBUGGING(LEVELING)) DEBUG_POS("Start EMST Tool-Change", current_position);
  485. // 1. Raise Z-Axis to give enough clearance
  486. current_position.z += SWITCHING_TOOLHEAD_Z_HOP;
  487. if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis ", current_position);
  488. fast_line_to_current(Z_AXIS);
  489. // 2. Move to position near active extruder parking
  490. if (DEBUGGING(LEVELING)) {
  491. planner.synchronize();
  492. SERIAL_ECHOLNPAIR("(2) Move near active extruder parking", active_extruder);
  493. DEBUG_POS("Moving ParkPos", current_position);
  494. }
  495. current_position.set(hoffs.x + placexpos,
  496. hoffs.y + SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR);
  497. fast_line_to_current(X_AXIS);
  498. // 3. Move gently to park position of active extruder
  499. if (DEBUGGING(LEVELING)) {
  500. planner.synchronize();
  501. SERIAL_ECHOLNPAIR("(3) Move gently to park position of active extruder", active_extruder);
  502. DEBUG_POS("Moving ParkPos", current_position);
  503. }
  504. current_position.y -= SWITCHING_TOOLHEAD_Y_CLEAR;
  505. slow_line_to_current(Y_AXIS);
  506. // 4. Disengage magnetic field, wait for delay
  507. planner.synchronize();
  508. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Disengage magnet");
  509. est_deactivate_solenoid();
  510. // 5. Leave extruder and move to position near new extruder parking
  511. if (DEBUGGING(LEVELING)) {
  512. DEBUG_ECHOLNPGM("(5) Move near new extruder parking");
  513. DEBUG_POS("Moving ParkPos", current_position);
  514. }
  515. current_position.y += SWITCHING_TOOLHEAD_Y_CLEAR;
  516. slow_line_to_current(Y_AXIS);
  517. current_position.set(hoffs.x + grabxpos,
  518. hoffs.y + SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR);
  519. fast_line_to_current(X_AXIS);
  520. // 6. Move gently to park position of new extruder
  521. current_position.y -= SWITCHING_TOOLHEAD_Y_CLEAR;
  522. if (DEBUGGING(LEVELING)) {
  523. planner.synchronize();
  524. DEBUG_ECHOLNPGM("(6) Move near new extruder");
  525. }
  526. slow_line_to_current(Y_AXIS);
  527. // 7. Engage magnetic field for new extruder parking
  528. planner.synchronize();
  529. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(7) Engage magnetic field");
  530. est_activate_solenoid();
  531. // 8. Unpark extruder
  532. current_position.y += SWITCHING_TOOLHEAD_Y_CLEAR;
  533. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(8) Unpark extruder");
  534. slow_line_to_current(X_AXIS);
  535. planner.synchronize(); // Always sync the final move
  536. // 9. Apply Z hotend offset to current position
  537. if (DEBUGGING(LEVELING)) DEBUG_POS("(9) Applying Z-offset", current_position);
  538. current_position.z += hoffs.z - hotend_offset[new_tool].z;
  539. if (DEBUGGING(LEVELING)) DEBUG_POS("EMST Tool-Change done.", current_position);
  540. }
  541. #endif // ELECTROMAGNETIC_SWITCHING_TOOLHEAD
  542. #if EXTRUDERS
  543. inline void invalid_extruder_error(const uint8_t e) {
  544. SERIAL_ECHO_START();
  545. SERIAL_CHAR('T'); SERIAL_ECHO(int(e));
  546. SERIAL_CHAR(' '); SERIAL_ECHOLNPGM(STR_INVALID_EXTRUDER);
  547. }
  548. #endif
  549. #if ENABLED(DUAL_X_CARRIAGE)
  550. inline void dualx_tool_change(const uint8_t new_tool, bool &no_move) {
  551. if (DEBUGGING(LEVELING)) {
  552. DEBUG_ECHOPGM("Dual X Carriage Mode ");
  553. switch (dual_x_carriage_mode) {
  554. case DXC_FULL_CONTROL_MODE: DEBUG_ECHOLNPGM("FULL_CONTROL"); break;
  555. case DXC_AUTO_PARK_MODE: DEBUG_ECHOLNPGM("AUTO_PARK"); break;
  556. case DXC_DUPLICATION_MODE: DEBUG_ECHOLNPGM("DUPLICATION"); break;
  557. case DXC_MIRRORED_MODE: DEBUG_ECHOLNPGM("MIRRORED"); break;
  558. }
  559. }
  560. const float xhome = x_home_pos(active_extruder);
  561. if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE
  562. && IsRunning() && !no_move
  563. && (delayed_move_time || current_position.x != xhome)
  564. ) {
  565. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("MoveX to ", xhome);
  566. // Park old head
  567. current_position.x = xhome;
  568. line_to_current_position(planner.settings.max_feedrate_mm_s[X_AXIS]);
  569. planner.synchronize();
  570. }
  571. // Activate the new extruder ahead of calling set_axis_is_at_home!
  572. active_extruder = new_tool;
  573. // This function resets the max/min values - the current position may be overwritten below.
  574. set_axis_is_at_home(X_AXIS);
  575. if (DEBUGGING(LEVELING)) DEBUG_POS("New Extruder", current_position);
  576. switch (dual_x_carriage_mode) {
  577. case DXC_FULL_CONTROL_MODE:
  578. // New current position is the position of the activated extruder
  579. current_position.x = inactive_extruder_x_pos;
  580. // Save the inactive extruder's position (from the old current_position)
  581. inactive_extruder_x_pos = destination.x;
  582. break;
  583. case DXC_AUTO_PARK_MODE:
  584. // record current raised toolhead position for use by unpark
  585. raised_parked_position = current_position;
  586. active_extruder_parked = true;
  587. delayed_move_time = 0;
  588. break;
  589. default:
  590. break;
  591. }
  592. if (DEBUGGING(LEVELING)) {
  593. DEBUG_ECHOLNPAIR("Active extruder parked: ", active_extruder_parked ? "yes" : "no");
  594. DEBUG_POS("New extruder (parked)", current_position);
  595. }
  596. }
  597. #endif // DUAL_X_CARRIAGE
  598. /**
  599. * Perform a tool-change, which may result in moving the
  600. * previous tool out of the way and the new tool into place.
  601. */
  602. void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
  603. #if ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
  604. if (new_tool == active_extruder) return;
  605. #endif
  606. #if ENABLED(MIXING_EXTRUDER)
  607. UNUSED(no_move);
  608. if (new_tool >= MIXING_VIRTUAL_TOOLS)
  609. return invalid_extruder_error(new_tool);
  610. #if MIXING_VIRTUAL_TOOLS > 1
  611. // T0-Tnnn: Switch virtual tool by changing the index to the mix
  612. mixer.T(new_tool);
  613. #endif
  614. #elif ENABLED(PRUSA_MMU2)
  615. UNUSED(no_move);
  616. mmu2.tool_change(new_tool);
  617. #elif EXTRUDERS == 0
  618. // Nothing to do
  619. UNUSED(new_tool); UNUSED(no_move);
  620. #elif EXTRUDERS < 2
  621. UNUSED(no_move);
  622. if (new_tool) invalid_extruder_error(new_tool);
  623. return;
  624. #else // EXTRUDERS > 1
  625. planner.synchronize();
  626. #if ENABLED(DUAL_X_CARRIAGE) // Only T0 allowed if the Printer is in DXC_DUPLICATION_MODE or DXC_MIRRORED_MODE
  627. if (new_tool != 0 && dxc_is_duplicating())
  628. return invalid_extruder_error(new_tool);
  629. #endif
  630. if (new_tool >= EXTRUDERS)
  631. return invalid_extruder_error(new_tool);
  632. if (!no_move && !all_axes_homed()) {
  633. no_move = true;
  634. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("No move (not homed)");
  635. }
  636. #if HAS_LCD_MENU
  637. if (!no_move) ui.return_to_status();
  638. #endif
  639. #if ENABLED(DUAL_X_CARRIAGE)
  640. const bool idex_full_control = dual_x_carriage_mode == DXC_FULL_CONTROL_MODE;
  641. #else
  642. constexpr bool idex_full_control = false;
  643. #endif
  644. const uint8_t old_tool = active_extruder;
  645. const bool can_move_away = !no_move && !idex_full_control;
  646. #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
  647. const bool should_swap = can_move_away && toolchange_settings.swap_length;
  648. #if ENABLED(PREVENT_COLD_EXTRUSION)
  649. const bool too_cold = !DEBUGGING(DRYRUN) && (thermalManager.targetTooColdToExtrude(old_tool) || thermalManager.targetTooColdToExtrude(new_tool));
  650. #else
  651. constexpr bool too_cold = false;
  652. #endif
  653. if (should_swap) {
  654. if (too_cold) {
  655. SERIAL_ECHO_MSG(STR_ERR_HOTEND_TOO_COLD);
  656. #if ENABLED(SINGLENOZZLE)
  657. active_extruder = new_tool;
  658. return;
  659. #endif
  660. }
  661. else {
  662. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  663. do_pause_e_move(-toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.retract_speed));
  664. #else
  665. current_position.e -= toolchange_settings.swap_length / planner.e_factor[old_tool];
  666. planner.buffer_line(current_position, MMM_TO_MMS(toolchange_settings.retract_speed), old_tool);
  667. planner.synchronize();
  668. #endif
  669. }
  670. }
  671. #endif // TOOLCHANGE_FILAMENT_SWAP
  672. #if HAS_LEVELING && DISABLED(SINGLENOZZLE)
  673. // Set current position to the physical position
  674. TEMPORARY_BED_LEVELING_STATE(false);
  675. #endif
  676. if (new_tool != old_tool) {
  677. #if SWITCHING_NOZZLE_TWO_SERVOS
  678. raise_nozzle(old_tool);
  679. #endif
  680. REMEMBER(fr, feedrate_mm_s, XY_PROBE_FEEDRATE_MM_S);
  681. #if HAS_SOFTWARE_ENDSTOPS
  682. #if HAS_HOTEND_OFFSET
  683. #define _EXT_ARGS , old_tool, new_tool
  684. #else
  685. #define _EXT_ARGS
  686. #endif
  687. update_software_endstops(X_AXIS _EXT_ARGS);
  688. #if DISABLED(DUAL_X_CARRIAGE)
  689. update_software_endstops(Y_AXIS _EXT_ARGS);
  690. update_software_endstops(Z_AXIS _EXT_ARGS);
  691. #endif
  692. #endif
  693. destination = current_position;
  694. #if DISABLED(SWITCHING_NOZZLE)
  695. if (can_move_away) {
  696. // Do a small lift to avoid the workpiece in the move back (below)
  697. current_position.z += toolchange_settings.z_raise;
  698. #if HAS_SOFTWARE_ENDSTOPS
  699. NOMORE(current_position.z, soft_endstop.max.z);
  700. #endif
  701. fast_line_to_current(Z_AXIS);
  702. #if ENABLED(TOOLCHANGE_PARK)
  703. current_position = toolchange_settings.change_point;
  704. #endif
  705. planner.buffer_line(current_position, feedrate_mm_s, old_tool);
  706. planner.synchronize();
  707. }
  708. #endif
  709. #if HAS_HOTEND_OFFSET
  710. xyz_pos_t diff = hotend_offset[new_tool] - hotend_offset[old_tool];
  711. #if ENABLED(DUAL_X_CARRIAGE)
  712. diff.x = 0;
  713. #endif
  714. #else
  715. constexpr xyz_pos_t diff{0};
  716. #endif
  717. #if ENABLED(DUAL_X_CARRIAGE)
  718. dualx_tool_change(new_tool, no_move);
  719. #elif ENABLED(PARKING_EXTRUDER) // Dual Parking extruder
  720. parking_extruder_tool_change(new_tool, no_move);
  721. #elif ENABLED(MAGNETIC_PARKING_EXTRUDER) // Magnetic Parking extruder
  722. magnetic_parking_extruder_tool_change(new_tool);
  723. #elif ENABLED(SWITCHING_TOOLHEAD) // Switching Toolhead
  724. switching_toolhead_tool_change(new_tool, no_move);
  725. #elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD) // Magnetic Switching Toolhead
  726. magnetic_switching_toolhead_tool_change(new_tool, no_move);
  727. #elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD) // Magnetic Switching ToolChanger
  728. em_switching_toolhead_tool_change(new_tool, no_move);
  729. #elif ENABLED(SWITCHING_NOZZLE) && !SWITCHING_NOZZLE_TWO_SERVOS // Switching Nozzle (single servo)
  730. // Raise by a configured distance to avoid workpiece, except with
  731. // SWITCHING_NOZZLE_TWO_SERVOS, as both nozzles will lift instead.
  732. if (!no_move) {
  733. #if HAS_SOFTWARE_ENDSTOPS
  734. const float maxz = _MIN(soft_endstop.max.z, Z_MAX_POS);
  735. #else
  736. constexpr float maxz = Z_MAX_POS;
  737. #endif
  738. // Check if Z has space to compensate at least z_offset, and if not, just abort now
  739. const float newz = current_position.z + _MAX(-diff.z, 0.0);
  740. if (newz > maxz) return;
  741. current_position.z = _MIN(newz + toolchange_settings.z_raise, maxz);
  742. fast_line_to_current(Z_AXIS);
  743. }
  744. move_nozzle_servo(new_tool);
  745. #endif
  746. #if DISABLED(DUAL_X_CARRIAGE)
  747. active_extruder = new_tool; // Set the new active extruder
  748. #endif
  749. // The newly-selected extruder XYZ is actually at...
  750. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Offset Tool XYZ by { ", diff.x, ", ", diff.y, ", ", diff.z, " }");
  751. current_position += diff;
  752. // Tell the planner the new "current position"
  753. sync_plan_position();
  754. #if ENABLED(DELTA)
  755. //LOOP_XYZ(i) update_software_endstops(i); // or modify the constrain function
  756. const bool safe_to_move = current_position.z < delta_clip_start_height - 1;
  757. #else
  758. constexpr bool safe_to_move = true;
  759. #endif
  760. // Return to position and lower again
  761. if (safe_to_move && !no_move && IsRunning()) {
  762. #if ENABLED(SINGLENOZZLE)
  763. #if FAN_COUNT > 0
  764. singlenozzle_fan_speed[old_tool] = thermalManager.fan_speed[0];
  765. thermalManager.fan_speed[0] = singlenozzle_fan_speed[new_tool];
  766. #endif
  767. singlenozzle_temp[old_tool] = thermalManager.temp_hotend[0].target;
  768. if (singlenozzle_temp[new_tool] && singlenozzle_temp[new_tool] != singlenozzle_temp[old_tool]) {
  769. thermalManager.setTargetHotend(singlenozzle_temp[new_tool], 0);
  770. #if HAS_DISPLAY
  771. thermalManager.set_heating_message(0);
  772. #endif
  773. (void)thermalManager.wait_for_hotend(0, false); // Wait for heating or cooling
  774. }
  775. #endif
  776. #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
  777. if (should_swap && !too_cold) {
  778. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  779. do_pause_e_move(toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.prime_speed));
  780. do_pause_e_move(toolchange_settings.extra_prime, ADVANCED_PAUSE_PURGE_FEEDRATE);
  781. #else
  782. current_position.e += toolchange_settings.swap_length / planner.e_factor[new_tool];
  783. planner.buffer_line(current_position, MMM_TO_MMS(toolchange_settings.prime_speed), new_tool);
  784. current_position.e += toolchange_settings.extra_prime / planner.e_factor[new_tool];
  785. planner.buffer_line(current_position, MMM_TO_MMS(toolchange_settings.prime_speed * 0.2f), new_tool);
  786. #endif
  787. planner.synchronize();
  788. planner.set_e_position_mm((destination.e = current_position.e = current_position.e - (TOOLCHANGE_FIL_EXTRA_PRIME)));
  789. }
  790. #endif
  791. // Prevent a move outside physical bounds
  792. #if ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
  793. // If the original position is within tool store area, go to X origin at once
  794. if (destination.y < SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR) {
  795. current_position.x = 0;
  796. planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], new_tool);
  797. planner.synchronize();
  798. }
  799. #else
  800. apply_motion_limits(destination);
  801. #endif
  802. // Should the nozzle move back to the old position?
  803. if (can_move_away) {
  804. #if ENABLED(TOOLCHANGE_NO_RETURN)
  805. // Just move back down
  806. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Move back Z only");
  807. do_blocking_move_to_z(destination.z, planner.settings.max_feedrate_mm_s[Z_AXIS]);
  808. #else
  809. // Move back to the original (or adjusted) position
  810. if (DEBUGGING(LEVELING)) DEBUG_POS("Move back", destination);
  811. do_blocking_move_to(destination);
  812. #endif
  813. }
  814. else if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Move back skipped");
  815. #if ENABLED(DUAL_X_CARRIAGE)
  816. active_extruder_parked = false;
  817. #endif
  818. }
  819. #if ENABLED(SWITCHING_NOZZLE)
  820. else {
  821. // Move back down. (Including when the new tool is higher.)
  822. do_blocking_move_to_z(destination.z, planner.settings.max_feedrate_mm_s[Z_AXIS]);
  823. }
  824. #endif
  825. #if ENABLED(PRUSA_MMU2)
  826. mmu2.tool_change(new_tool);
  827. #endif
  828. #if SWITCHING_NOZZLE_TWO_SERVOS
  829. lower_nozzle(new_tool);
  830. #endif
  831. } // (new_tool != old_tool)
  832. planner.synchronize();
  833. #if ENABLED(EXT_SOLENOID) && DISABLED(PARKING_EXTRUDER)
  834. disable_all_solenoids();
  835. enable_solenoid_on_active_extruder();
  836. #endif
  837. #if ENABLED(MK2_MULTIPLEXER)
  838. if (new_tool >= E_STEPPERS) return invalid_extruder_error(new_tool);
  839. select_multiplexed_stepper(new_tool);
  840. #endif
  841. #if DO_SWITCH_EXTRUDER
  842. planner.synchronize();
  843. move_extruder_servo(active_extruder);
  844. #endif
  845. #if HAS_FANMUX
  846. fanmux_switch(active_extruder);
  847. #endif
  848. #ifdef EVENT_GCODE_AFTER_TOOLCHANGE
  849. if (!no_move)
  850. gcode.process_subcommands_now_P(PSTR(EVENT_GCODE_AFTER_TOOLCHANGE));
  851. #endif
  852. SERIAL_ECHO_START();
  853. SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(active_extruder));
  854. #endif // EXTRUDERS > 1
  855. }