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.

probe.h 5.0KB

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