I bought 20W (12V@1.6A
- so probably ~4W optical power) laser module and wanted to control it
using Ender 3 Pro equipped with "silent" 32 bit board - V4.2.7 from Creality.
Usually, laser is controlled by utilizing Ender's fan control output, which utilizes PWM.
Unfortunately, turns out the frequency of PWM signal is ~8 Hz by default, which may be fine for controlling DC motors in the fans, but surely is too low to control a laser.
Github user "cbagwell" proposed a way to modify Marlin firmware to increase PWM frequency to 1 kHz:
MarlinFirmware/Marlin#20642 (comment)
In case the original post gets deleted, I'll allow myself to copy the instruction here.
The following steps work just fine with Creality 4.2.7 board and Marlin v 2.1.2 sources.
Assuming you're dealing with Marlin 2.1.2 sources configured for Ender 3 (Pro):
- Comment out FAN_SOFT_PWM in Configuration.h
- Change FAN_MIN_PWM to 0 in Configuration_adv.h
- Uncomment FAST_PWM_FAN in Configuration_adv.h
- Change MF_TIMER_STEP from 5 to 4 in Marlin/src/HAL/STM32F1/timers.h
- Comment out FAN_SOFT_PWM_REQUIRED in Marlin/src/pins/stm32f1/pins_CREALITY_V4.h
- Change PA_0 from TIM2 to TIM5 in buildroot/share/PlatformIO/variants/MARLIN_F103Rx/PeripheralPins.c
- Uncomment #define LASER_SYNCHRONOUS_M106_M107 in Configuration_adv.h
After you upgrade the firmware (the process of compiling and upgrading is well described on the web, won't go into details here), PWM should operate at 1 kHz frequency. That's fine for laser, but not very fine for your cooling fans (hotend and motherboard) - they will heat up and whine while the laser is operating.
The best solution is to disconnect hotend fan, and connect motherboard fan permamently to 24V.
0-5 volt PWM signal for driving the laser module can be taken from gate of Q1 mosfet, since fan outputs operate at 24V, which may be too much for 12V laser modules.