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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. #include "motion.h"
  28. #if HAS_BED_PROBE
  29. enum ProbePtRaise : uint8_t {
  30. PROBE_PT_NONE, // No raise or stow after run_z_probe
  31. PROBE_PT_STOW, // Do a complete stow after run_z_probe
  32. PROBE_PT_RAISE, // Raise to "between" clearance after run_z_probe
  33. PROBE_PT_BIG_RAISE // Raise to big clearance after run_z_probe
  34. };
  35. #endif
  36. class Probe {
  37. public:
  38. #if HAS_BED_PROBE
  39. static xyz_pos_t offset;
  40. static bool set_deployed(const bool deploy);
  41. #if IS_KINEMATIC
  42. #if HAS_PROBE_XY_OFFSET
  43. // Return true if the both nozzle and the probe can reach the given point.
  44. // Note: This won't work on SCARA since the probe offset rotates with the arm.
  45. static inline bool can_reach(const float &rx, const float &ry) {
  46. return position_is_reachable(rx - offset_xy.x, ry - offset_xy.y) // The nozzle can go where it needs to go?
  47. && position_is_reachable(rx, ry, ABS(MIN_PROBE_EDGE)); // Can the nozzle also go near there?
  48. }
  49. #else
  50. FORCE_INLINE static bool can_reach(const float &rx, const float &ry) {
  51. return position_is_reachable(rx, ry, MIN_PROBE_EDGE);
  52. }
  53. #endif
  54. #else
  55. /**
  56. * Return whether the given position is within the bed, and whether the nozzle
  57. * can reach the position required to put the probe at the given position.
  58. *
  59. * Example: For a probe offset of -10,+10, then for the probe to reach 0,0 the
  60. * nozzle must be be able to reach +10,-10.
  61. */
  62. static inline bool can_reach(const float &rx, const float &ry) {
  63. return position_is_reachable(rx - offset_xy.x, ry - offset_xy.y)
  64. && WITHIN(rx, min_x() - fslop, max_x() + fslop)
  65. && WITHIN(ry, min_y() - fslop, max_y() + fslop);
  66. }
  67. #endif
  68. #ifdef Z_AFTER_PROBING
  69. static void move_z_after_probing();
  70. #endif
  71. 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);
  72. 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) {
  73. return probe_at_point(pos.x, pos.y, raise_after, verbose_level, probe_relative, sanity_check);
  74. }
  75. #else
  76. static constexpr xyz_pos_t offset = xyz_pos_t({ 0, 0, 0 }); // See #16767
  77. static bool set_deployed(const bool) { return false; }
  78. FORCE_INLINE static bool can_reach(const float &rx, const float &ry) { return position_is_reachable(rx, ry); }
  79. #endif
  80. FORCE_INLINE static bool can_reach(const xy_pos_t &pos) { return can_reach(pos.x, pos.y); }
  81. FORCE_INLINE static bool good_bounds(const xy_pos_t &lf, const xy_pos_t &rb) {
  82. return (
  83. #if IS_KINEMATIC
  84. can_reach(lf.x, 0) && can_reach(rb.x, 0) && can_reach(0, lf.y) && can_reach(0, rb.y)
  85. #else
  86. can_reach(lf) && can_reach(rb)
  87. #endif
  88. );
  89. }
  90. // Use offset_xy for read only access
  91. // More optimal the XY offset is known to always be zero.
  92. #if HAS_PROBE_XY_OFFSET
  93. static const xyz_pos_t &offset_xy;
  94. #else
  95. static constexpr xy_pos_t offset_xy = xy_pos_t({ 0, 0 }); // See #16767
  96. #endif
  97. static inline bool deploy() { return set_deployed(true); }
  98. static inline bool stow() { return set_deployed(false); }
  99. #if HAS_BED_PROBE || HAS_LEVELING
  100. #if IS_KINEMATIC
  101. static constexpr float printable_radius = (
  102. #if ENABLED(DELTA)
  103. DELTA_PRINTABLE_RADIUS
  104. #elif IS_SCARA
  105. SCARA_PRINTABLE_RADIUS
  106. #endif
  107. );
  108. static inline float probe_radius() {
  109. return printable_radius - _MAX(MIN_PROBE_EDGE, HYPOT(offset_xy.x, offset_xy.y));
  110. }
  111. #endif
  112. static inline float min_x() {
  113. return (
  114. #if IS_KINEMATIC
  115. (X_CENTER) - probe_radius()
  116. #else
  117. _MAX((X_MIN_BED) + (MIN_PROBE_EDGE_LEFT), (X_MIN_POS) + offset_xy.x)
  118. #endif
  119. );
  120. }
  121. static inline float max_x() {
  122. return (
  123. #if IS_KINEMATIC
  124. (X_CENTER) + probe_radius()
  125. #else
  126. _MIN((X_MAX_BED) - (MIN_PROBE_EDGE_RIGHT), (X_MAX_POS) + offset_xy.x)
  127. #endif
  128. );
  129. }
  130. static inline float min_y() {
  131. return (
  132. #if IS_KINEMATIC
  133. (Y_CENTER) - probe_radius()
  134. #else
  135. _MAX((Y_MIN_BED) + (MIN_PROBE_EDGE_FRONT), (Y_MIN_POS) + offset_xy.y)
  136. #endif
  137. );
  138. }
  139. static inline float max_y() {
  140. return (
  141. #if IS_KINEMATIC
  142. (Y_CENTER) + probe_radius()
  143. #else
  144. _MIN((Y_MAX_BED) - (MIN_PROBE_EDGE_BACK), (Y_MAX_POS) + offset_xy.y)
  145. #endif
  146. );
  147. }
  148. #if NEEDS_THREE_PROBE_POINTS
  149. // Retrieve three points to probe the bed. Any type exposing set(X,Y) may be used.
  150. template <typename T>
  151. static inline void get_three_points(T points[3]) {
  152. #if HAS_FIXED_3POINT
  153. points[0].set(PROBE_PT_1_X, PROBE_PT_1_Y);
  154. points[1].set(PROBE_PT_2_X, PROBE_PT_2_Y);
  155. points[2].set(PROBE_PT_3_X, PROBE_PT_3_Y);
  156. #else
  157. #if IS_KINEMATIC
  158. constexpr float SIN0 = 0.0, SIN120 = 0.866025, SIN240 = -0.866025,
  159. COS0 = 1.0, COS120 = -0.5 , COS240 = -0.5;
  160. points[0].set((X_CENTER) + probe_radius() * COS0, (Y_CENTER) + probe_radius() * SIN0);
  161. points[1].set((X_CENTER) + probe_radius() * COS120, (Y_CENTER) + probe_radius() * SIN120);
  162. points[2].set((X_CENTER) + probe_radius() * COS240, (Y_CENTER) + probe_radius() * SIN240);
  163. #else
  164. points[0].set(min_x(), min_y());
  165. points[1].set(max_x(), min_y());
  166. points[2].set((max_x() - min_x()) / 2, max_y());
  167. #endif
  168. #endif
  169. }
  170. #endif
  171. #endif // HAS_BED_PROBE
  172. #if HAS_Z_SERVO_PROBE
  173. static void servo_probe_init();
  174. #endif
  175. #if QUIET_PROBING
  176. static void set_probing_paused(const bool p);
  177. #endif
  178. private:
  179. static bool probe_down_to_z(const float z, const feedRate_t fr_mm_s);
  180. static void do_z_raise(const float z_raise);
  181. static float run_z_probe(const bool sanity_check=true);
  182. };
  183. extern Probe probe;