Again this bloody Laser ;-D

Hi all, I guess 98% clicked already away, when it comes to this stupid Lasers again.

The very short version:

PWM is working, as soon an axis start to move it’s stopping.

Long-very long version:

Well, I start at the very beginning. I ordered pretty exactly 2 years ago a small NEJE Laser for my MPCNC #2 build in Thailand, back then I never got it to work. I can’t recall all the details, but in hindsight, it was probably just a grounding issue with the PWM signal. Then in between came a small inconvenience, called itself a pandemic.

On my MPCNC #1 build in Europe, I had a laser running well, after going through all the help from here, mainly this 400 post thread Laser engraving - not really getting great results

Meanwhile, a LR2 has replaced the MPCNC, all of them I have/had running with a MKS Gen 1.4 board. So with Christmas nearing, so are the requests for deco material. I got this laser I suspected death already out, and Ohh wonder, if connected correctly, it’s working. The neje_pwm.doc what I could download helped a lot.

I went through the above-mentioned thread again, and thought you got it once running so that will be just an afternoon b4 it’s running…….well, there would be probably no post here if the answer was yes.

First problem, My super accurate file management capabilities. It seems I had not a single Marlin firmware that would work with my build down in the garage. So I started from scrap, the only good thing is, I have enough spares (board, steppers, PSU) that I can start from scrap in the office. So I downloaded the latest (almost) firmware 2.0.7.2 https://github.com/V1EngineeringInc/MarlinBuilder/releases/download/510/V1CNC_Ramps_DualLR-2.0.7.2-src.zip

I tried to follow those steps working successfully more than 2 years ago, (link above) but hell, I did not even find this Marlin.cpp file anymore in this new build, searching for solutions in the web regarding PWM-laser, usually leads to pre 2.0 versions of Marlin.

I guess the most helpful thing was this link on Github. McUtty/Marlin2.0-Laser-with-M3-M4-M5-G-Code-for-Power: Marlin 2.0 optimised for Laser Engraver (1 X Axes Motor, 2 Y Axes Motors, Optional Z Axes) (github.com)

So the very few changes I did was actually in config_adv.h uncommenting (1486) #define SPINDLE_LASER_ENABLE, then I looked in pins_RAMPS.h the following entries.

(311) #define SPINDLE_LASER_ENABLE_PIN 4 // Pin should have a pullup/pulldown!

(312) #define SPINDLE_LASER_PWM_PIN 44 // MUST BE HARDWARE PWM

(313) #define SPINDLE_DIR_PIN 5

Originally the SPINDLE_LASER_PWM_PIN was on the Servo pin 6, so I left it untouched, and just connected my laser-pwm to Pin6 and that worked, well at least that’s what I thought. I was able to fire the laser in various intensities, but as soon I started a G-code file, I just saw the laser firing up a very short moment and stopped until the next section began. I was suspecting the G-code, but the behavior was the same if created with Estlcam or Lightburn.

I became suspicious and started the laser manually in Repetier-host, and it stays steady, but as soon I moved any axis, the PWM signal is down. Well I moved then to Pin44, I was thinking, Pin6 is used elsewhere in the code. Well, Pin44 is exact same behavior like Pin6 .

And that’s where I stand now, running out of ideas.



Marlins laser mode adjusts the laser with speed. So at speed 0, the power goes to zero. Maybe that is what’s happening? Try making a gcode script that sets the laser highish on a long fast move.

I think you can also set the power from the G1 command like:

G1 X100 F3000 S2000

If you’re using Repetier host to move the axis manually it’s probably using G0 rapid (non cutting) move commands. Laser mode turns the tool off during non cutting moves. You probably need to write or generate some gcode to get a true test.

Spindle mode leaves the tool on but has to lift to a safe height for non cutting moves, and pauses on rpm changes or tool on/off to let the bit settle at the desired speed. Laser responds immediately to on/off so no pause or Z height change is needed, significantly reducing overall job cut times.

As @jeffeb3 noted, laser mode also lowers intensity with axis motion speeds to avoid charring corners when the machine has to slow down to make the turn.

Well I tried some of those kind of commands, and it does absolutely nothing regarding PWM.
I uploaded that McUtty firmware, and that was working fine regarding the laser. So I thought just doing the small changes that it will match the LR will be OK.
The misery starts when I try enable the 2nd Z-axis, I looked around at Pins_RAMPS.h and the E0 (or E1??) stepper needs the Pin44.
So the compilation fails.
Well, I could probably rewire, or at least try to run G-code without Z.

So just a small update. I did rewire, so I use only one Z-Stepper driver. So far I just did tests with cutting. Using Estlcam as G-code generator, which I usually modify with a Text_Editor. Control is now M03/M05. I had a look at my old G-codes, when I had another Laser for a month, I used the D9 output, I remember I switched back to a 12V PS, as the Laser was 12V.
So far I didn’t try engraving, so I have not yet an idea what Marlin is doing in this regards, but as I understand, it’s not the same anymore when I tried the same with the Marlin 2.0 about 2 years ago.

The laser stuff is due for a revisit.

It is not easy to guide people as all the lasers being sold are slightly different.

Have a look at this thread to see is it helps you understand the way the firmware is currently set up. I need to take another look again because the laser stuff in the firmware is always getting messed with. I hope this is current. But as you can see it takes a while to dial it in, but not that it is cooling down here I can put it on my to-do list.