My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

probe.h 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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);
  74. }
  75. #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
  76. static const char msg_wait_for_bed_heating[25];
  77. #endif
  78. #else
  79. static constexpr xyz_pos_t offset = xyz_pos_t({ 0, 0, 0 }); // See #16767
  80. static bool set_deployed(const bool) { return false; }
  81. FORCE_INLINE static bool can_reach(const float &rx, const float &ry) { return position_is_reachable(rx, ry); }
  82. #endif
  83. FORCE_INLINE static bool can_reach(const xy_pos_t &pos) { return can_reach(pos.x, pos.y); }
  84. FORCE_INLINE static bool good_bounds(const xy_pos_t &lf, const xy_pos_t &rb) {
  85. return (
  86. #if IS_KINEMATIC
  87. can_reach(lf.x, 0) && can_reach(rb.x, 0) && can_reach(0, lf.y) && can_reach(0, rb.y)
  88. #else
  89. can_reach(lf) && can_reach(rb)
  90. #endif
  91. );
  92. }
  93. // Use offset_xy for read only access
  94. // More optimal the XY offset is known to always be zero.
  95. #if HAS_PROBE_XY_OFFSET
  96. static const xyz_pos_t &offset_xy;
  97. #else
  98. static constexpr xy_pos_t offset_xy = xy_pos_t({ 0, 0 }); // See #16767
  99. #endif
  100. static inline bool deploy() { return set_deployed(true); }
  101. static inline bool stow() { return set_deployed(false); }
  102. #if HAS_BED_PROBE || HAS_LEVELING
  103. #if IS_KINEMATIC
  104. static constexpr float printable_radius = (
  105. #if ENABLED(DELTA)
  106. DELTA_PRINTABLE_RADIUS
  107. #elif IS_SCARA
  108. SCARA_PRINTABLE_RADIUS
  109. #endif
  110. );
  111. static inline float probe_radius() {
  112. return printable_radius - _MAX(MIN_PROBE_EDGE, HYPOT(offset_xy.x, offset_xy.y));
  113. }
  114. #endif
  115. static inline float min_x() {
  116. return (
  117. #if IS_KINEMATIC
  118. (X_CENTER) - probe_radius()
  119. #else
  120. _MAX((X_MIN_BED) + (MIN_PROBE_EDGE_LEFT), (X_MIN_POS) + offset_xy.x)
  121. #endif
  122. );
  123. }
  124. static inline float max_x() {
  125. return (
  126. #if IS_KINEMATIC
  127. (X_CENTER) + probe_radius()
  128. #else
  129. _MIN((X_MAX_BED) - (MIN_PROBE_EDGE_RIGHT), (X_MAX_POS) + offset_xy.x)
  130. #endif
  131. );
  132. }
  133. static inline float min_y() {
  134. return (
  135. #if IS_KINEMATIC
  136. (Y_CENTER) - probe_radius()
  137. #else
  138. _MAX((Y_MIN_BED) + (MIN_PROBE_EDGE_FRONT), (Y_MIN_POS) + offset_xy.y)
  139. #endif
  140. );
  141. }
  142. static inline float max_y() {
  143. return (
  144. #if IS_KINEMATIC
  145. (Y_CENTER) + probe_radius()
  146. #else
  147. _MIN((Y_MAX_BED) - (MIN_PROBE_EDGE_BACK), (Y_MAX_POS) + offset_xy.y)
  148. #endif
  149. );
  150. }
  151. #if NEEDS_THREE_PROBE_POINTS
  152. // Retrieve three points to probe the bed. Any type exposing set(X,Y) may be used.
  153. template <typename T>
  154. static inline void get_three_points(T points[3]) {
  155. #if ENABLED(HAS_FIXED_3POINT)
  156. points[0].set(PROBE_PT_1_X, PROBE_PT_1_Y);
  157. points[1].set(PROBE_PT_2_X, PROBE_PT_2_Y);
  158. points[2].set(PROBE_PT_3_X, PROBE_PT_3_Y);
  159. #else
  160. #if IS_KINEMATIC
  161. constexpr float SIN0 = 0.0, SIN120 = 0.866025, SIN240 = -0.866025,
  162. COS0 = 1.0, COS120 = -0.5 , COS240 = -0.5;
  163. points[0].set((X_CENTER) + probe_radius() * COS0, (Y_CENTER) + probe_radius() * SIN0);
  164. points[1].set((X_CENTER) + probe_radius() * COS120, (Y_CENTER) + probe_radius() * SIN120);
  165. points[2].set((X_CENTER) + probe_radius() * COS240, (Y_CENTER) + probe_radius() * SIN240);
  166. #else
  167. points[0].set(min_x(), min_y());
  168. points[1].set(max_x(), min_y());
  169. points[2].set((max_x() - min_x()) / 2, max_y());
  170. #endif
  171. #endif
  172. }
  173. #endif
  174. #endif // HAS_BED_PROBE
  175. #if HAS_Z_SERVO_PROBE
  176. static void servo_probe_init();
  177. #endif
  178. #if QUIET_PROBING
  179. static void set_probing_paused(const bool p);
  180. #endif
  181. private:
  182. static bool probe_down_to_z(const float z, const feedRate_t fr_mm_s);
  183. static void do_z_raise(const float z_raise);
  184. static float run_z_probe(const bool sanity_check=true);
  185. };
  186. extern Probe probe;