Now that I have the basic concept working, I thought I’d check out what the Marlin team is working on - since if there stuff is nearly working it didn’t make sense to clean up my project. I checked out this pull request (big update just 6 days ago)
LASER improvements pull request
And that took me to the development fork…
GitHub Marlin laser fork
I then did a merge of the MPCNC bugfix-2.0.x changes (which takes some work as Marlin has changed quite a few things) in Configuration.h, Configuration_adv.h and pins_RAMPS.h. Even then, it would not compile. Looks like they changed the name of a function (in status_screen_DOGM.cpp it references undefined ui8tostr3, that needs to changed to ui8tostr3rj). I also got linker errors, at least on Windows w/PlatformIO, that required I move the typedef for settings_laser_t out of the parent typedef (planner_settings_t) and into global scope and then it links and runs.
I then set up my oscilloscope to watch the laser PWM pin (which is D6) and the X stepper pin, and tried the M3 commands. To test, I set up a series of M3 commands to turn the laser ON/OFF, and move X and Y steppers to see how the signal works:
G92 X0 Y0 E0
M3 S0
G4 P1000
M3 S100
G1 X30 Y30 F2000
M3 S0
G1 X30 Y0
M3 S100
G1 X0 Y30
M3 S0
G1 X0 Y0
When I look at the scope, the laser pin is tightly aligned to the motion queue of the steppers, so that is great news.
However - the signal does not vary based on acceleration. It does align timing, but it does not change the pulse based on the overall speed of the gantry - it is a fixed burn signal. If no movement is in the queue and you use M3, the laser just turns on and sits there at power, further showing it isn’t monitoring movement speed.
UPDATE: This is wrong. If you use the new S parameter on G1 (G1 X10 Y10 S50, for example) the laser PWM changes with acceleration.
On a side note, either there is a bug or I have something misconfigured, because the pulse width never gets very wide, even at the full power setting. It varies in width between 0 and 4% duty cycle, but never above that. I’ve tried both percentage based (0-100) and PWM based (0-255) settings, with no change in pulse width.
Seeing as I’ve not yet powered up my laser, I’m wondering how much of the “laser problem” this solves? Other than Marlin soon having this “out of the box” (avoiding our hacks to get lasers working), is this any better than what we are already have? Is my approach for tracking extruder power and getting an accelerated power PWM worth finishing, or am I chasing a meaningless project?
UPDATE: So it feels like the external hardware solution is not worth completing. If anyone feels otherwise, please share your thoughts - else I’ll be dropping this project (was fun though for a couple days, and it really does work!)