Advertisement
KirboWnz

Using_PWM_Tools.md

Sep 7th, 2023
1,979
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Smarty 2.41 KB | None | 0 0
  1. root@creality /usr/share [#] cat klipper/docs/Using_PWM_Tools.md
  2. # Using PWM tools
  3.  
  4. This document describes how to setup a PWM-controlled laser or spindle
  5. using `output_pin` and some macros.
  6.  
  7. ## How does it work?
  8.  
  9. With re-purposing the printhead's fan pwm output, you can control
  10. lasers or spindles.
  11. This is useful if you use switchable print heads, for example
  12. the E3D toolchanger or a DIY solution.
  13. Usually, cam-tools such as LaserWeb can be configured to use `M3-M5`
  14. commands, which stand for _spindle speed CW_ (`M3 S[0-255]`),
  15. _spindle speed CCW_ (`M4 S[0-255]`) and _spindle stop_ (`M5`).
  16.  
  17.  
  18. **Warning:** When driving a laser, keep all security precautions
  19. that you can think of! Diode lasers are usually inverted.
  20. This means, that when the MCU restarts, the laser will be
  21. _fully on_ for the time it takes the MCU to start up again.
  22. For good measure, it is recommended to _always_ wear appropriate
  23. laser-goggles of the right wavelength if the laser is powered;
  24. and to disconnect the laser when it is not needed.
  25. Also, you should configure a safety timeout,
  26. so that when your host or MCU encounters an error, the tool will stop.
  27.  
  28. For an example configuration, see [config/sample-pwm-tool.cfg](/config/sample-pwm-tool.cfg).
  29.  
  30. ## Current Limitations
  31.  
  32. There is a limitation of how frequent PWM updates may occur.
  33. While being very precise, a PWM update may only occur every 0.1 seconds,
  34. rendering it almost useless for raster engraving.
  35. However, there exists an [experimental branch](https://github.com/Cirromulus/klipper/tree/laser_tool) with its own tradeoffs.
  36. In long term, it is planned to add this functionality to main-line klipper.
  37.  
  38. ## Commands
  39.  
  40. `M3/M4 S<value>` : Set PWM duty-cycle. Values between 0 and 255.
  41. `M5` : Stop PWM output to shutdown value.
  42.  
  43. ## Laserweb Configuration
  44.  
  45. If you use Laserweb, a working configuration would be:
  46.  
  47.     GCODE START:
  48.         M5            ; Disable Laser
  49.         G21           ; Set units to mm
  50.         G90           ; Absolute positioning
  51.         G0 Z0 F7000   ; Set Non-Cutting speed
  52.  
  53.     GCODE END:
  54.         M5            ; Disable Laser
  55.         G91           ; relative
  56.         G0 Z+20 F4000 ;
  57.         G90           ; absolute
  58.  
  59.     GCODE HOMING:
  60.         M5            ; Disable Laser
  61.         G28           ; Home all axis
  62.  
  63.     TOOL ON:
  64.         M3 $INTENSITY
  65.  
  66.     TOOL OFF:
  67.         M5            ; Disable Laser
  68.  
  69.     LASER INTENSITY:
  70.         S
  71.  
  72.        
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement