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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../../inc/MarlinConfig.h"
  23. #if ENABLED(BACKLASH_GCODE)
  24. #include "../../feature/backlash.h"
  25. #include "../../module/planner.h"
  26. #include "../gcode.h"
  27. /**
  28. * M425: Enable and tune backlash correction.
  29. *
  30. * F<fraction> Enable/disable/fade-out backlash correction (0.0 to 1.0)
  31. * S<smoothing_mm> Distance over which backlash correction is spread
  32. * X<distance_mm> Set the backlash distance on X (0 to disable)
  33. * Y<distance_mm> ... on Y
  34. * Z<distance_mm> ... on Z
  35. * X If a backlash measurement was done on X, copy that value
  36. * Y ... on Y
  37. * Z ... on Z
  38. *
  39. * Type M425 without any arguments to show active values.
  40. */
  41. void GcodeSuite::M425() {
  42. bool noArgs = true;
  43. auto axis_can_calibrate = [](const uint8_t a) {
  44. #define _CAN_CASE(N) case N##_AXIS: return AXIS_CAN_CALIBRATE(N);
  45. switch (a) {
  46. default: return false;
  47. MAIN_AXIS_MAP(_CAN_CASE)
  48. }
  49. };
  50. LOOP_NUM_AXES(a) {
  51. if (axis_can_calibrate(a) && parser.seen(AXIS_CHAR(a))) {
  52. planner.synchronize();
  53. backlash.set_distance_mm((AxisEnum)a, parser.has_value() ? parser.value_axis_units((AxisEnum)a) : backlash.get_measurement((AxisEnum)a));
  54. noArgs = false;
  55. }
  56. }
  57. if (parser.seen('F')) {
  58. planner.synchronize();
  59. backlash.set_correction(parser.value_float());
  60. noArgs = false;
  61. }
  62. #ifdef BACKLASH_SMOOTHING_MM
  63. if (parser.seen('S')) {
  64. planner.synchronize();
  65. backlash.set_smoothing_mm(parser.value_linear_units());
  66. noArgs = false;
  67. }
  68. #endif
  69. if (noArgs) {
  70. SERIAL_ECHOPGM("Backlash Correction ");
  71. if (!backlash.get_correction_uint8()) SERIAL_ECHOPGM("in");
  72. SERIAL_ECHOLNPGM("active:");
  73. SERIAL_ECHOLNPGM(" Correction Amount/Fade-out: F", backlash.get_correction(), " (F1.0 = full, F0.0 = none)");
  74. SERIAL_ECHOPGM(" Backlash Distance (mm): ");
  75. LOOP_NUM_AXES(a) if (axis_can_calibrate(a)) {
  76. SERIAL_ECHOLNPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_STR[a]), backlash.get_distance_mm((AxisEnum)a));
  77. }
  78. #ifdef BACKLASH_SMOOTHING_MM
  79. SERIAL_ECHOLNPGM(" Smoothing (mm): S", backlash.get_smoothing_mm());
  80. #endif
  81. #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
  82. SERIAL_ECHOPGM(" Average measured backlash (mm):");
  83. if (backlash.has_any_measurement()) {
  84. LOOP_NUM_AXES(a) if (axis_can_calibrate(a) && backlash.has_measurement(AxisEnum(a))) {
  85. SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_STR[a]), backlash.get_measurement((AxisEnum)a));
  86. }
  87. }
  88. else
  89. SERIAL_ECHOPGM(" (Not yet measured)");
  90. SERIAL_EOL();
  91. #endif
  92. }
  93. }
  94. void GcodeSuite::M425_report(const bool forReplay/*=true*/) {
  95. report_heading_etc(forReplay, F(STR_BACKLASH_COMPENSATION));
  96. SERIAL_ECHOLNPGM_P(
  97. PSTR(" M425 F"), backlash.get_correction()
  98. #ifdef BACKLASH_SMOOTHING_MM
  99. , PSTR(" S"), LINEAR_UNIT(backlash.get_smoothing_mm())
  100. #endif
  101. , LIST_N(DOUBLE(NUM_AXES),
  102. SP_X_STR, LINEAR_UNIT(backlash.get_distance_mm(X_AXIS)),
  103. SP_Y_STR, LINEAR_UNIT(backlash.get_distance_mm(Y_AXIS)),
  104. SP_Z_STR, LINEAR_UNIT(backlash.get_distance_mm(Z_AXIS)),
  105. SP_I_STR, I_AXIS_UNIT(backlash.get_distance_mm(I_AXIS)),
  106. SP_J_STR, J_AXIS_UNIT(backlash.get_distance_mm(J_AXIS)),
  107. SP_K_STR, K_AXIS_UNIT(backlash.get_distance_mm(K_AXIS)),
  108. SP_U_STR, U_AXIS_UNIT(backlash.get_distance_mm(U_AXIS)),
  109. SP_V_STR, V_AXIS_UNIT(backlash.get_distance_mm(V_AXIS)),
  110. SP_W_STR, W_AXIS_UNIT(backlash.get_distance_mm(W_AXIS))
  111. )
  112. );
  113. }
  114. #endif // BACKLASH_GCODE