My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

M605.cpp 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2019 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/MarlinConfig.h"
  23. #if HAS_DUPLICATION_MODE
  24. //#define DEBUG_DXC_MODE
  25. #include "../gcode.h"
  26. #include "../../module/motion.h"
  27. #include "../../module/stepper.h"
  28. #include "../../module/tool_change.h"
  29. #include "../../module/planner.h"
  30. #if ENABLED(DUAL_X_CARRIAGE)
  31. /**
  32. * M605: Set dual x-carriage movement mode
  33. *
  34. * M605 : Restore user specified DEFAULT_DUAL_X_CARRIAGE_MODE
  35. * M605 S0 : Full control mode. The slicer has full control over x-carriage movement
  36. * M605 S1 : Auto-park mode. The inactive head will auto park/unpark without slicer involvement
  37. * M605 S2 [Xnnn] [Rmmm]: Duplication mode. The second extruder will duplicate the first with nnn
  38. * units x-offset and an optional differential hotend temperature of
  39. * mmm degrees. E.g., with "M605 S2 X100 R2" the second extruder will duplicate
  40. * the first with a spacing of 100mm in the x direction and 2 degrees hotter.
  41. * M605 S3 : Enable Scaled Duplication mode. The second extruder will duplicate the first extruder's
  42. * movement similar to the M605 S2 mode. However, the second extruder will be producing
  43. * a scaled image of the first extruder. The initial x-offset and temperature differential are
  44. * set with M605 S2 [Xnnn] [Rmmm] and then followed with a M605 S3 to start the mirrored movement.
  45. * M605 W : IDEX What? command.
  46. *
  47. * Note: the X axis should be homed after changing dual x-carriage mode.
  48. */
  49. void GcodeSuite::M605() {
  50. planner.synchronize();
  51. if (parser.seen('S')) {
  52. const DualXMode previous_mode = dual_x_carriage_mode;
  53. dual_x_carriage_mode = (DualXMode)parser.value_byte();
  54. #if 0
  55. scaled_duplication_mode = false;
  56. if (dual_x_carriage_mode == DXC_SCALED_DUPLICATION_MODE) {
  57. if (previous_mode != DXC_DUPLICATION_MODE) {
  58. SERIAL_ECHOLNPGM("Printer must be in DXC_DUPLICATION_MODE prior to ");
  59. SERIAL_ECHOLNPGM("specifying DXC_SCALED_DUPLICATION_MODE.");
  60. dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
  61. return;
  62. }
  63. scaled_duplication_mode = true;
  64. stepper.set_directions();
  65. float x_jog = current_position[X_AXIS] - .1;
  66. for (uint8_t i = 2; --i;) {
  67. planner.buffer_line(x_jog, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate_mm_s, 0);
  68. x_jog += .1;
  69. }
  70. return;
  71. }
  72. #endif
  73. switch (dual_x_carriage_mode) {
  74. case DXC_FULL_CONTROL_MODE:
  75. case DXC_AUTO_PARK_MODE:
  76. break;
  77. case DXC_DUPLICATION_MODE:
  78. if (parser.seen('X')) duplicate_extruder_x_offset = MAX(parser.value_linear_units(), X2_MIN_POS - x_home_pos(0));
  79. if (parser.seen('R')) duplicate_extruder_temp_offset = parser.value_celsius_diff();
  80. if (active_extruder != 0) tool_change(0);
  81. break;
  82. default:
  83. dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
  84. break;
  85. }
  86. active_extruder_parked = false;
  87. extruder_duplication_enabled = false;
  88. stepper.set_directions();
  89. delayed_move_time = 0;
  90. }
  91. else if (!parser.seen('W')) // if no S or W parameter, the DXC mode gets reset to the user's default
  92. dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
  93. #ifdef DEBUG_DXC_MODE
  94. if (parser.seen('W')) {
  95. SERIAL_ECHO_START();
  96. SERIAL_ECHOPGM("IDEX mode: ");
  97. switch (dual_x_carriage_mode) {
  98. case DXC_FULL_CONTROL_MODE: SERIAL_ECHOPGM("DXC_FULL_CONTROL_MODE"); break;
  99. case DXC_AUTO_PARK_MODE: SERIAL_ECHOPGM("DXC_AUTO_PARK_MODE"); break;
  100. case DXC_DUPLICATION_MODE: SERIAL_ECHOPGM("DXC_DUPLICATION_MODE"); break;
  101. case DXC_SCALED_DUPLICATION_MODE: SERIAL_ECHOPGM("DXC_SCALED_DUPLICATION_MODE"); break;
  102. }
  103. SERIAL_ECHOPAIR("\nActive Ext: ", int(active_extruder));
  104. if (!active_extruder_parked) SERIAL_ECHOPGM(" NOT ");
  105. SERIAL_ECHOPGM(" parked.");
  106. SERIAL_ECHOPAIR("\nactive_extruder_x_pos: ", current_position[X_AXIS]);
  107. SERIAL_ECHOPAIR("\ninactive_extruder_x_pos: ", inactive_extruder_x_pos);
  108. SERIAL_ECHOPAIR("\nextruder_duplication_enabled: ", int(extruder_duplication_enabled));
  109. SERIAL_ECHOPAIR("\nduplicate_extruder_x_offset: ", duplicate_extruder_x_offset);
  110. SERIAL_ECHOPAIR("\nduplicate_extruder_temp_offset: ", duplicate_extruder_temp_offset);
  111. SERIAL_ECHOPAIR("\ndelayed_move_time: ", delayed_move_time);
  112. SERIAL_ECHOPAIR("\nX1 Home X: ", x_home_pos(0));
  113. SERIAL_ECHOPAIR("\nX1_MIN_POS=", int(X1_MIN_POS));
  114. SERIAL_ECHOPAIR("\nX1_MAX_POS=", int(X1_MAX_POS));
  115. SERIAL_ECHOPAIR("\nX2 Home X: ", x_home_pos(1));
  116. SERIAL_ECHOPAIR("\nX2_MIN_POS=", int(X2_MIN_POS));
  117. SERIAL_ECHOPAIR("\nX2_MAX_POS=", int(X2_MAX_POS));
  118. SERIAL_ECHOPAIR("\nX2_HOME_DIR=", int(X2_HOME_DIR));
  119. SERIAL_ECHOPAIR("\nX2_HOME_POS=", int(X2_HOME_POS));
  120. SERIAL_ECHOPAIR("\nDEFAULT_DUAL_X_CARRIAGE_MODE=", STRINGIFY(DEFAULT_DUAL_X_CARRIAGE_MODE));
  121. SERIAL_ECHOPAIR("\nTOOLCHANGE_ZRAISE=", float(TOOLCHANGE_ZRAISE));
  122. SERIAL_ECHOPAIR("\nDEFAULT_DUPLICATION_X_OFFSET=", int(DEFAULT_DUPLICATION_X_OFFSET));
  123. SERIAL_EOL();
  124. for (uint8_t i = 0; i < 2; i++) {
  125. SERIAL_ECHOPAIR(" nozzle:", int(i));
  126. LOOP_XYZ(j) {
  127. SERIAL_ECHOPGM(" hotend_offset[");
  128. SERIAL_CHAR(axis_codes[j]);
  129. SERIAL_ECHOPAIR("_AXIS][", int(i));
  130. SERIAL_ECHOPAIR("]=", hotend_offset[j][i]);
  131. }
  132. SERIAL_EOL();
  133. }
  134. SERIAL_EOL();
  135. }
  136. #endif // DEBUG_DXC_MODE
  137. }
  138. #elif ENABLED(MULTI_NOZZLE_DUPLICATION)
  139. /**
  140. * M605: Set multi-nozzle duplication mode
  141. *
  142. * S2 - Enable duplication mode
  143. * P[mask] - Bit-mask of nozzles to include in the duplication set.
  144. * A value of 0 disables duplication.
  145. * E[index] - Last nozzle index to include in the duplication set.
  146. * A value of 0 disables duplication.
  147. */
  148. void GcodeSuite::M605() {
  149. if (parser.seen("EPS")) {
  150. planner.synchronize();
  151. if (parser.seenval('P')) duplication_e_mask = parser.value_int(); // Set the mask directly
  152. else if (parser.seenval('E')) duplication_e_mask = pow(2, e + 1) - 1; // Set the mask by E index
  153. const bool ena = (2 == parser.intval('S', extruder_duplication_enabled ? 2 : 0));
  154. extruder_duplication_enabled = ena && (duplication_e_mask >= 3);
  155. }
  156. SERIAL_ECHO_START();
  157. SERIAL_ECHOPGM(MSG_DUPLICATION_MODE);
  158. serialprint_onoff(extruder_duplication_enabled);
  159. if (ena) {
  160. SERIAL_ECHOPGM(" ( ");
  161. HOTEND_LOOP() if (TEST(duplication_e_mask, e)) { SERIAL_ECHO(e); SERIAL_CHAR(' '); }
  162. SERIAL_CHAR(')');
  163. }
  164. SERIAL_EOL();
  165. }
  166. #endif // MULTI_NOZZLE_DUPLICATION
  167. #endif // HAS_DUPICATION_MODE