My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

M605.cpp 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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/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. #define DEBUG_OUT ENABLED(DEBUG_DXC_MODE)
  31. #include "../../core/debug_out.h"
  32. #if ENABLED(DUAL_X_CARRIAGE)
  33. /**
  34. * M605: Set dual x-carriage movement mode
  35. *
  36. * M605 S0 : (FULL_CONTROL) The slicer has full control over both X-carriages and can achieve optimal travel
  37. * results as long as it supports dual X-carriages.
  38. *
  39. * M605 S1 : (AUTO_PARK) The firmware automatically parks and unparks the X-carriages on tool-change so that
  40. * additional slicer support is not required.
  41. *
  42. * M605 S2 X R : (DUPLICATION) The firmware moves the second X-carriage and extruder in synchronization with
  43. * the first X-carriage and extruder, to print 2 copies of the same object at the same time.
  44. * Set the constant X-offset and temperature differential with M605 S2 X[offs] R[deg] and
  45. * follow with "M605 S2" to initiate duplicated movement. For example, use "M605 S2 X100 R2" to
  46. * make a copy 100mm to the right with E1 2° hotter than E0.
  47. *
  48. * M605 S3 : (MIRRORED) Formbot/Vivedino-inspired mirrored mode in which the second extruder duplicates
  49. * the movement of the first except the second extruder is reversed in the X axis.
  50. * The temperature differential and initial X offset must be set with "M605 S2 X[offs] R[deg]",
  51. * then followed by "M605 S3" to initiate mirrored movement.
  52. *
  53. * M605 W : IDEX What? command.
  54. *
  55. * Note: the X axis should be homed after changing Dual X-carriage mode.
  56. */
  57. void GcodeSuite::M605() {
  58. planner.synchronize();
  59. if (parser.seen('S')) {
  60. const DualXMode previous_mode = dual_x_carriage_mode;
  61. dual_x_carriage_mode = (DualXMode)parser.value_byte();
  62. mirrored_duplication_mode = false;
  63. if (dual_x_carriage_mode == DXC_MIRRORED_MODE) {
  64. if (previous_mode != DXC_DUPLICATION_MODE) {
  65. SERIAL_ECHOLNPGM("Printer must be in DXC_DUPLICATION_MODE prior to ");
  66. SERIAL_ECHOLNPGM("specifying DXC_MIRRORED_MODE.");
  67. dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
  68. return;
  69. }
  70. mirrored_duplication_mode = true;
  71. stepper.set_directions();
  72. float x_jog = current_position.x - .1;
  73. for (uint8_t i = 2; --i;) {
  74. planner.buffer_line(x_jog, current_position.y, current_position.z, current_position.e, feedrate_mm_s, 0);
  75. x_jog += .1;
  76. }
  77. return;
  78. }
  79. switch (dual_x_carriage_mode) {
  80. case DXC_FULL_CONTROL_MODE:
  81. case DXC_AUTO_PARK_MODE:
  82. break;
  83. case DXC_DUPLICATION_MODE:
  84. if (parser.seen('X')) duplicate_extruder_x_offset = _MAX(parser.value_linear_units(), X2_MIN_POS - x_home_pos(0));
  85. if (parser.seen('R')) duplicate_extruder_temp_offset = parser.value_celsius_diff();
  86. if (active_extruder != 0) tool_change(0);
  87. break;
  88. default:
  89. dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
  90. break;
  91. }
  92. active_extruder_parked = false;
  93. extruder_duplication_enabled = false;
  94. stepper.set_directions();
  95. delayed_move_time = 0;
  96. }
  97. else if (!parser.seen('W')) // if no S or W parameter, the DXC mode gets reset to the user's default
  98. dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
  99. #ifdef DEBUG_DXC_MODE
  100. if (parser.seen('W')) {
  101. DEBUG_ECHO_START();
  102. DEBUG_ECHOPGM("Dual X Carriage Mode ");
  103. switch (dual_x_carriage_mode) {
  104. case DXC_FULL_CONTROL_MODE: DEBUG_ECHOPGM("FULL_CONTROL"); break;
  105. case DXC_AUTO_PARK_MODE: DEBUG_ECHOPGM("AUTO_PARK"); break;
  106. case DXC_DUPLICATION_MODE: DEBUG_ECHOPGM("DUPLICATION"); break;
  107. case DXC_MIRRORED_MODE: DEBUG_ECHOPGM("MIRRORED"); break;
  108. }
  109. DEBUG_ECHOPAIR("\nActive Ext: ", int(active_extruder));
  110. if (!active_extruder_parked) DEBUG_ECHOPGM(" NOT ");
  111. DEBUG_ECHOPGM(" parked.");
  112. DEBUG_ECHOPAIR("\nactive_extruder_x_pos: ", current_position.x);
  113. DEBUG_ECHOPAIR("\ninactive_extruder_x_pos: ", inactive_extruder_x_pos);
  114. DEBUG_ECHOPAIR("\nextruder_duplication_enabled: ", int(extruder_duplication_enabled));
  115. DEBUG_ECHOPAIR("\nduplicate_extruder_x_offset: ", duplicate_extruder_x_offset);
  116. DEBUG_ECHOPAIR("\nduplicate_extruder_temp_offset: ", duplicate_extruder_temp_offset);
  117. DEBUG_ECHOPAIR("\ndelayed_move_time: ", delayed_move_time);
  118. DEBUG_ECHOPAIR("\nX1 Home X: ", x_home_pos(0), "\nX1_MIN_POS=", int(X1_MIN_POS), "\nX1_MAX_POS=", int(X1_MAX_POS));
  119. DEBUG_ECHOPAIR("\nX2 Home X: ", x_home_pos(1), "\nX2_MIN_POS=", int(X2_MIN_POS), "\nX2_MAX_POS=", int(X2_MAX_POS));
  120. DEBUG_ECHOPAIR("\nX2_HOME_DIR=", int(X2_HOME_DIR), "\nX2_HOME_POS=", int(X2_HOME_POS));
  121. DEBUG_ECHOPAIR("\nDEFAULT_DUAL_X_CARRIAGE_MODE=", STRINGIFY(DEFAULT_DUAL_X_CARRIAGE_MODE));
  122. DEBUG_ECHOPAIR("\toolchange_settings.z_raise=", toolchange_settings.z_raise);
  123. DEBUG_ECHOPAIR("\nDEFAULT_DUPLICATION_X_OFFSET=", int(DEFAULT_DUPLICATION_X_OFFSET));
  124. DEBUG_EOL();
  125. HOTEND_LOOP() {
  126. DEBUG_ECHOPAIR_P(SP_T_STR, int(e));
  127. LOOP_XYZ(a) DEBUG_ECHOPAIR(" hotend_offset[", int(e), "].", axis_codes[a] | 0x20, "=", hotend_offset[e][a]);
  128. DEBUG_EOL();
  129. }
  130. DEBUG_EOL();
  131. }
  132. #endif // DEBUG_DXC_MODE
  133. }
  134. #elif ENABLED(MULTI_NOZZLE_DUPLICATION)
  135. /**
  136. * M605: Set multi-nozzle duplication mode
  137. *
  138. * S2 - Enable duplication mode
  139. * P[mask] - Bit-mask of nozzles to include in the duplication set.
  140. * A value of 0 disables duplication.
  141. * E[index] - Last nozzle index to include in the duplication set.
  142. * A value of 0 disables duplication.
  143. */
  144. void GcodeSuite::M605() {
  145. bool ena = false;
  146. if (parser.seen("EPS")) {
  147. planner.synchronize();
  148. if (parser.seenval('P')) duplication_e_mask = parser.value_int(); // Set the mask directly
  149. else if (parser.seenval('E')) duplication_e_mask = pow(2, parser.value_int() + 1) - 1; // Set the mask by E index
  150. ena = (2 == parser.intval('S', extruder_duplication_enabled ? 2 : 0));
  151. extruder_duplication_enabled = ena && (duplication_e_mask >= 3);
  152. }
  153. SERIAL_ECHO_START();
  154. SERIAL_ECHOPGM(STR_DUPLICATION_MODE);
  155. serialprint_onoff(extruder_duplication_enabled);
  156. if (ena) {
  157. SERIAL_ECHOPGM(" ( ");
  158. HOTEND_LOOP() if (TEST(duplication_e_mask, e)) { SERIAL_ECHO(e); SERIAL_CHAR(' '); }
  159. SERIAL_CHAR(')');
  160. }
  161. SERIAL_EOL();
  162. }
  163. #endif // MULTI_NOZZLE_DUPLICATION
  164. #endif // HAS_DUPICATION_MODE