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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079
  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/prusa_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. for (uint8_t n = 0; n <= 1; ++n)
  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 switching_toolhead_tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
  286. if (no_move) return;
  287. constexpr uint16_t angles[2] = SWITCHING_TOOLHEAD_SERVO_ANGLES;
  288. constexpr float toolheadposx[] = SWITCHING_TOOLHEAD_X_POS;
  289. const float placexpos = toolheadposx[active_extruder],
  290. grabxpos = toolheadposx[new_tool];
  291. /**
  292. * 1. Move to switch position of current toolhead
  293. * 2. Unlock tool and drop it in the dock
  294. * 3. Move to the new toolhead
  295. * 4. Grab and lock the new toolhead
  296. */
  297. // 1. Move to switch position of current toolhead
  298. if (DEBUGGING(LEVELING)) DEBUG_POS("Start ST Tool-Change", current_position);
  299. current_position.x = placexpos;
  300. if (DEBUGGING(LEVELING)) {
  301. DEBUG_ECHOLNPAIR("(1) Place old tool ", int(active_extruder));
  302. DEBUG_POS("Move X SwitchPos", current_position);
  303. }
  304. fast_line_to_current(X_AXIS);
  305. current_position.y = SWITCHING_TOOLHEAD_Y_POS - (SWITCHING_TOOLHEAD_Y_SECURITY);
  306. if (DEBUGGING(LEVELING)) {
  307. planner.synchronize();
  308. DEBUG_POS("Move Y SwitchPos + Security", current_position);
  309. }
  310. fast_line_to_current(Y_AXIS);
  311. // 2. Unlock tool and drop it in the dock
  312. planner.synchronize();
  313. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(2) Unlock and Place Toolhead");
  314. MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[1]);
  315. safe_delay(500);
  316. current_position.y = SWITCHING_TOOLHEAD_Y_POS;
  317. if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
  318. slow_line_to_current(Y_AXIS);
  319. // Wait for move to complete, then another 0.2s
  320. planner.synchronize();
  321. safe_delay(200);
  322. current_position.y -= SWITCHING_TOOLHEAD_Y_CLEAR;
  323. if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
  324. fast_line_to_current(Y_AXIS); // move away from docked toolhead
  325. // 3. Move to the new toolhead
  326. current_position.x = grabxpos;
  327. if (DEBUGGING(LEVELING)) {
  328. planner.synchronize();
  329. DEBUG_ECHOLNPGM("(3) Move to new toolhead position");
  330. DEBUG_POS("Move to new toolhead X", current_position);
  331. }
  332. fast_line_to_current(X_AXIS);
  333. current_position.y = SWITCHING_TOOLHEAD_Y_POS - (SWITCHING_TOOLHEAD_Y_SECURITY);
  334. if (DEBUGGING(LEVELING)) {
  335. planner.synchronize();
  336. DEBUG_POS("Move Y SwitchPos + Security", current_position);
  337. }
  338. fast_line_to_current(Y_AXIS);
  339. // 4. Grab and lock the new toolhead
  340. current_position.y = SWITCHING_TOOLHEAD_Y_POS;
  341. if (DEBUGGING(LEVELING)) {
  342. planner.synchronize();
  343. DEBUG_ECHOLNPGM("(4) Grab and lock new toolhead");
  344. DEBUG_POS("Move Y SwitchPos", current_position);
  345. }
  346. slow_line_to_current(Y_AXIS);
  347. // Wait for move to finish, pause 0.2s, move servo, pause 0.5s
  348. planner.synchronize();
  349. safe_delay(200);
  350. MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[0]);
  351. safe_delay(500);
  352. current_position.y -= SWITCHING_TOOLHEAD_Y_CLEAR;
  353. if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
  354. fast_line_to_current(Y_AXIS); // Move away from docked toolhead
  355. planner.synchronize(); // Always sync the final move
  356. if (DEBUGGING(LEVELING)) DEBUG_POS("ST Tool-Change done.", current_position);
  357. }
  358. #elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
  359. inline void magnetic_switching_toolhead_tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
  360. if (no_move) return;
  361. constexpr float toolheadposx[] = SWITCHING_TOOLHEAD_X_POS,
  362. toolheadclearx[] = SWITCHING_TOOLHEAD_X_SECURITY;
  363. const float placexpos = toolheadposx[active_extruder],
  364. placexclear = toolheadclearx[active_extruder],
  365. grabxpos = toolheadposx[new_tool],
  366. grabxclear = toolheadclearx[new_tool];
  367. /**
  368. * 1. Move to switch position of current toolhead
  369. * 2. Release and place toolhead in the dock
  370. * 3. Move to the new toolhead
  371. * 4. Grab the new toolhead and move to security position
  372. */
  373. if (DEBUGGING(LEVELING)) DEBUG_POS("Start MST Tool-Change", current_position);
  374. // 1. Move to switch position current toolhead
  375. current_position.y = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR;
  376. if (DEBUGGING(LEVELING)) {
  377. SERIAL_ECHOLNPAIR("(1) Place old tool ", int(active_extruder));
  378. DEBUG_POS("Move Y SwitchPos + Security", current_position);
  379. }
  380. fast_line_to_current(Y_AXIS);
  381. current_position.x = placexclear;
  382. if (DEBUGGING(LEVELING)) {
  383. planner.synchronize();
  384. DEBUG_POS("Move X SwitchPos + Security", current_position);
  385. }
  386. fast_line_to_current(X_AXIS);
  387. current_position.y = SWITCHING_TOOLHEAD_Y_POS;
  388. if (DEBUGGING(LEVELING)) {
  389. planner.synchronize();
  390. DEBUG_POS("Move Y SwitchPos", current_position);
  391. }
  392. fast_line_to_current(Y_AXIS);
  393. current_position.x = placexpos;
  394. if (DEBUGGING(LEVELING)) {
  395. planner.synchronize();
  396. DEBUG_POS("Move X SwitchPos", current_position);
  397. }
  398. line_to_current_position(planner.settings.max_feedrate_mm_s[X_AXIS] * 0.25f);
  399. // 2. Release and place toolhead in the dock
  400. if (DEBUGGING(LEVELING)) {
  401. planner.synchronize();
  402. DEBUG_ECHOLNPGM("(2) Release and Place Toolhead");
  403. }
  404. current_position.y = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_RELEASE;
  405. if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Release", current_position);
  406. line_to_current_position(planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.1f);
  407. current_position.y = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_SECURITY;
  408. if (DEBUGGING(LEVELING)) {
  409. planner.synchronize();
  410. DEBUG_POS("Move Y SwitchPos + Security", current_position);
  411. }
  412. line_to_current_position(planner.settings.max_feedrate_mm_s[Y_AXIS]);
  413. // 3. Move to new toolhead position
  414. if (DEBUGGING(LEVELING)) {
  415. planner.synchronize();
  416. DEBUG_ECHOLNPGM("(3) Move to new toolhead position");
  417. }
  418. current_position.x = grabxpos;
  419. if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position);
  420. fast_line_to_current(X_AXIS);
  421. // 4. Grab the new toolhead and move to security position
  422. if (DEBUGGING(LEVELING)) {
  423. planner.synchronize();
  424. DEBUG_ECHOLNPGM("(4) Grab new toolhead, move to security position");
  425. }
  426. current_position.y = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_RELEASE;
  427. if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Release", current_position);
  428. line_to_current_position(planner.settings.max_feedrate_mm_s[Y_AXIS]);
  429. current_position.y = SWITCHING_TOOLHEAD_Y_POS;
  430. if (DEBUGGING(LEVELING)) {
  431. planner.synchronize();
  432. DEBUG_POS("Move Y SwitchPos", current_position);
  433. }
  434. _line_to_current(Y_AXIS, 0.2f);
  435. #if ENABLED(PRIME_BEFORE_REMOVE) && (SWITCHING_TOOLHEAD_PRIME_MM || SWITCHING_TOOLHEAD_RETRACT_MM)
  436. #if SWITCHING_TOOLHEAD_PRIME_MM
  437. current_position.e += SWITCHING_TOOLHEAD_PRIME_MM;
  438. planner.buffer_line(current_position, MMM_TO_MMS(SWITCHING_TOOLHEAD_PRIME_FEEDRATE), new_tool);
  439. #endif
  440. #if SWITCHING_TOOLHEAD_RETRACT_MM
  441. current_position.e -= SWITCHING_TOOLHEAD_RETRACT_MM;
  442. planner.buffer_line(current_position, MMM_TO_MMS(SWITCHING_TOOLHEAD_RETRACT_FEEDRATE), new_tool);
  443. #endif
  444. #else
  445. planner.synchronize();
  446. safe_delay(100); // Give switch time to settle
  447. #endif
  448. current_position.x = grabxclear;
  449. if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X + Security", current_position);
  450. _line_to_current(X_AXIS, 0.1f);
  451. planner.synchronize();
  452. safe_delay(100); // Give switch time to settle
  453. current_position.y += SWITCHING_TOOLHEAD_Y_CLEAR;
  454. if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
  455. fast_line_to_current(Y_AXIS); // move away from docked toolhead
  456. planner.synchronize(); // Always sync last tool-change move
  457. if (DEBUGGING(LEVELING)) DEBUG_POS("MST Tool-Change done.", current_position);
  458. }
  459. #elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
  460. inline void est_activate_solenoid() { OUT_WRITE(SOL0_PIN, HIGH); }
  461. inline void est_deactivate_solenoid() { OUT_WRITE(SOL0_PIN, LOW); }
  462. void est_init() { est_activate_solenoid(); }
  463. inline void em_switching_toolhead_tool_change(const uint8_t new_tool, bool no_move) {
  464. if (no_move) return;
  465. constexpr float toolheadposx[] = SWITCHING_TOOLHEAD_X_POS;
  466. const float placexpos = toolheadposx[active_extruder],
  467. grabxpos = toolheadposx[new_tool];
  468. const xyz_pos_t &hoffs = hotend_offset[active_extruder];
  469. /**
  470. * 1. Raise Z-Axis to give enough clearance
  471. * 2. Move to position near active extruder parking
  472. * 3. Move gently to park position of active extruder
  473. * 4. Disengage magnetic field, wait for delay
  474. * 5. Leave extruder and move to position near new extruder parking
  475. * 6. Move gently to park position of new extruder
  476. * 7. Engage magnetic field for new extruder parking
  477. * 8. Unpark extruder
  478. * 9. Apply Z hotend offset to current position
  479. */
  480. if (DEBUGGING(LEVELING)) DEBUG_POS("Start EMST Tool-Change", current_position);
  481. // 1. Raise Z-Axis to give enough clearance
  482. current_position.z += SWITCHING_TOOLHEAD_Z_HOP;
  483. if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis ", current_position);
  484. fast_line_to_current(Z_AXIS);
  485. // 2. Move to position near active extruder parking
  486. if (DEBUGGING(LEVELING)) {
  487. planner.synchronize();
  488. SERIAL_ECHOLNPAIR("(2) Move near active extruder parking", active_extruder);
  489. DEBUG_POS("Moving ParkPos", current_position);
  490. }
  491. current_position.set(hoffs.x + placexpos,
  492. hoffs.y + SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR);
  493. fast_line_to_current(X_AXIS);
  494. // 3. Move gently to park position of active extruder
  495. if (DEBUGGING(LEVELING)) {
  496. planner.synchronize();
  497. SERIAL_ECHOLNPAIR("(3) Move gently to park position of active extruder", active_extruder);
  498. DEBUG_POS("Moving ParkPos", current_position);
  499. }
  500. current_position.y -= SWITCHING_TOOLHEAD_Y_CLEAR;
  501. slow_line_to_current(Y_AXIS);
  502. // 4. Disengage magnetic field, wait for delay
  503. planner.synchronize();
  504. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Disengage magnet");
  505. est_deactivate_solenoid();
  506. // 5. Leave extruder and move to position near new extruder parking
  507. if (DEBUGGING(LEVELING)) {
  508. DEBUG_ECHOLNPGM("(5) Move near new extruder parking");
  509. DEBUG_POS("Moving ParkPos", current_position);
  510. }
  511. current_position.y += SWITCHING_TOOLHEAD_Y_CLEAR;
  512. slow_line_to_current(Y_AXIS);
  513. current_position.set(hoffs.x + grabxpos,
  514. hoffs.y + SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR);
  515. fast_line_to_current(X_AXIS);
  516. // 6. Move gently to park position of new extruder
  517. current_position.y -= SWITCHING_TOOLHEAD_Y_CLEAR;
  518. if (DEBUGGING(LEVELING)) {
  519. planner.synchronize();
  520. DEBUG_ECHOLNPGM("(6) Move near new extruder");
  521. }
  522. slow_line_to_current(Y_AXIS);
  523. // 7. Engage magnetic field for new extruder parking
  524. planner.synchronize();
  525. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(7) Engage magnetic field");
  526. est_activate_solenoid();
  527. // 8. Unpark extruder
  528. current_position.y += SWITCHING_TOOLHEAD_Y_CLEAR;
  529. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(8) Unpark extruder");
  530. slow_line_to_current(X_AXIS);
  531. planner.synchronize(); // Always sync the final move
  532. // 9. Apply Z hotend offset to current position
  533. if (DEBUGGING(LEVELING)) DEBUG_POS("(9) Applying Z-offset", current_position);
  534. current_position.z += hoffs.z - hotend_offset[new_tool].z;
  535. if (DEBUGGING(LEVELING)) DEBUG_POS("EMST Tool-Change done.", current_position);
  536. }
  537. #endif // ELECTROMAGNETIC_SWITCHING_TOOLHEAD
  538. #if EXTRUDERS
  539. inline void invalid_extruder_error(const uint8_t e) {
  540. SERIAL_ECHO_START();
  541. SERIAL_CHAR('T'); SERIAL_ECHO(int(e));
  542. SERIAL_CHAR(' '); SERIAL_ECHOLNPGM(STR_INVALID_EXTRUDER);
  543. }
  544. #endif
  545. #if ENABLED(DUAL_X_CARRIAGE)
  546. inline void dualx_tool_change(const uint8_t new_tool, bool &no_move) {
  547. if (DEBUGGING(LEVELING)) {
  548. DEBUG_ECHOPGM("Dual X Carriage Mode ");
  549. switch (dual_x_carriage_mode) {
  550. case DXC_FULL_CONTROL_MODE: DEBUG_ECHOLNPGM("FULL_CONTROL"); break;
  551. case DXC_AUTO_PARK_MODE: DEBUG_ECHOLNPGM("AUTO_PARK"); break;
  552. case DXC_DUPLICATION_MODE: DEBUG_ECHOLNPGM("DUPLICATION"); break;
  553. case DXC_MIRRORED_MODE: DEBUG_ECHOLNPGM("MIRRORED"); break;
  554. }
  555. }
  556. const float xhome = x_home_pos(active_extruder);
  557. if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE
  558. && IsRunning() && !no_move
  559. && (delayed_move_time || current_position.x != xhome)
  560. ) {
  561. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("MoveX to ", xhome);
  562. // Park old head
  563. current_position.x = xhome;
  564. line_to_current_position(planner.settings.max_feedrate_mm_s[X_AXIS]);
  565. planner.synchronize();
  566. }
  567. // Activate the new extruder ahead of calling set_axis_is_at_home!
  568. active_extruder = new_tool;
  569. // This function resets the max/min values - the current position may be overwritten below.
  570. set_axis_is_at_home(X_AXIS);
  571. if (DEBUGGING(LEVELING)) DEBUG_POS("New Extruder", current_position);
  572. switch (dual_x_carriage_mode) {
  573. case DXC_FULL_CONTROL_MODE:
  574. // New current position is the position of the activated extruder
  575. current_position.x = inactive_extruder_x_pos;
  576. // Save the inactive extruder's position (from the old current_position)
  577. inactive_extruder_x_pos = destination.x;
  578. break;
  579. case DXC_AUTO_PARK_MODE:
  580. // record current raised toolhead position for use by unpark
  581. raised_parked_position = current_position;
  582. active_extruder_parked = true;
  583. delayed_move_time = 0;
  584. break;
  585. default:
  586. break;
  587. }
  588. if (DEBUGGING(LEVELING)) {
  589. DEBUG_ECHOLNPAIR("Active extruder parked: ", active_extruder_parked ? "yes" : "no");
  590. DEBUG_POS("New extruder (parked)", current_position);
  591. }
  592. }
  593. #endif // DUAL_X_CARRIAGE
  594. /**
  595. * Perform a tool-change, which may result in moving the
  596. * previous tool out of the way and the new tool into place.
  597. */
  598. void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
  599. #if ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
  600. if (new_tool == active_extruder) return;
  601. #endif
  602. #if ENABLED(MIXING_EXTRUDER)
  603. UNUSED(no_move);
  604. if (new_tool >= MIXING_VIRTUAL_TOOLS)
  605. return invalid_extruder_error(new_tool);
  606. #if MIXING_VIRTUAL_TOOLS > 1
  607. // T0-Tnnn: Switch virtual tool by changing the index to the mix
  608. mixer.T(new_tool);
  609. #endif
  610. #elif ENABLED(PRUSA_MMU2)
  611. UNUSED(no_move);
  612. mmu2.tool_change(new_tool);
  613. #elif EXTRUDERS == 0
  614. // Nothing to do
  615. UNUSED(new_tool); UNUSED(no_move);
  616. #elif EXTRUDERS < 2
  617. UNUSED(no_move);
  618. if (new_tool) invalid_extruder_error(new_tool);
  619. return;
  620. #else // EXTRUDERS > 1
  621. planner.synchronize();
  622. #if ENABLED(DUAL_X_CARRIAGE) // Only T0 allowed if the Printer is in DXC_DUPLICATION_MODE or DXC_MIRRORED_MODE
  623. if (new_tool != 0 && dxc_is_duplicating())
  624. return invalid_extruder_error(new_tool);
  625. #endif
  626. if (new_tool >= EXTRUDERS)
  627. return invalid_extruder_error(new_tool);
  628. if (!no_move && !all_axes_homed()) {
  629. no_move = true;
  630. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("No move (not homed)");
  631. }
  632. #if HAS_LCD_MENU
  633. if (!no_move) ui.return_to_status();
  634. #endif
  635. #if ENABLED(DUAL_X_CARRIAGE)
  636. const bool idex_full_control = dual_x_carriage_mode == DXC_FULL_CONTROL_MODE;
  637. #else
  638. constexpr bool idex_full_control = false;
  639. #endif
  640. const uint8_t old_tool = active_extruder;
  641. const bool can_move_away = !no_move && !idex_full_control;
  642. #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
  643. const bool should_swap = can_move_away && toolchange_settings.swap_length;
  644. #if ENABLED(PREVENT_COLD_EXTRUSION)
  645. const bool too_cold = !DEBUGGING(DRYRUN) && (thermalManager.targetTooColdToExtrude(old_tool) || thermalManager.targetTooColdToExtrude(new_tool));
  646. #else
  647. constexpr bool too_cold = false;
  648. #endif
  649. if (should_swap) {
  650. if (too_cold) {
  651. SERIAL_ECHO_MSG(STR_ERR_HOTEND_TOO_COLD);
  652. #if ENABLED(SINGLENOZZLE)
  653. active_extruder = new_tool;
  654. return;
  655. #endif
  656. }
  657. else {
  658. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  659. do_pause_e_move(-toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.retract_speed));
  660. #else
  661. current_position.e -= toolchange_settings.swap_length / planner.e_factor[old_tool];
  662. planner.buffer_line(current_position, MMM_TO_MMS(toolchange_settings.retract_speed), old_tool);
  663. planner.synchronize();
  664. #endif
  665. }
  666. }
  667. #endif // TOOLCHANGE_FILAMENT_SWAP
  668. #if HAS_LEVELING && DISABLED(SINGLENOZZLE)
  669. // Set current position to the physical position
  670. TEMPORARY_BED_LEVELING_STATE(false);
  671. #endif
  672. if (new_tool != old_tool) {
  673. #if SWITCHING_NOZZLE_TWO_SERVOS
  674. raise_nozzle(old_tool);
  675. #endif
  676. REMEMBER(fr, feedrate_mm_s, XY_PROBE_FEEDRATE_MM_S);
  677. #if HAS_SOFTWARE_ENDSTOPS
  678. #if HAS_HOTEND_OFFSET
  679. #define _EXT_ARGS , old_tool, new_tool
  680. #else
  681. #define _EXT_ARGS
  682. #endif
  683. update_software_endstops(X_AXIS _EXT_ARGS);
  684. #if DISABLED(DUAL_X_CARRIAGE)
  685. update_software_endstops(Y_AXIS _EXT_ARGS);
  686. update_software_endstops(Z_AXIS _EXT_ARGS);
  687. #endif
  688. #endif
  689. destination = current_position;
  690. #if DISABLED(SWITCHING_NOZZLE)
  691. if (can_move_away) {
  692. // Do a small lift to avoid the workpiece in the move back (below)
  693. current_position.z += toolchange_settings.z_raise;
  694. #if HAS_SOFTWARE_ENDSTOPS
  695. NOMORE(current_position.z, soft_endstop.max.z);
  696. #endif
  697. fast_line_to_current(Z_AXIS);
  698. #if ENABLED(TOOLCHANGE_PARK)
  699. current_position = toolchange_settings.change_point;
  700. #endif
  701. planner.buffer_line(current_position, feedrate_mm_s, old_tool);
  702. planner.synchronize();
  703. }
  704. #endif
  705. #if HAS_HOTEND_OFFSET
  706. xyz_pos_t diff = hotend_offset[new_tool] - hotend_offset[old_tool];
  707. #if ENABLED(DUAL_X_CARRIAGE)
  708. diff.x = 0;
  709. #endif
  710. #else
  711. constexpr xyz_pos_t diff{0};
  712. #endif
  713. #if ENABLED(DUAL_X_CARRIAGE)
  714. dualx_tool_change(new_tool, no_move);
  715. #elif ENABLED(PARKING_EXTRUDER) // Dual Parking extruder
  716. parking_extruder_tool_change(new_tool, no_move);
  717. #elif ENABLED(MAGNETIC_PARKING_EXTRUDER) // Magnetic Parking extruder
  718. magnetic_parking_extruder_tool_change(new_tool);
  719. #elif ENABLED(SWITCHING_TOOLHEAD) // Switching Toolhead
  720. switching_toolhead_tool_change(new_tool, no_move);
  721. #elif ENABLED(MAGNETIC_SWITCHING_TOOLHEAD) // Magnetic Switching Toolhead
  722. magnetic_switching_toolhead_tool_change(new_tool, no_move);
  723. #elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD) // Magnetic Switching ToolChanger
  724. em_switching_toolhead_tool_change(new_tool, no_move);
  725. #elif ENABLED(SWITCHING_NOZZLE) && !SWITCHING_NOZZLE_TWO_SERVOS // Switching Nozzle (single servo)
  726. // Raise by a configured distance to avoid workpiece, except with
  727. // SWITCHING_NOZZLE_TWO_SERVOS, as both nozzles will lift instead.
  728. if (!no_move) {
  729. #if HAS_SOFTWARE_ENDSTOPS
  730. const float maxz = _MIN(soft_endstop.max.z, Z_MAX_POS);
  731. #else
  732. constexpr float maxz = Z_MAX_POS;
  733. #endif
  734. // Check if Z has space to compensate at least z_offset, and if not, just abort now
  735. const float newz = current_position.z + _MAX(-diff.z, 0.0);
  736. if (newz > maxz) return;
  737. current_position.z = _MIN(newz + toolchange_settings.z_raise, maxz);
  738. fast_line_to_current(Z_AXIS);
  739. }
  740. move_nozzle_servo(new_tool);
  741. #endif
  742. #if DISABLED(DUAL_X_CARRIAGE)
  743. active_extruder = new_tool; // Set the new active extruder
  744. #endif
  745. // The newly-selected extruder XYZ is actually at...
  746. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Offset Tool XYZ by { ", diff.x, ", ", diff.y, ", ", diff.z, " }");
  747. current_position += diff;
  748. // Tell the planner the new "current position"
  749. sync_plan_position();
  750. #if ENABLED(DELTA)
  751. //LOOP_XYZ(i) update_software_endstops(i); // or modify the constrain function
  752. const bool safe_to_move = current_position.z < delta_clip_start_height - 1;
  753. #else
  754. constexpr bool safe_to_move = true;
  755. #endif
  756. // Return to position and lower again
  757. if (safe_to_move && !no_move && IsRunning()) {
  758. #if ENABLED(SINGLENOZZLE)
  759. #if FAN_COUNT > 0
  760. singlenozzle_fan_speed[old_tool] = thermalManager.fan_speed[0];
  761. thermalManager.fan_speed[0] = singlenozzle_fan_speed[new_tool];
  762. #endif
  763. singlenozzle_temp[old_tool] = thermalManager.temp_hotend[0].target;
  764. if (singlenozzle_temp[new_tool] && singlenozzle_temp[new_tool] != singlenozzle_temp[old_tool]) {
  765. thermalManager.setTargetHotend(singlenozzle_temp[new_tool], 0);
  766. #if HAS_DISPLAY
  767. thermalManager.set_heating_message(0);
  768. #endif
  769. (void)thermalManager.wait_for_hotend(0, false); // Wait for heating or cooling
  770. }
  771. #endif
  772. #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
  773. if (should_swap && !too_cold) {
  774. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  775. do_pause_e_move(toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.prime_speed));
  776. do_pause_e_move(toolchange_settings.extra_prime, ADVANCED_PAUSE_PURGE_FEEDRATE);
  777. #else
  778. current_position.e += toolchange_settings.swap_length / planner.e_factor[new_tool];
  779. planner.buffer_line(current_position, MMM_TO_MMS(toolchange_settings.prime_speed), new_tool);
  780. current_position.e += toolchange_settings.extra_prime / planner.e_factor[new_tool];
  781. planner.buffer_line(current_position, MMM_TO_MMS(toolchange_settings.prime_speed * 0.2f), new_tool);
  782. #endif
  783. planner.synchronize();
  784. planner.set_e_position_mm((destination.e = current_position.e = current_position.e - (TOOLCHANGE_FIL_EXTRA_PRIME)));
  785. }
  786. #endif
  787. // Prevent a move outside physical bounds
  788. #if ENABLED(MAGNETIC_SWITCHING_TOOLHEAD)
  789. // If the original position is within tool store area, go to X origin at once
  790. if (destination.y < SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR) {
  791. current_position.x = 0;
  792. planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], new_tool);
  793. planner.synchronize();
  794. }
  795. #else
  796. apply_motion_limits(destination);
  797. #endif
  798. // Should the nozzle move back to the old position?
  799. if (can_move_away) {
  800. #if ENABLED(TOOLCHANGE_NO_RETURN)
  801. // Just move back down
  802. if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Move back Z only");
  803. do_blocking_move_to_z(destination.z, planner.settings.max_feedrate_mm_s[Z_AXIS]);
  804. #else
  805. // Move back to the original (or adjusted) position
  806. if (DEBUGGING(LEVELING)) DEBUG_POS("Move back", destination);
  807. do_blocking_move_to(destination);
  808. #endif
  809. }
  810. else if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Move back skipped");
  811. #if ENABLED(DUAL_X_CARRIAGE)
  812. active_extruder_parked = false;
  813. #endif
  814. }
  815. #if ENABLED(SWITCHING_NOZZLE)
  816. else {
  817. // Move back down. (Including when the new tool is higher.)
  818. do_blocking_move_to_z(destination.z, planner.settings.max_feedrate_mm_s[Z_AXIS]);
  819. }
  820. #endif
  821. #if ENABLED(PRUSA_MMU2)
  822. mmu2.tool_change(new_tool);
  823. #endif
  824. #if SWITCHING_NOZZLE_TWO_SERVOS
  825. lower_nozzle(new_tool);
  826. #endif
  827. } // (new_tool != old_tool)
  828. planner.synchronize();
  829. #if ENABLED(EXT_SOLENOID) && DISABLED(PARKING_EXTRUDER)
  830. disable_all_solenoids();
  831. enable_solenoid_on_active_extruder();
  832. #endif
  833. #if ENABLED(MK2_MULTIPLEXER)
  834. if (new_tool >= E_STEPPERS) return invalid_extruder_error(new_tool);
  835. select_multiplexed_stepper(new_tool);
  836. #endif
  837. #if DO_SWITCH_EXTRUDER
  838. planner.synchronize();
  839. move_extruder_servo(active_extruder);
  840. #endif
  841. #if HAS_FANMUX
  842. fanmux_switch(active_extruder);
  843. #endif
  844. #ifdef EVENT_GCODE_AFTER_TOOLCHANGE
  845. if (!no_move)
  846. gcode.process_subcommands_now_P(PSTR(EVENT_GCODE_AFTER_TOOLCHANGE));
  847. #endif
  848. SERIAL_ECHO_START();
  849. SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(active_extruder));
  850. #endif // EXTRUDERS > 1
  851. }