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.

M200-M205.cpp 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 "../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. if (get_target_extruder_from_command()) return;
  34. if (parser.seen('D')) {
  35. // setting any extruder filament size disables volumetric on the assumption that
  36. // slicers either generate in extruder values as cubic mm or as as filament feeds
  37. // for all extruders
  38. if ( (parser.volumetric_enabled = (parser.value_linear_units() != 0.0)) )
  39. planner.set_filament_size(target_extruder, parser.value_linear_units());
  40. }
  41. planner.calculate_volumetric_multipliers();
  42. }
  43. #endif // !NO_VOLUMETRICS
  44. /**
  45. * M201: Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
  46. *
  47. * With multiple extruders use T to specify which one.
  48. */
  49. void GcodeSuite::M201() {
  50. GET_TARGET_EXTRUDER();
  51. LOOP_XYZE(i) {
  52. if (parser.seen(axis_codes[i])) {
  53. const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
  54. planner.max_acceleration_mm_per_s2[a] = parser.value_axis_units((AxisEnum)a);
  55. }
  56. }
  57. // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
  58. planner.reset_acceleration_rates();
  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. GET_TARGET_EXTRUDER();
  67. LOOP_XYZE(i)
  68. if (parser.seen(axis_codes[i])) {
  69. const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
  70. planner.max_feedrate_mm_s[a] = parser.value_axis_units((AxisEnum)a);
  71. }
  72. }
  73. /**
  74. * M204: Set Accelerations in units/sec^2 (M204 P1200 R3000 T3000)
  75. *
  76. * P = Printing moves
  77. * R = Retract only (no X, Y, Z) moves
  78. * T = Travel (non printing) moves
  79. *
  80. * Also sets minimum segment time in ms (B20000) to prevent buffer under-runs and M20 minimum feedrate
  81. */
  82. void GcodeSuite::M204() {
  83. if (parser.seen('S')) { // Kept for legacy compatibility. Should NOT BE USED for new developments.
  84. planner.travel_acceleration = planner.acceleration = parser.value_linear_units();
  85. SERIAL_ECHOLNPAIR("Setting Print and Travel Acceleration: ", planner.acceleration);
  86. }
  87. if (parser.seen('P')) {
  88. planner.acceleration = parser.value_linear_units();
  89. SERIAL_ECHOLNPAIR("Setting Print Acceleration: ", planner.acceleration);
  90. }
  91. if (parser.seen('R')) {
  92. planner.retract_acceleration = parser.value_linear_units();
  93. SERIAL_ECHOLNPAIR("Setting Retract Acceleration: ", planner.retract_acceleration);
  94. }
  95. if (parser.seen('T')) {
  96. planner.travel_acceleration = parser.value_linear_units();
  97. SERIAL_ECHOLNPAIR("Setting Travel Acceleration: ", planner.travel_acceleration);
  98. }
  99. }
  100. /**
  101. * M205: Set Advanced Settings
  102. *
  103. * S = Min Feed Rate (units/s)
  104. * T = Min Travel Feed Rate (units/s)
  105. * B = Min Segment Time (µs)
  106. * X = Max X Jerk (units/sec^2)
  107. * Y = Max Y Jerk (units/sec^2)
  108. * Z = Max Z Jerk (units/sec^2)
  109. * E = Max E Jerk (units/sec^2)
  110. */
  111. void GcodeSuite::M205() {
  112. if (parser.seen('S')) planner.min_feedrate_mm_s = parser.value_linear_units();
  113. if (parser.seen('T')) planner.min_travel_feedrate_mm_s = parser.value_linear_units();
  114. if (parser.seen('B')) planner.min_segment_time_us = parser.value_ulong();
  115. if (parser.seen('X')) planner.max_jerk[X_AXIS] = parser.value_linear_units();
  116. if (parser.seen('Y')) planner.max_jerk[Y_AXIS] = parser.value_linear_units();
  117. if (parser.seen('Z')) planner.max_jerk[Z_AXIS] = parser.value_linear_units();
  118. if (parser.seen('E')) planner.max_jerk[E_AXIS] = parser.value_linear_units();
  119. }