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.9KB

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