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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../../inc/MarlinConfig.h"
  23. #include "../gcode.h"
  24. #include "../../module/motion.h"
  25. #include "../../module/stepper.h"
  26. #if ENABLED(M114_DETAIL)
  27. #if HAS_L64XX
  28. #include "../../libs/L64XX/L64XX_Marlin.h"
  29. #define DEBUG_OUT ENABLED(L6470_CHITCHAT)
  30. #include "../../core/debug_out.h"
  31. #endif
  32. void report_all_axis_pos(const xyze_pos_t &pos, const uint8_t n=LOGICAL_AXES, const uint8_t precision=3) {
  33. char str[12];
  34. LOOP_L_N(a, n) {
  35. SERIAL_CHAR(' ', axis_codes[a], ':');
  36. if (pos[a] >= 0) SERIAL_CHAR(' ');
  37. SERIAL_ECHO(dtostrf(pos[a], 1, precision, str));
  38. }
  39. SERIAL_EOL();
  40. }
  41. inline void report_linear_axis_pos(const xyze_pos_t &pos) { report_all_axis_pos(pos, XYZ); }
  42. void report_linear_axis_pos(const xyz_pos_t &pos, const uint8_t precision=3) {
  43. char str[12];
  44. LOOP_NUM_AXES(a) {
  45. SERIAL_CHAR(' ', AXIS_CHAR(a), ':');
  46. SERIAL_ECHO(dtostrf(pos[a], 1, precision, str));
  47. }
  48. SERIAL_EOL();
  49. }
  50. void report_current_position_detail() {
  51. // Position as sent by G-code
  52. SERIAL_ECHOPGM("\nLogical:");
  53. report_linear_axis_pos(current_position.asLogical());
  54. // Cartesian position in native machine space
  55. SERIAL_ECHOPGM("Raw: ");
  56. report_linear_axis_pos(current_position);
  57. xyze_pos_t leveled = current_position;
  58. #if HAS_LEVELING
  59. // Current position with leveling applied
  60. SERIAL_ECHOPGM("Leveled:");
  61. planner.apply_leveling(leveled);
  62. report_linear_axis_pos(leveled);
  63. // Test planner un-leveling. This should match the Raw result.
  64. SERIAL_ECHOPGM("UnLevel:");
  65. xyze_pos_t unleveled = leveled;
  66. planner.unapply_leveling(unleveled);
  67. report_linear_axis_pos(unleveled);
  68. #endif
  69. #if IS_KINEMATIC
  70. // Kinematics applied to the leveled position
  71. SERIAL_ECHOPGM(TERN(IS_SCARA, "ScaraK: ", "DeltaK: "));
  72. inverse_kinematics(leveled); // writes delta[]
  73. report_linear_axis_pos(delta);
  74. #endif
  75. planner.synchronize();
  76. #if HAS_L64XX
  77. char temp_buf[80];
  78. int32_t temp;
  79. //#define ABS_POS_SIGN_MASK 0b1111 1111 1110 0000 0000 0000 0000 0000
  80. #define ABS_POS_SIGN_MASK 0b11111111111000000000000000000000
  81. #define REPORT_ABSOLUTE_POS(Q) do{ \
  82. L64xxManager.say_axis(Q, false); \
  83. temp = L6470_GETPARAM(L6470_ABS_POS,Q); \
  84. if (temp & ABS_POS_SIGN_MASK) temp |= ABS_POS_SIGN_MASK; \
  85. sprintf_P(temp_buf, PSTR(":%8ld "), temp); \
  86. DEBUG_ECHO(temp_buf); \
  87. }while(0)
  88. DEBUG_ECHOPGM("\nL6470:");
  89. #if AXIS_IS_L64XX(X)
  90. REPORT_ABSOLUTE_POS(X);
  91. #endif
  92. #if AXIS_IS_L64XX(X2)
  93. REPORT_ABSOLUTE_POS(X2);
  94. #endif
  95. #if AXIS_IS_L64XX(Y)
  96. REPORT_ABSOLUTE_POS(Y);
  97. #endif
  98. #if AXIS_IS_L64XX(Y2)
  99. REPORT_ABSOLUTE_POS(Y2);
  100. #endif
  101. #if AXIS_IS_L64XX(Z)
  102. REPORT_ABSOLUTE_POS(Z);
  103. #endif
  104. #if AXIS_IS_L64XX(Z2)
  105. REPORT_ABSOLUTE_POS(Z2);
  106. #endif
  107. #if AXIS_IS_L64XX(Z3)
  108. REPORT_ABSOLUTE_POS(Z3);
  109. #endif
  110. #if AXIS_IS_L64XX(Z4)
  111. REPORT_ABSOLUTE_POS(Z4);
  112. #endif
  113. #if AXIS_IS_L64XX(I)
  114. REPORT_ABSOLUTE_POS(I);
  115. #endif
  116. #if AXIS_IS_L64XX(J)
  117. REPORT_ABSOLUTE_POS(J);
  118. #endif
  119. #if AXIS_IS_L64XX(K)
  120. REPORT_ABSOLUTE_POS(K);
  121. #endif
  122. #if AXIS_IS_L64XX(U)
  123. REPORT_ABSOLUTE_POS(U);
  124. #endif
  125. #if AXIS_IS_L64XX(V)
  126. REPORT_ABSOLUTE_POS(V);
  127. #endif
  128. #if AXIS_IS_L64XX(W)
  129. REPORT_ABSOLUTE_POS(W);
  130. #endif
  131. #if AXIS_IS_L64XX(E0)
  132. REPORT_ABSOLUTE_POS(E0);
  133. #endif
  134. #if AXIS_IS_L64XX(E1)
  135. REPORT_ABSOLUTE_POS(E1);
  136. #endif
  137. #if AXIS_IS_L64XX(E2)
  138. REPORT_ABSOLUTE_POS(E2);
  139. #endif
  140. #if AXIS_IS_L64XX(E3)
  141. REPORT_ABSOLUTE_POS(E3);
  142. #endif
  143. #if AXIS_IS_L64XX(E4)
  144. REPORT_ABSOLUTE_POS(E4);
  145. #endif
  146. #if AXIS_IS_L64XX(E5)
  147. REPORT_ABSOLUTE_POS(E5);
  148. #endif
  149. #if AXIS_IS_L64XX(E6)
  150. REPORT_ABSOLUTE_POS(E6);
  151. #endif
  152. #if AXIS_IS_L64XX(E7)
  153. REPORT_ABSOLUTE_POS(E7);
  154. #endif
  155. SERIAL_EOL();
  156. #endif // HAS_L64XX
  157. SERIAL_ECHOPGM("Stepper:");
  158. LOOP_LOGICAL_AXES(i) {
  159. SERIAL_CHAR(' ', axis_codes[i], ':');
  160. SERIAL_ECHO(stepper.position((AxisEnum)i));
  161. }
  162. SERIAL_EOL();
  163. #if IS_SCARA
  164. const xy_float_t deg = {
  165. planner.get_axis_position_degrees(A_AXIS),
  166. planner.get_axis_position_degrees(B_AXIS)
  167. };
  168. SERIAL_ECHOPGM("Degrees:");
  169. report_all_axis_pos(deg, 2);
  170. #endif
  171. SERIAL_ECHOPGM("FromStp:");
  172. get_cartesian_from_steppers(); // writes 'cartes' (with forward kinematics)
  173. xyze_pos_t from_steppers = LOGICAL_AXIS_ARRAY(
  174. planner.get_axis_position_mm(E_AXIS),
  175. cartes.x, cartes.y, cartes.z,
  176. planner.get_axis_position_mm(I_AXIS),
  177. planner.get_axis_position_mm(J_AXIS),
  178. planner.get_axis_position_mm(K_AXIS),
  179. planner.get_axis_position_mm(U_AXIS),
  180. planner.get_axis_position_mm(V_AXIS),
  181. planner.get_axis_position_mm(W_AXIS)
  182. );
  183. report_all_axis_pos(from_steppers);
  184. const xyze_float_t diff = from_steppers - leveled;
  185. SERIAL_ECHOPGM("Diff: ");
  186. report_all_axis_pos(diff);
  187. TERN_(FULL_REPORT_TO_HOST_FEATURE, report_current_grblstate_moving());
  188. }
  189. #endif // M114_DETAIL
  190. /**
  191. * M114: Report the current position to host.
  192. * Since steppers are moving, the count positions are
  193. * projected by using planner calculations.
  194. * D - Report more detail. This syncs the planner. (Requires M114_DETAIL)
  195. * E - Report E stepper position (Requires M114_DETAIL)
  196. * R - Report the realtime position instead of projected.
  197. */
  198. void GcodeSuite::M114() {
  199. #if ENABLED(M114_DETAIL)
  200. if (parser.seen_test('D')) {
  201. #if DISABLED(M114_LEGACY)
  202. planner.synchronize();
  203. #endif
  204. report_current_position();
  205. report_current_position_detail();
  206. return;
  207. }
  208. #if HAS_EXTRUDERS
  209. if (parser.seen_test('E')) {
  210. SERIAL_ECHOLNPGM("Count E:", stepper.position(E_AXIS));
  211. return;
  212. }
  213. #endif
  214. #endif
  215. #if ENABLED(M114_REALTIME)
  216. if (parser.seen_test('R')) { report_real_position(); return; }
  217. #endif
  218. TERN_(M114_LEGACY, planner.synchronize());
  219. report_current_position_projected();
  220. TERN_(FULL_REPORT_TO_HOST_FEATURE, report_current_grblstate_moving());
  221. }