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.

M114.cpp 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. #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_DRIVER(L6470)
  28. //C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\gcode\host\M114.cpp
  29. //C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\module\bob_L6470.cpp
  30. #include "../../module/L6470/L6470_Marlin.h"
  31. #define DEBUG_OUT ENABLED(L6470_CHITCHAT)
  32. #include "../../core/debug_out.h"
  33. #endif
  34. void report_xyze(const float pos[], const uint8_t n = 4, const uint8_t precision = 3) {
  35. char str[12];
  36. for (uint8_t i = 0; i < n; i++) {
  37. SERIAL_CHAR(' ');
  38. SERIAL_CHAR(axis_codes[i]);
  39. SERIAL_CHAR(':');
  40. SERIAL_ECHO(dtostrf(pos[i], 8, precision, str));
  41. }
  42. SERIAL_EOL();
  43. }
  44. inline void report_xyz(const float pos[]) { report_xyze(pos, 3); }
  45. void report_current_position_detail() {
  46. SERIAL_ECHOPGM("\nLogical:");
  47. const float logical[XYZ] = {
  48. LOGICAL_X_POSITION(current_position[X_AXIS]),
  49. LOGICAL_Y_POSITION(current_position[Y_AXIS]),
  50. LOGICAL_Z_POSITION(current_position[Z_AXIS])
  51. };
  52. report_xyz(logical);
  53. SERIAL_ECHOPGM("Raw: ");
  54. report_xyz(current_position);
  55. float leveled[XYZ] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] };
  56. #if HAS_LEVELING
  57. SERIAL_ECHOPGM("Leveled:");
  58. planner.apply_leveling(leveled);
  59. report_xyz(leveled);
  60. SERIAL_ECHOPGM("UnLevel:");
  61. float unleveled[XYZ] = { leveled[X_AXIS], leveled[Y_AXIS], leveled[Z_AXIS] };
  62. planner.unapply_leveling(unleveled);
  63. report_xyz(unleveled);
  64. #endif
  65. #if IS_KINEMATIC
  66. #if IS_SCARA
  67. SERIAL_ECHOPGM("ScaraK: ");
  68. #else
  69. SERIAL_ECHOPGM("DeltaK: ");
  70. #endif
  71. inverse_kinematics(leveled); // writes delta[]
  72. report_xyz(delta);
  73. #endif
  74. planner.synchronize();
  75. #if HAS_DRIVER(L6470)
  76. char temp_buf[80];
  77. int32_t temp;
  78. //#define ABS_POS_SIGN_MASK 0b1111 1111 1110 0000 0000 0000 0000 0000
  79. #define ABS_POS_SIGN_MASK 0b11111111111000000000000000000000
  80. #define REPORT_ABSOLUTE_POS(Q) do{ \
  81. L6470.say_axis(Q, false); \
  82. temp = L6470_GETPARAM(L6470_ABS_POS,Q); \
  83. if (temp & ABS_POS_SIGN_MASK) temp |= ABS_POS_SIGN_MASK; \
  84. sprintf_P(temp_buf, PSTR(":%8ld "), temp); \
  85. DEBUG_ECHO(temp_buf); \
  86. }while(0)
  87. DEBUG_ECHOPGM("\nL6470:");
  88. #if AXIS_DRIVER_TYPE_X(L6470)
  89. REPORT_ABSOLUTE_POS(X);
  90. #endif
  91. #if AXIS_DRIVER_TYPE_X2(L6470)
  92. REPORT_ABSOLUTE_POS(X2);
  93. #endif
  94. #if AXIS_DRIVER_TYPE_Y(L6470)
  95. REPORT_ABSOLUTE_POS(Y);
  96. #endif
  97. #if AXIS_DRIVER_TYPE_Y2(L6470)
  98. REPORT_ABSOLUTE_POS(Y2);
  99. #endif
  100. #if AXIS_DRIVER_TYPE_Z(L6470)
  101. REPORT_ABSOLUTE_POS(Z);
  102. #endif
  103. #if AXIS_DRIVER_TYPE_Z2(L6470)
  104. REPORT_ABSOLUTE_POS(Z2);
  105. #endif
  106. #if AXIS_DRIVER_TYPE_Z3(L6470)
  107. REPORT_ABSOLUTE_POS(Z3);
  108. #endif
  109. #if AXIS_DRIVER_TYPE_E0(L6470)
  110. REPORT_ABSOLUTE_POS(E0);
  111. #endif
  112. #if AXIS_DRIVER_TYPE_E1(L6470)
  113. REPORT_ABSOLUTE_POS(E1);
  114. #endif
  115. #if AXIS_DRIVER_TYPE_E2(L6470)
  116. REPORT_ABSOLUTE_POS(E2);
  117. #endif
  118. #if AXIS_DRIVER_TYPE_E3(L6470)
  119. REPORT_ABSOLUTE_POS(E3);
  120. #endif
  121. #if AXIS_DRIVER_TYPE_E4(L6470)
  122. REPORT_ABSOLUTE_POS(E4);
  123. #endif
  124. #if AXIS_DRIVER_TYPE_E5(L6470)
  125. REPORT_ABSOLUTE_POS(E5);
  126. #endif
  127. SERIAL_EOL();
  128. #endif // HAS_DRIVER(L6470)
  129. SERIAL_ECHOPGM("Stepper:");
  130. LOOP_XYZE(i) {
  131. SERIAL_CHAR(' ');
  132. SERIAL_CHAR(axis_codes[i]);
  133. SERIAL_CHAR(':');
  134. SERIAL_ECHO(stepper.position((AxisEnum)i));
  135. }
  136. SERIAL_EOL();
  137. #if IS_SCARA
  138. const float deg[XYZ] = {
  139. planner.get_axis_position_degrees(A_AXIS),
  140. planner.get_axis_position_degrees(B_AXIS)
  141. };
  142. SERIAL_ECHOPGM("Degrees:");
  143. report_xyze(deg, 2);
  144. #endif
  145. SERIAL_ECHOPGM("FromStp:");
  146. get_cartesian_from_steppers(); // writes cartes[XYZ] (with forward kinematics)
  147. const float from_steppers[XYZE] = { cartes[X_AXIS], cartes[Y_AXIS], cartes[Z_AXIS], planner.get_axis_position_mm(E_AXIS) };
  148. report_xyze(from_steppers);
  149. const float diff[XYZE] = {
  150. from_steppers[X_AXIS] - leveled[X_AXIS],
  151. from_steppers[Y_AXIS] - leveled[Y_AXIS],
  152. from_steppers[Z_AXIS] - leveled[Z_AXIS],
  153. from_steppers[E_AXIS] - current_position[E_AXIS]
  154. };
  155. SERIAL_ECHOPGM("Differ: ");
  156. report_xyze(diff);
  157. }
  158. #endif // M114_DETAIL
  159. /**
  160. * M114: Report current position to host
  161. */
  162. void GcodeSuite::M114() {
  163. #if ENABLED(M114_DETAIL)
  164. if (parser.seen('D')) {
  165. report_current_position_detail();
  166. return;
  167. }
  168. #endif
  169. planner.synchronize();
  170. report_current_position();
  171. }