My Marlin configs for Fabrikator Mini and CTC i3 Pro B
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

M913.cpp 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #include "../../../inc/MarlinConfig.h"
  23. #if ENABLED(HAVE_TMC2130) && ENABLED(HYBRID_THRESHOLD)
  24. #include "../../gcode.h"
  25. #include "../../../feature/tmc2130.h"
  26. #include "../../../module/planner.h"
  27. #include "../../../module/stepper_indirection.h"
  28. inline void tmc2130_get_pwmthrs(TMC2130Stepper &st, const char name, const uint16_t spmm) {
  29. SERIAL_CHAR(name);
  30. SERIAL_ECHOPGM(" stealthChop max speed set to ");
  31. SERIAL_ECHOLN(12650000UL * st.microsteps() / (256 * st.stealth_max_speed() * spmm));
  32. }
  33. inline void tmc2130_set_pwmthrs(TMC2130Stepper &st, const char name, const int32_t thrs, const uint32_t spmm) {
  34. st.stealth_max_speed(12650000UL * st.microsteps() / (256 * thrs * spmm));
  35. tmc2130_get_pwmthrs(st, name, spmm);
  36. }
  37. /**
  38. * M913: Set HYBRID_THRESHOLD speed.
  39. */
  40. void GcodeSuite::M913() {
  41. uint16_t values[XYZE];
  42. LOOP_XYZE(i)
  43. values[i] = parser.intval(axis_codes[i]);
  44. #if ENABLED(X_IS_TMC2130)
  45. if (values[X_AXIS]) tmc2130_set_pwmthrs(stepperX, 'X', values[X_AXIS], planner.axis_steps_per_mm[X_AXIS]);
  46. else tmc2130_get_pwmthrs(stepperX, 'X', planner.axis_steps_per_mm[X_AXIS]);
  47. #endif
  48. #if ENABLED(Y_IS_TMC2130)
  49. if (values[Y_AXIS]) tmc2130_set_pwmthrs(stepperY, 'Y', values[Y_AXIS], planner.axis_steps_per_mm[Y_AXIS]);
  50. else tmc2130_get_pwmthrs(stepperY, 'Y', planner.axis_steps_per_mm[Y_AXIS]);
  51. #endif
  52. #if ENABLED(Z_IS_TMC2130)
  53. if (values[Z_AXIS]) tmc2130_set_pwmthrs(stepperZ, 'Z', values[Z_AXIS], planner.axis_steps_per_mm[Z_AXIS]);
  54. else tmc2130_get_pwmthrs(stepperZ, 'Z', planner.axis_steps_per_mm[Z_AXIS]);
  55. #endif
  56. #if ENABLED(E0_IS_TMC2130)
  57. if (values[E_AXIS]) tmc2130_set_pwmthrs(stepperE0, 'E', values[E_AXIS], planner.axis_steps_per_mm[E_AXIS]);
  58. else tmc2130_get_pwmthrs(stepperE0, 'E', planner.axis_steps_per_mm[E_AXIS]);
  59. #endif
  60. }
  61. #endif // HAVE_TMC2130 && HYBRID_THRESHOLD