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.

M593.cpp 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2022 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. #if ENABLED(INPUT_SHAPING)
  24. #include "../../gcode.h"
  25. #include "../../../module/stepper.h"
  26. void GcodeSuite::M593_report(const bool forReplay/*=true*/) {
  27. report_heading_etc(forReplay, F("Input Shaping"));
  28. #if HAS_SHAPING_X
  29. SERIAL_ECHO_MSG("M593 X"
  30. " F", stepper.get_shaping_frequency(X_AXIS),
  31. " D", stepper.get_shaping_damping_ratio(X_AXIS)
  32. );
  33. #endif
  34. #if HAS_SHAPING_Y
  35. SERIAL_ECHO_MSG("M593 Y"
  36. " F", stepper.get_shaping_frequency(Y_AXIS),
  37. " D", stepper.get_shaping_damping_ratio(Y_AXIS)
  38. );
  39. #endif
  40. }
  41. /**
  42. * M593: Get or Set Input Shaping Parameters
  43. * D<factor> Set the zeta/damping factor. If axes (X, Y, etc.) are not specified, set for all axes.
  44. * F<frequency> Set the frequency. If axes (X, Y, etc.) are not specified, set for all axes.
  45. * T[map] Input Shaping type, 0:ZV, 1:EI, 2:2H EI (not implemented yet)
  46. * X<1> Set the given parameters only for the X axis.
  47. * Y<1> Set the given parameters only for the Y axis.
  48. */
  49. void GcodeSuite::M593() {
  50. if (!parser.seen_any()) return M593_report();
  51. const bool seen_X = TERN0(HAS_SHAPING_X, parser.seen_test('X')),
  52. seen_Y = TERN0(HAS_SHAPING_Y, parser.seen_test('Y')),
  53. for_X = seen_X || TERN0(HAS_SHAPING_X, (!seen_X && !seen_Y)),
  54. for_Y = seen_Y || TERN0(HAS_SHAPING_Y, (!seen_X && !seen_Y));
  55. if (parser.seen('D')) {
  56. const float zeta = parser.value_float();
  57. if (WITHIN(zeta, 0, 1)) {
  58. if (for_X) stepper.set_shaping_damping_ratio(X_AXIS, zeta);
  59. if (for_Y) stepper.set_shaping_damping_ratio(Y_AXIS, zeta);
  60. }
  61. else
  62. SERIAL_ECHO_MSG("?Zeta (D) value out of range (0-1)");
  63. }
  64. if (parser.seen('F')) {
  65. const float freq = parser.value_float();
  66. if (freq > 0) {
  67. if (for_X) stepper.set_shaping_frequency(X_AXIS, freq);
  68. if (for_Y) stepper.set_shaping_frequency(Y_AXIS, freq);
  69. }
  70. else
  71. SERIAL_ECHO_MSG("?Frequency (F) must be greater than 0");
  72. }
  73. }
  74. #endif