Wiring up a laser to Ramps 1.4 with Marlin 2.1.1 on MPCNC

Preprocessor defines can get convoluted, but I believe this is the line that defines the laser pin for the ramps board:

#define SPINDLE_LASER_PWM_PIN 44 // Hardware PWM

And is found the file Marlin/src/pins/ramps/RAMPS.h.

The laser PWM pin must support PWM. On the Ramps/Mega board that will be pins 2 through 13, 44, 45, and 46. Looking at the pinout diagram for the Ramp board, the most likely candidates are on the servos block and highlighted in yellow:

image

Before making any firmware changes, I’d carefully test the PWM output of your selected replacement pin using M42 and a voltmeter. You should see the voltage vary between 0V and approximately 5V as you increase the PWM value from 0 to 255.

Avoid using pins 8, 9, and 10 since they will be at a higher voltage and be ground-side switched.

Also, you might want to consider how pin 44 is blown since if it is an underlying problem, you will blow the replacement pin as well.

So change the D44 reference to one of the pins in yellow?
Learning a lot here.
Can I use that test command in lightburn?

I mistakenly grounded pin 44.

define SPINDLE_LASER_PWM_PIN 6 // Hardware PWM

Correct? As an example

You need the ‘#’ at the beginning:

   #define SPINDLE_LASER_PWM_PIN             6  // Hardware PWM

Yes, missed that.

Well, partial success here. Pin 6 works with the laser menu but with lightburn no matter if I use m105/106, M3/5 or online commands. I’ll look at the gcode to be sure it contains correct start commands as noted above. I’m feeling better about this now.
Thanks for the help.
Forbes

So I need to put M3 I at the top of any gcode generated by Lightburn to insure inline operations?

Yes, M3 I is required starting with version 515. M3 should also work with Lightburn. It does for me. Also, the laser menu is not working for me in version 515 due to the safety timeout. I’m not sure why it is iworking for you. Are you sure you are modifying the latest V1 maintained Marlin firmware? Previous to 515, behaviors were different, though M3 should work in both versions.

I downloaded the latest 2.1.1 for Ramps. The lcd says 515s I believe.
I do get yellow warnings while compiling. Something like Ardodude or similar.
I’ll try compiling on another cpitee. I’m using the latest version of PlatformIO.
The warnings say something about using the latest version of something or other… I’m not at my machine at the moment.

I’m hoping I can get this working so I can go onto completing my build. So far so good.

Using pin 6 PWM yields steady power no matter the s value. M3 I command

You don’t say what command you are using to vary the value. Start by trying to control the pin with M42. It doesn’t require M3 I at the beginning of the file. See if you can get the pin to vary between 0V and around 5V with S parameters between 0 and 255.

Hello, thanks to this forum I was able to build the CNC with a 20 W Arduino Mega AtomStack M100 laser and Ramps 1.6 plus, and I wanted to provide some clarifications so that other users do not have problems, the default Marlin pin in its latest version is the pin 6, not 44. In the header file ramps.h it specifies it.
On the other hand, the Marlin laser control menu works correctly, it is used to test the laser by pulse. Greetings to all!!!

1 Like

Just came here to say that the safety laser turn off feature is indeed interfering with the laser menu.

Even if the safety is set to 1000 (ms), it doesn’t let you ANY pulses with the menu. I commented it completely and now it works.

How can you release a feature and not even test it properly?

1 Like

Who exactly are you directing that at?

This is an old thread, and to my knowledge there’s no issues with lasers.

While the thread may be old, the issue he is writing about is in the current V1 maintained versions of Marlin. The latest V1 releases (2.1.1 / 515) incorporated updated laser code that includes a safety timeout if the laser is not moved. According to reports, it does not play well with native Marlin display code for turning the laser on and off manually. It also interferes with g-code to manually turn on the laser (very low power) for positioning the origin of a job, though using M42 instead of M3 is a usable workaround.

1 Like

OH, we did fix that already right, we just have not bumped the stable release.

That is two firmware things the last few days. It might be time for a release bump.

1 Like

Ryan was this issue fixed ? I see V515d Marlin 2.1.1 is the latest ?

Thanks

That is all I know of this.

yes.