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.

delta.h 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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. * delta.h - Delta-specific functions
  24. */
  25. #ifndef __DELTA_H__
  26. #define __DELTA_H__
  27. extern float delta_endstop_adj[ABC],
  28. delta_radius,
  29. delta_diagonal_rod,
  30. delta_segments_per_second,
  31. delta_calibration_radius,
  32. delta_tower_angle_trim[ABC];
  33. extern float delta_tower[ABC][2],
  34. delta_diagonal_rod_2_tower[ABC],
  35. delta_clip_start_height;
  36. /**
  37. * Recalculate factors used for delta kinematics whenever
  38. * settings have been changed (e.g., by M665).
  39. */
  40. void recalc_delta_settings(const float radius, const float diagonal_rod, const float tower_angle_trim[ABC]);
  41. /**
  42. * Delta Inverse Kinematics
  43. *
  44. * Calculate the tower positions for a given logical
  45. * position, storing the result in the delta[] array.
  46. *
  47. * This is an expensive calculation, requiring 3 square
  48. * roots per segmented linear move, and strains the limits
  49. * of a Mega2560 with a Graphical Display.
  50. *
  51. * Suggested optimizations include:
  52. *
  53. * - Disable the home_offset (M206) and/or position_shift (G92)
  54. * features to remove up to 12 float additions.
  55. *
  56. * - Use a fast-inverse-sqrt function and add the reciprocal.
  57. * (see above)
  58. */
  59. #if ENABLED(DELTA_FAST_SQRT) && defined(__AVR__)
  60. /**
  61. * Fast inverse sqrt from Quake III Arena
  62. * See: https://en.wikipedia.org/wiki/Fast_inverse_square_root
  63. */
  64. float Q_rsqrt(float number);
  65. #define _SQRT(n) (1.0f / Q_rsqrt(n))
  66. #else
  67. #define _SQRT(n) SQRT(n)
  68. #endif
  69. // Macro to obtain the Z position of an individual tower
  70. #define DELTA_Z(T) raw[Z_AXIS] + _SQRT( \
  71. delta_diagonal_rod_2_tower[T] - HYPOT2( \
  72. delta_tower[T][X_AXIS] - raw[X_AXIS], \
  73. delta_tower[T][Y_AXIS] - raw[Y_AXIS] \
  74. ) \
  75. )
  76. #define DELTA_RAW_IK() do { \
  77. delta[A_AXIS] = DELTA_Z(A_AXIS); \
  78. delta[B_AXIS] = DELTA_Z(B_AXIS); \
  79. delta[C_AXIS] = DELTA_Z(C_AXIS); \
  80. }while(0)
  81. #define DELTA_LOGICAL_IK() do { \
  82. const float raw[XYZ] = { \
  83. RAW_X_POSITION(logical[X_AXIS]), \
  84. RAW_Y_POSITION(logical[Y_AXIS]), \
  85. RAW_Z_POSITION(logical[Z_AXIS]) \
  86. }; \
  87. DELTA_RAW_IK(); \
  88. }while(0)
  89. void inverse_kinematics(const float logical[XYZ]);
  90. /**
  91. * Calculate the highest Z position where the
  92. * effector has the full range of XY motion.
  93. */
  94. float delta_safe_distance_from_top();
  95. /**
  96. * Delta Forward Kinematics
  97. *
  98. * See the Wikipedia article "Trilateration"
  99. * https://en.wikipedia.org/wiki/Trilateration
  100. *
  101. * Establish a new coordinate system in the plane of the
  102. * three carriage points. This system has its origin at
  103. * tower1, with tower2 on the X axis. Tower3 is in the X-Y
  104. * plane with a Z component of zero.
  105. * We will define unit vectors in this coordinate system
  106. * in our original coordinate system. Then when we calculate
  107. * the Xnew, Ynew and Znew values, we can translate back into
  108. * the original system by moving along those unit vectors
  109. * by the corresponding values.
  110. *
  111. * Variable names matched to Marlin, c-version, and avoid the
  112. * use of any vector library.
  113. *
  114. * by Andreas Hardtung 2016-06-07
  115. * based on a Java function from "Delta Robot Kinematics V3"
  116. * by Steve Graves
  117. *
  118. * The result is stored in the cartes[] array.
  119. */
  120. void forward_kinematics_DELTA(float z1, float z2, float z3);
  121. FORCE_INLINE void forward_kinematics_DELTA(float point[ABC]) {
  122. forward_kinematics_DELTA(point[A_AXIS], point[B_AXIS], point[C_AXIS]);
  123. }
  124. bool home_delta();
  125. #endif // __DELTA_H__