My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

M200-M205.cpp 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 "../gcode.h"
  23. #include "../../Marlin.h"
  24. #include "../../module/planner.h"
  25. #if DISABLED(NO_VOLUMETRICS)
  26. /**
  27. * M200: Set filament diameter and set E axis units to cubic units
  28. *
  29. * T<extruder> - Optional extruder number. Current extruder if omitted.
  30. * D<linear> - Diameter of the filament. Use "D0" to switch back to linear units on the E axis.
  31. */
  32. void GcodeSuite::M200() {
  33. const int8_t target_extruder = get_target_extruder_from_command();
  34. if (target_extruder < 0) return;
  35. if (parser.seen('D')) {
  36. // setting any extruder filament size disables volumetric on the assumption that
  37. // slicers either generate in extruder values as cubic mm or as as filament feeds
  38. // for all extruders
  39. if ( (parser.volumetric_enabled = (parser.value_linear_units() != 0)) )
  40. planner.set_filament_size(target_extruder, parser.value_linear_units());
  41. }
  42. planner.calculate_volumetric_multipliers();
  43. }
  44. #endif // !NO_VOLUMETRICS
  45. /**
  46. * M201: Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
  47. *
  48. * With multiple extruders use T to specify which one.
  49. */
  50. void GcodeSuite::M201() {
  51. const int8_t target_extruder = get_target_extruder_from_command();
  52. if (target_extruder < 0) return;
  53. LOOP_XYZE(i) {
  54. if (parser.seen(axis_codes[i])) {
  55. const uint8_t a = (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i);
  56. planner.set_max_acceleration(a, parser.value_axis_units((AxisEnum)a));
  57. }
  58. }
  59. }
  60. /**
  61. * M203: Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in units/sec
  62. *
  63. * With multiple extruders use T to specify which one.
  64. */
  65. void GcodeSuite::M203() {
  66. const int8_t target_extruder = get_target_extruder_from_command();
  67. if (target_extruder < 0) return;
  68. LOOP_XYZE(i)
  69. if (parser.seen(axis_codes[i])) {
  70. const uint8_t a = (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i);
  71. planner.set_max_feedrate(a, parser.value_axis_units((AxisEnum)a));
  72. }
  73. }
  74. /**
  75. * M204: Set Accelerations in units/sec^2 (M204 P1200 R3000 T3000)
  76. *
  77. * P = Printing moves
  78. * R = Retract only (no X, Y, Z) moves
  79. * T = Travel (non printing) moves
  80. */
  81. void GcodeSuite::M204() {
  82. if (!parser.seen("PRST")) {
  83. SERIAL_ECHOPAIR("Acceleration: P", planner.settings.acceleration);
  84. SERIAL_ECHOPAIR(" R", planner.settings.retract_acceleration);
  85. SERIAL_ECHOLNPAIR(" T", planner.settings.travel_acceleration);
  86. }
  87. else {
  88. //planner.synchronize();
  89. // 'S' for legacy compatibility. Should NOT BE USED for new development
  90. if (parser.seenval('S')) planner.settings.travel_acceleration = planner.settings.acceleration = parser.value_linear_units();
  91. if (parser.seenval('P')) planner.settings.acceleration = parser.value_linear_units();
  92. if (parser.seenval('R')) planner.settings.retract_acceleration = parser.value_linear_units();
  93. if (parser.seenval('T')) planner.settings.travel_acceleration = parser.value_linear_units();
  94. }
  95. }
  96. /**
  97. * M205: Set Advanced Settings
  98. *
  99. * B = Min Segment Time (µs)
  100. * S = Min Feed Rate (units/s)
  101. * T = Min Travel Feed Rate (units/s)
  102. * X = Max X Jerk (units/sec^2)
  103. * Y = Max Y Jerk (units/sec^2)
  104. * Z = Max Z Jerk (units/sec^2)
  105. * E = Max E Jerk (units/sec^2)
  106. * J = Junction Deviation (mm) (Requires JUNCTION_DEVIATION)
  107. */
  108. void GcodeSuite::M205() {
  109. #if ENABLED(JUNCTION_DEVIATION)
  110. #define J_PARAM "J"
  111. #else
  112. #define J_PARAM
  113. #endif
  114. #if HAS_CLASSIC_JERK
  115. #define XYZE_PARAM "XYZE"
  116. #else
  117. #define XYZE_PARAM
  118. #endif
  119. if (!parser.seen("BST" J_PARAM XYZE_PARAM)) return;
  120. //planner.synchronize();
  121. if (parser.seen('B')) planner.settings.min_segment_time_us = parser.value_ulong();
  122. if (parser.seen('S')) planner.settings.min_feedrate_mm_s = parser.value_linear_units();
  123. if (parser.seen('T')) planner.settings.min_travel_feedrate_mm_s = parser.value_linear_units();
  124. #if ENABLED(JUNCTION_DEVIATION)
  125. if (parser.seen('J')) {
  126. const float junc_dev = parser.value_linear_units();
  127. if (WITHIN(junc_dev, 0.01f, 0.3f)) {
  128. planner.junction_deviation_mm = junc_dev;
  129. #if ENABLED(LIN_ADVANCE)
  130. planner.recalculate_max_e_jerk();
  131. #endif
  132. }
  133. else
  134. SERIAL_ERROR_MSG("?J out of range (0.01 to 0.3)");
  135. }
  136. #endif
  137. #if HAS_CLASSIC_JERK
  138. if (parser.seen('X')) planner.set_max_jerk(X_AXIS, parser.value_linear_units());
  139. if (parser.seen('Y')) planner.set_max_jerk(Y_AXIS, parser.value_linear_units());
  140. if (parser.seen('Z')) {
  141. planner.set_max_jerk(Z_AXIS, parser.value_linear_units());
  142. #if HAS_MESH && DISABLED(LIMITED_JERK_EDITING)
  143. if (planner.max_jerk.z <= 0.1f)
  144. SERIAL_ECHOLNPGM("WARNING! Low Z Jerk may lead to unwanted pauses.");
  145. #endif
  146. }
  147. #if !BOTH(JUNCTION_DEVIATION, LIN_ADVANCE)
  148. if (parser.seen('E')) planner.set_max_jerk(E_AXIS, parser.value_linear_units());
  149. #endif
  150. #endif
  151. }