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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. /**
  24. * module/probe.h - Move, deploy, enable, etc.
  25. */
  26. #include "../inc/MarlinConfig.h"
  27. #if HAS_BED_PROBE
  28. enum ProbePtRaise : uint8_t {
  29. PROBE_PT_NONE, // No raise or stow after run_z_probe
  30. PROBE_PT_STOW, // Do a complete stow after run_z_probe
  31. PROBE_PT_RAISE, // Raise to "between" clearance after run_z_probe
  32. PROBE_PT_BIG_RAISE // Raise to big clearance after run_z_probe
  33. };
  34. #endif
  35. class Probe {
  36. public:
  37. #if HAS_BED_PROBE
  38. static xyz_pos_t offset;
  39. static bool set_deployed(const bool deploy);
  40. #ifdef Z_AFTER_PROBING
  41. static void move_z_after_probing();
  42. #endif
  43. static float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true, const bool sanity_check=true);
  44. static inline float probe_at_point(const xy_pos_t &pos, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true, const bool sanity_check=true) {
  45. return probe_at_point(pos.x, pos.y, raise_after, verbose_level, probe_relative);
  46. }
  47. #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
  48. static const char msg_wait_for_bed_heating[25];
  49. #endif
  50. #else
  51. static constexpr xyz_pos_t offset = xyz_pos_t({ 0, 0, 0 }); // See #16767
  52. static bool set_deployed(const bool) { return false; }
  53. #endif
  54. // Use offset_xy for read only access
  55. // More optimal the XY offset is known to always be zero.
  56. #if HAS_PROBE_XY_OFFSET
  57. static const xyz_pos_t &offset_xy;
  58. #else
  59. static constexpr xy_pos_t offset_xy = xy_pos_t({ 0, 0 }); // See #16767
  60. #endif
  61. static inline bool deploy() { return set_deployed(true); }
  62. static inline bool stow() { return set_deployed(false); }
  63. #if HAS_BED_PROBE || HAS_LEVELING
  64. #if IS_KINEMATIC
  65. static constexpr float printable_radius = (
  66. #if ENABLED(DELTA)
  67. DELTA_PRINTABLE_RADIUS
  68. #elif IS_SCARA
  69. SCARA_PRINTABLE_RADIUS
  70. #endif
  71. );
  72. static inline float probe_radius() {
  73. return printable_radius - _MAX(MIN_PROBE_EDGE, HYPOT(offset_xy.x, offset_xy.y));
  74. }
  75. #endif
  76. static inline float min_x() {
  77. return (
  78. #if IS_KINEMATIC
  79. (X_CENTER) - probe_radius()
  80. #else
  81. _MAX((X_MIN_BED) + (MIN_PROBE_EDGE_LEFT), (X_MIN_POS) + offset_xy.x)
  82. #endif
  83. );
  84. }
  85. static inline float max_x() {
  86. return (
  87. #if IS_KINEMATIC
  88. (X_CENTER) + probe_radius()
  89. #else
  90. _MIN((X_MAX_BED) - (MIN_PROBE_EDGE_RIGHT), (X_MAX_POS) + offset_xy.x)
  91. #endif
  92. );
  93. }
  94. static inline float min_y() {
  95. return (
  96. #if IS_KINEMATIC
  97. (Y_CENTER) - probe_radius()
  98. #else
  99. _MAX((Y_MIN_BED) + (MIN_PROBE_EDGE_FRONT), (Y_MIN_POS) + offset_xy.y)
  100. #endif
  101. );
  102. }
  103. static inline float max_y() {
  104. return (
  105. #if IS_KINEMATIC
  106. (Y_CENTER) + probe_radius()
  107. #else
  108. _MIN((Y_MAX_BED) - (MIN_PROBE_EDGE_BACK), (Y_MAX_POS) + offset_xy.y)
  109. #endif
  110. );
  111. }
  112. #if NEEDS_THREE_PROBE_POINTS
  113. // Retrieve three points to probe the bed. Any type exposing set(X,Y) may be used.
  114. template <typename T>
  115. static inline void get_three_points(T points[3]) {
  116. #if ENABLED(HAS_FIXED_3POINT)
  117. points[0].set(PROBE_PT_1_X, PROBE_PT_1_Y);
  118. points[1].set(PROBE_PT_2_X, PROBE_PT_2_Y);
  119. points[2].set(PROBE_PT_3_X, PROBE_PT_3_Y);
  120. #else
  121. #if IS_KINEMATIC
  122. constexpr float SIN0 = 0.0, SIN120 = 0.866025, SIN240 = -0.866025,
  123. COS0 = 1.0, COS120 = -0.5 , COS240 = -0.5;
  124. points[0].set((X_CENTER) + probe_radius() * COS0, (Y_CENTER) + probe_radius() * SIN0);
  125. points[1].set((X_CENTER) + probe_radius() * COS120, (Y_CENTER) + probe_radius() * SIN120);
  126. points[2].set((X_CENTER) + probe_radius() * COS240, (Y_CENTER) + probe_radius() * SIN240);
  127. #else
  128. points[0].set(min_x(), min_y());
  129. points[1].set(max_x(), min_y());
  130. points[2].set((max_x() - min_x()) / 2, max_y());
  131. #endif
  132. #endif
  133. }
  134. #endif
  135. #endif // HAS_BED_PROBE
  136. #if HAS_Z_SERVO_PROBE
  137. static void servo_probe_init();
  138. #endif
  139. #if QUIET_PROBING
  140. static void set_probing_paused(const bool p);
  141. #endif
  142. private:
  143. static bool probe_down_to_z(const float z, const feedRate_t fr_mm_s);
  144. static void do_z_raise(const float z_raise);
  145. static float run_z_probe(const bool sanity_check=true);
  146. };
  147. extern Probe probe;