My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

M3-M5.cpp 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #if HAS_CUTTER
  24. #include "../gcode.h"
  25. #include "../../feature/spindle_laser.h"
  26. #include "../../module/stepper.h"
  27. /**
  28. * M3 - Cutter ON (Clockwise)
  29. * M4 - Cutter ON (Counter-clockwise)
  30. *
  31. * S<power> - Set power. S0 turns it off.
  32. * O<ocr> - Set power and OCR
  33. *
  34. * If no PWM pin is defined then M3/M4 just turns it on.
  35. *
  36. * At least 12.8KHz (50Hz * 256) is needed for Spindle PWM.
  37. * Hardware PWM is required on AVR. ISRs are too slow.
  38. *
  39. * NOTE: WGM for timers 3, 4, and 5 must be either Mode 1 or Mode 5.
  40. * No other settings give a PWM signal that goes from 0 to 5 volts.
  41. *
  42. * The system automatically sets WGM to Mode 1, so no special
  43. * initialization is needed.
  44. *
  45. * WGM bits for timer 2 are automatically set by the system to
  46. * Mode 1. This produces an acceptable 0 to 5 volt signal.
  47. * No special initialization is needed.
  48. *
  49. * NOTE: A minimum PWM frequency of 50 Hz is needed. All prescaler
  50. * factors for timers 2, 3, 4, and 5 are acceptable.
  51. *
  52. * SPINDLE_LASER_ENA_PIN needs an external pullup or it may power on
  53. * the spindle/laser during power-up or when connecting to the host
  54. * (usually goes through a reset which sets all I/O pins to tri-state)
  55. *
  56. * PWM duty cycle goes from 0 (off) to 255 (always on).
  57. */
  58. void GcodeSuite::M3_M4(const bool is_M4) {
  59. planner.synchronize(); // Wait for previous movement commands (G0/G0/G2/G3) to complete before changing power
  60. cutter.set_direction(is_M4);
  61. #if ENABLED(SPINDLE_LASER_PWM)
  62. if (parser.seen('O'))
  63. cutter.set_ocr_power(parser.value_byte()); // The OCR is a value from 0 to 255 (uint8_t)
  64. else
  65. cutter.set_power(parser.intval('S', 255));
  66. #else
  67. cutter.set_enabled(true);
  68. #endif
  69. }
  70. /**
  71. * M5 - Cutter OFF
  72. */
  73. void GcodeSuite::M5() {
  74. planner.synchronize();
  75. cutter.set_enabled(false);
  76. }
  77. #endif // HAS_CUTTER