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.

M605.cpp 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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 ENABLED(DUAL_X_CARRIAGE) || ENABLED(DUAL_NOZZLE_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. scaled_duplication_mode = false;
  55. if (dual_x_carriage_mode == DXC_SCALED_DUPLICATION_MODE) {
  56. if (previous_mode != DXC_DUPLICATION_MODE) {
  57. SERIAL_ECHOLNPGM("Printer must be in DXC_DUPLICATION_MODE prior to ");
  58. SERIAL_ECHOLNPGM("specifying DXC_SCALED_DUPLICATION_MODE.");
  59. dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
  60. return;
  61. }
  62. scaled_duplication_mode = true;
  63. stepper.set_directions();
  64. float x_jog = current_position[X_AXIS] - .1;
  65. for (uint8_t i = 2; --i;) {
  66. planner.buffer_line(x_jog, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate_mm_s, 0);
  67. x_jog += .1;
  68. }
  69. return;
  70. }
  71. switch (dual_x_carriage_mode) {
  72. case DXC_FULL_CONTROL_MODE:
  73. case DXC_AUTO_PARK_MODE:
  74. break;
  75. case DXC_DUPLICATION_MODE:
  76. if (parser.seen('X')) duplicate_extruder_x_offset = MAX(parser.value_linear_units(), X2_MIN_POS - x_home_pos(0));
  77. if (parser.seen('R')) duplicate_extruder_temp_offset = parser.value_celsius_diff();
  78. if (active_extruder != 0) tool_change(0);
  79. break;
  80. default:
  81. dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
  82. break;
  83. }
  84. active_extruder_parked = false;
  85. extruder_duplication_enabled = false;
  86. stepper.set_directions();
  87. delayed_move_time = 0;
  88. }
  89. else if (!parser.seen('W')) // if no S or W parameter, the DXC mode gets reset to the user's default
  90. dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
  91. #ifdef DEBUG_DXC_MODE
  92. if (parser.seen('W')) {
  93. SERIAL_ECHO_START();
  94. SERIAL_ECHOPGM("IDEX mode: ");
  95. switch (dual_x_carriage_mode) {
  96. case DXC_FULL_CONTROL_MODE: SERIAL_ECHOPGM("DXC_FULL_CONTROL_MODE"); break;
  97. case DXC_AUTO_PARK_MODE: SERIAL_ECHOPGM("DXC_AUTO_PARK_MODE"); break;
  98. case DXC_DUPLICATION_MODE: SERIAL_ECHOPGM("DXC_DUPLICATION_MODE"); break;
  99. case DXC_SCALED_DUPLICATION_MODE: SERIAL_ECHOPGM("DXC_SCALED_DUPLICATION_MODE"); break;
  100. }
  101. SERIAL_ECHOPAIR("\nActive Ext: ", int(active_extruder));
  102. if (!active_extruder_parked) SERIAL_ECHOPGM(" NOT ");
  103. SERIAL_ECHOPGM(" parked.");
  104. SERIAL_ECHOPAIR("\nactive_extruder_x_pos: ", current_position[X_AXIS]);
  105. SERIAL_ECHOPAIR("\ninactive_extruder_x_pos: ", inactive_extruder_x_pos);
  106. SERIAL_ECHOPAIR("\nextruder_duplication_enabled: ", int(extruder_duplication_enabled));
  107. SERIAL_ECHOPAIR("\nduplicate_extruder_x_offset: ", duplicate_extruder_x_offset);
  108. SERIAL_ECHOPAIR("\nduplicate_extruder_temp_offset: ", duplicate_extruder_temp_offset);
  109. SERIAL_ECHOPAIR("\ndelayed_move_time: ", delayed_move_time);
  110. SERIAL_ECHOPAIR("\nX1 Home X: ", x_home_pos(0));
  111. SERIAL_ECHOPAIR("\nX1_MIN_POS=", int(X1_MIN_POS));
  112. SERIAL_ECHOPAIR("\nX1_MAX_POS=", int(X1_MAX_POS));
  113. SERIAL_ECHOPAIR("\nX2 Home X: ", x_home_pos(1));
  114. SERIAL_ECHOPAIR("\nX2_MIN_POS=", int(X2_MIN_POS));
  115. SERIAL_ECHOPAIR("\nX2_MAX_POS=", int(X2_MAX_POS));
  116. SERIAL_ECHOPAIR("\nX2_HOME_DIR=", int(X2_HOME_DIR));
  117. SERIAL_ECHOPAIR("\nX2_HOME_POS=", int(X2_HOME_POS));
  118. SERIAL_ECHOPAIR("\nDEFAULT_DUAL_X_CARRIAGE_MODE=", STRINGIFY(DEFAULT_DUAL_X_CARRIAGE_MODE));
  119. SERIAL_ECHOPAIR("\nTOOLCHANGE_ZRAISE=", float(TOOLCHANGE_ZRAISE));
  120. SERIAL_ECHOPAIR("\nDEFAULT_DUPLICATION_X_OFFSET=", int(DEFAULT_DUPLICATION_X_OFFSET));
  121. SERIAL_EOL();
  122. for (uint8_t i = 0; i < 2; i++) {
  123. SERIAL_ECHOPAIR(" nozzle:", int(i));
  124. LOOP_XYZ(j) {
  125. SERIAL_ECHOPGM(" hotend_offset[");
  126. SERIAL_CHAR(axis_codes[j]);
  127. SERIAL_ECHOPAIR("_AXIS][", int(i));
  128. SERIAL_ECHOPAIR("]=", hotend_offset[j][i]);
  129. }
  130. SERIAL_EOL();
  131. }
  132. SERIAL_EOL();
  133. }
  134. #endif // DEBUG_DXC_MODE
  135. }
  136. #elif ENABLED(DUAL_NOZZLE_DUPLICATION_MODE)
  137. void GcodeSuite::M605() {
  138. planner.synchronize();
  139. extruder_duplication_enabled = parser.intval('S') == (int)DXC_DUPLICATION_MODE;
  140. SERIAL_ECHO_START();
  141. SERIAL_ECHOPGM(MSG_DUPLICATION_MODE);
  142. serialprintln_onoff(extruder_duplication_enabled);
  143. }
  144. #endif // DUAL_NOZZLE_DUPLICATION_MODE
  145. #endif // DUAL_X_CARRIAGE || DUAL_NOZZLE_DUPLICATION_MODE