My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

backlash.h 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. #include "../inc/MarlinConfigPre.h"
  24. #include "../module/planner.h"
  25. constexpr uint8_t all_on = 0xFF, all_off = 0x00;
  26. class Backlash {
  27. public:
  28. #if ENABLED(BACKLASH_GCODE)
  29. static xyz_float_t distance_mm;
  30. static uint8_t correction;
  31. #ifdef BACKLASH_SMOOTHING_MM
  32. static float smoothing_mm;
  33. #endif
  34. static inline void set_correction(const float &v) { correction = _MAX(0, _MIN(1.0, v)) * all_on; }
  35. static inline float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; }
  36. #else
  37. static constexpr uint8_t correction = (BACKLASH_CORRECTION) * 0xFF;
  38. static const xyz_float_t distance_mm;
  39. #ifdef BACKLASH_SMOOTHING_MM
  40. static constexpr float smoothing_mm = BACKLASH_SMOOTHING_MM;
  41. #endif
  42. #endif
  43. #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
  44. private:
  45. static xyz_float_t measured_mm;
  46. static xyz_uint8_t measured_count;
  47. public:
  48. static void measure_with_probe();
  49. #endif
  50. static inline float get_measurement(const AxisEnum a) {
  51. // Return the measurement averaged over all readings
  52. return (
  53. #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
  54. measured_count[a] > 0 ? measured_mm[a] / measured_count[a] :
  55. #endif
  56. 0
  57. );
  58. #if DISABLED(MEASURE_BACKLASH_WHEN_PROBING)
  59. UNUSED(a);
  60. #endif
  61. }
  62. static inline bool has_measurement(const AxisEnum a) {
  63. return (false
  64. #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
  65. || (measured_count[a] > 0)
  66. #endif
  67. );
  68. #if DISABLED(MEASURE_BACKLASH_WHEN_PROBING)
  69. UNUSED(a);
  70. #endif
  71. }
  72. static inline bool has_any_measurement() {
  73. return has_measurement(X_AXIS) || has_measurement(Y_AXIS) || has_measurement(Z_AXIS);
  74. }
  75. void add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const uint8_t dm, block_t * const block);
  76. };
  77. extern Backlash backlash;