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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. /**
  23. * feature/z_stepper_align.cpp
  24. */
  25. #include "../inc/MarlinConfigPre.h"
  26. #if ENABLED(Z_STEPPER_AUTO_ALIGN)
  27. #include "z_stepper_align.h"
  28. #include "../module/probe.h"
  29. ZStepperAlign z_stepper_align;
  30. xy_pos_t ZStepperAlign::xy[NUM_Z_STEPPER_DRIVERS];
  31. #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
  32. xy_pos_t ZStepperAlign::stepper_xy[NUM_Z_STEPPER_DRIVERS];
  33. #endif
  34. void ZStepperAlign::reset_to_default() {
  35. #ifdef Z_STEPPER_ALIGN_XY
  36. constexpr xy_pos_t xy_init[] = Z_STEPPER_ALIGN_XY;
  37. static_assert(COUNT(xy_init) == NUM_Z_STEPPER_DRIVERS,
  38. "Z_STEPPER_ALIGN_XY requires "
  39. #if NUM_Z_STEPPER_DRIVERS == 4
  40. "four {X,Y} entries (Z, Z2, Z3, and Z4)."
  41. #elif NUM_Z_STEPPER_DRIVERS == 3
  42. "three {X,Y} entries (Z, Z2, and Z3)."
  43. #else
  44. "two {X,Y} entries (Z and Z2)."
  45. #endif
  46. );
  47. constexpr xyz_pos_t dpo = NOZZLE_TO_PROBE_OFFSET;
  48. #define LTEST(N) (xy_init[N].x >= _MAX(X_MIN_BED + MIN_PROBE_EDGE_LEFT, X_MIN_POS + dpo.x) - 0.00001f)
  49. #define RTEST(N) (xy_init[N].x <= _MIN(X_MAX_BED - MIN_PROBE_EDGE_RIGHT, X_MAX_POS + dpo.x) + 0.00001f)
  50. #define FTEST(N) (xy_init[N].y >= _MAX(Y_MIN_BED + MIN_PROBE_EDGE_FRONT, Y_MIN_POS + dpo.y) - 0.00001f)
  51. #define BTEST(N) (xy_init[N].y <= _MIN(Y_MAX_BED - MIN_PROBE_EDGE_BACK, Y_MAX_POS + dpo.y) + 0.00001f)
  52. static_assert(LTEST(0) && RTEST(0), "The 1st Z_STEPPER_ALIGN_XY X is unreachable with the default probe X offset.");
  53. static_assert(FTEST(0) && BTEST(0), "The 1st Z_STEPPER_ALIGN_XY Y is unreachable with the default probe Y offset.");
  54. static_assert(LTEST(1) && RTEST(1), "The 2nd Z_STEPPER_ALIGN_XY X is unreachable with the default probe X offset.");
  55. static_assert(FTEST(1) && BTEST(1), "The 2nd Z_STEPPER_ALIGN_XY Y is unreachable with the default probe Y offset.");
  56. #if NUM_Z_STEPPER_DRIVERS >= 3
  57. static_assert(LTEST(2) && RTEST(2), "The 3rd Z_STEPPER_ALIGN_XY X is unreachable with the default probe X offset.");
  58. static_assert(FTEST(2) && BTEST(2), "The 3rd Z_STEPPER_ALIGN_XY Y is unreachable with the default probe Y offset.");
  59. #if NUM_Z_STEPPER_DRIVERS >= 4
  60. static_assert(LTEST(3) && RTEST(3), "The 4th Z_STEPPER_ALIGN_XY X is unreachable with the default probe X offset.");
  61. static_assert(FTEST(3) && BTEST(3), "The 4th Z_STEPPER_ALIGN_XY Y is unreachable with the default probe Y offset.");
  62. #endif
  63. #endif
  64. #else // !defined(Z_STEPPER_ALIGN_XY)
  65. const xy_pos_t xy_init[] = {
  66. #if NUM_Z_STEPPER_DRIVERS >= 3 // First probe point...
  67. #if !Z_STEPPERS_ORIENTATION
  68. { probe.min_x(), probe.min_y() }, // SW
  69. #elif Z_STEPPERS_ORIENTATION == 1
  70. { probe.min_x(), probe.max_y() }, // NW
  71. #elif Z_STEPPERS_ORIENTATION == 2
  72. { probe.max_x(), probe.max_y() }, // NE
  73. #elif Z_STEPPERS_ORIENTATION == 3
  74. { probe.max_x(), probe.min_y() }, // SE
  75. #else
  76. #error "Z_STEPPERS_ORIENTATION must be from 0 to 3 (first point SW, NW, NE, SE)."
  77. #endif
  78. #if NUM_Z_STEPPER_DRIVERS == 4 // 3 more points...
  79. #if !Z_STEPPERS_ORIENTATION
  80. { probe.min_x(), probe.max_y() }, { probe.max_x(), probe.max_y() }, { probe.max_x(), probe.min_y() } // SW
  81. #elif Z_STEPPERS_ORIENTATION == 1
  82. { probe.max_x(), probe.max_y() }, { probe.max_x(), probe.min_y() }, { probe.min_x(), probe.min_y() } // NW
  83. #elif Z_STEPPERS_ORIENTATION == 2
  84. { probe.max_x(), probe.min_y() }, { probe.min_x(), probe.min_y() }, { probe.min_x(), probe.max_y() } // NE
  85. #elif Z_STEPPERS_ORIENTATION == 3
  86. { probe.min_x(), probe.min_y() }, { probe.min_x(), probe.max_y() }, { probe.max_x(), probe.max_y() } // SE
  87. #endif
  88. #elif !Z_STEPPERS_ORIENTATION // or 2 more points...
  89. { probe.max_x(), probe.min_y() }, { X_CENTER, probe.max_y() } // SW
  90. #elif Z_STEPPERS_ORIENTATION == 1
  91. { probe.min_x(), probe.min_y() }, { probe.max_x(), Y_CENTER } // NW
  92. #elif Z_STEPPERS_ORIENTATION == 2
  93. { probe.min_x(), probe.max_y() }, { X_CENTER, probe.min_y() } // NE
  94. #elif Z_STEPPERS_ORIENTATION == 3
  95. { probe.max_x(), probe.max_y() }, { probe.min_x(), Y_CENTER } // SE
  96. #endif
  97. #elif Z_STEPPERS_ORIENTATION
  98. { X_CENTER, probe.min_y() }, { X_CENTER, probe.max_y() }
  99. #else
  100. { probe.min_x(), Y_CENTER }, { probe.max_x(), Y_CENTER }
  101. #endif
  102. };
  103. #endif // !defined(Z_STEPPER_ALIGN_XY)
  104. COPY(xy, xy_init);
  105. #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
  106. constexpr xy_pos_t stepper_xy_init[] = Z_STEPPER_ALIGN_STEPPER_XY;
  107. static_assert(
  108. COUNT(stepper_xy_init) == NUM_Z_STEPPER_DRIVERS,
  109. "Z_STEPPER_ALIGN_STEPPER_XY requires "
  110. #if NUM_Z_STEPPER_DRIVERS == 4
  111. "four {X,Y} entries (Z, Z2, Z3, and Z4)."
  112. #elif NUM_Z_STEPPER_DRIVERS == 3
  113. "three {X,Y} entries (Z, Z2, and Z3)."
  114. #endif
  115. );
  116. COPY(stepper_xy, stepper_xy_init);
  117. #endif
  118. }
  119. #endif // Z_STEPPER_AUTO_ALIGN