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.

M425.cpp 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 ENABLED(BACKLASH_GCODE)
  24. #include "../../module/planner.h"
  25. float backlash_distance_mm[XYZ] = BACKLASH_DISTANCE_MM,
  26. backlash_correction = BACKLASH_CORRECTION;
  27. #ifdef BACKLASH_SMOOTHING_MM
  28. float backlash_smoothing_mm = BACKLASH_SMOOTHING_MM;
  29. #endif
  30. #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
  31. float backlash_measured_mm[XYZ] = { 0 };
  32. uint8_t backlash_measured_num[XYZ] = { 0 };
  33. #endif
  34. #include "../gcode.h"
  35. /**
  36. * M425: Enable and tune backlash correction.
  37. *
  38. * F<fraction> Enable/disable/fade-out backlash correction (0.0 to 1.0)
  39. * S<smoothing_mm> Distance over which backlash correction is spread
  40. * X<distance_mm> Set the backlash distance on X (0 to disable)
  41. * Y<distance_mm> ... on Y
  42. * Z<distance_mm> ... on Z
  43. * X If a backlash measurement was done on X, copy that value
  44. * Y ... on Y
  45. * Z ... on Z
  46. *
  47. * Type M425 without any arguments to show active values.
  48. */
  49. void GcodeSuite::M425() {
  50. bool noArgs = true;
  51. LOOP_XYZ(i) {
  52. if (parser.seen(axis_codes[i])) {
  53. planner.synchronize();
  54. const float measured_backlash = (
  55. #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
  56. backlash_measured_num[i] > 0 ? backlash_measured_mm[i] / backlash_measured_num[i] : 0
  57. #else
  58. 0
  59. #endif
  60. );
  61. backlash_distance_mm[i] = parser.has_value() ? parser.value_linear_units() : measured_backlash;
  62. noArgs = false;
  63. }
  64. }
  65. if (parser.seen('F')) {
  66. planner.synchronize();
  67. backlash_correction = MAX(0, MIN(1.0, parser.value_linear_units()));
  68. noArgs = false;
  69. }
  70. #ifdef BACKLASH_SMOOTHING_MM
  71. if (parser.seen('S')) {
  72. planner.synchronize();
  73. backlash_smoothing_mm = parser.value_linear_units();
  74. noArgs = false;
  75. }
  76. #endif
  77. if (noArgs) {
  78. SERIAL_ECHOPGM("Backlash correction is ");
  79. if (!backlash_correction) SERIAL_ECHOPGM("in");
  80. SERIAL_ECHOLNPGM("active:");
  81. SERIAL_ECHOPAIR(" Correction Amount/Fade-out: F", backlash_correction);
  82. SERIAL_ECHOLNPGM(" (F1.0 = full, F0.0 = none)");
  83. SERIAL_ECHOPGM(" Backlash Distance (mm): ");
  84. LOOP_XYZ(a) {
  85. SERIAL_CHAR(' ');
  86. SERIAL_CHAR(axis_codes[a]);
  87. SERIAL_ECHO(backlash_distance_mm[a]);
  88. SERIAL_EOL();
  89. }
  90. #ifdef BACKLASH_SMOOTHING_MM
  91. SERIAL_ECHOLNPAIR(" Smoothing (mm): S", backlash_smoothing_mm);
  92. #endif
  93. #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
  94. SERIAL_ECHOPGM(" Average measured backlash (mm):");
  95. LOOP_XYZ(a) {
  96. if (backlash_measured_num[a] > 0) {
  97. SERIAL_CHAR(' ');
  98. SERIAL_CHAR(axis_codes[a]);
  99. SERIAL_ECHO(backlash_measured_mm[a] / backlash_measured_num[a]);
  100. }
  101. }
  102. if (!backlash_measured_num[X_AXIS] && !backlash_measured_num[Y_AXIS] && !backlash_measured_num[Z_AXIS])
  103. SERIAL_ECHOPGM(" (Not yet measured)");
  104. SERIAL_EOL();
  105. #endif
  106. }
  107. }
  108. #endif // BACKLASH_GCODE