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

Hi All.
I’ve successfully got my MPCNC running with X, Y and Z axis on Marlin 2.1.1 with a Ramps 1.4 board over an Arduino Mega 2560.
Next step is to get the laser to fire.
I have a 3 wire laser, red - apparently +12v, black - gnd and yellow for the signal TTL.
I have tested the laser with a fixed 12v input and one of the 5v pins on the RAMPS board and it fires up and smokes stuff - cool.
However I can’t work out where to connect the wires to programatically control the laser with Gcode, nor how to edit the marlin config files appropriately.
Any words of wisdom would be greatly received as the docs for Marlin, and other forums have left me a little bewildered.
Many thanks in advance.
Dan

You need to use inline laser commands, and the program needs to start with “M3 I”.

That turns on the laser, and inline commands. Best practice is to end your gcode with M5 as well.

Easy to add these things in something like lightburn.

I just checked, and laser support is enabled in the latest V1 firmware release (115) for the Ramps board. If you are running an older version of the firmware, you will need to either upgrade or enable the laser support in the source for your older version.

Assuming the defines are set the way I think they are, D44 is set up to be the laser pin. That is on Aux-2:

image

Since you already have your laser firing, this probably is not a problem, but if you are using a separate power supply for your laser, you also need a ground wire connecting the Rambo board to your laser.

And, as Ryan mentions, you need an M3 I at the beginning of any script where you want to use inline laser commands.

Hi,
I’ve installed the latest V1 version of Marlin, 2.11 515S and have not been able to get my NEJE 20 water, 5 optical, to fire using the laser function. It works fine with the NEJE test module so I know the laser is functioning. I’ve tried D44, D9 and other pins.
What am I doing wrong?
It used to work on my mini rambo and version 2.09…

Water = laser

Given the pin numbers you list, I’m guessing you have a Rambo board. Laser PWM is pin 45, not pin 44.

Version 515 of the firmware introduced a safety timeout. After 1 second of non-movement, the laser is turned off. Unfortunately, this interferes with turning the laser on using the laser menu. An easy workaround is to use M42 to set the state of pin 45.

Also, starting with this version of the firmware, you have to put the following at the top of your g-code files in order to use inline laser commands.

M3 I
1 Like

Hi. No, it’s a ramps 1.4
I flashed the hex firmware for the ramps as downloaded. I checked the pins file and it says D44. I’m going to try it without the NEJE power monitor board. Perhaps there is a ground issue with that. Just to make sure, as long as I use a ground pin on the board it’s considered grounded. Any ground pin or should I use the PS ground pin on the PS connector?
I did have it working on my minirambo using a modified 2.09 firmware.
Thanks for the rime and help.
Forbes

I use a ground pin on the board it’s considered grounded.

Correct.

I just a hobbyist with electronics, but if I were debugging your problem, the first thing I’d do is carefully connect a voltmeter to D44 and GND, and use M42 to set the PWM value of the pin. Try 255, 128, and 64. You should see approximately 5.0V, 2.5V and 1.25V. Assuming that works, connect the laser (power off first), and try M42 with the laser.

As mentioned in my previous post, the laser menu does not work (at least on my Rambo board). I get a brief flash, and then nothing. My theory is that the new safety timeout is turning the laser off.

You keep saying this, but you’ve answered almost every laser question in the last year or so. At some point, you’re the expert. You at least have my endorsement. :beers:

5 Likes

Thank you for the kind words. When you see this disclaimer in my posts, one of a few things are happening:

  • If the OP follows my advice. there is some risk to the electronics. I would take the risk, but beware.
  • I made up the answer in my head based on how I think the electronics work (with no education), therefore someone with actual electronics education might want to check my answer.
  • It is something I’ve done with an Arduino project, and I know it will work, but I don’t know if it is wise choice.

In this particular case, if Forbes shorts D44 to ground, even briefly, the pin is likely dead. Unlike the Rambo, Arduinos don’t survive pin shorts. I’ve burned out enough pins to know.

3 Likes

I like the idea that pin 44 needs to be checked for operation and isn’t in fact busted. Being a EE this makes a lot of sense. I’m new to the Arduino world as far as the electronics of the board IO. Assuming the pin is dead, I should look at assing another pin to be D44 or assign pin 42 to be the laser pin? Then perhaps put a diode in series with the laser trigger line to prevent the accidental grounding.
Or even a transistor as the trigger interface.
I’ll get this figured out and report the results.
Another question:. I need to also run a fan, control some lights when the machine is running and run auto leveling with a BL touch or similar.
Is Marlin 2.1.1 auto leveling capable?
Thanks to all and a very Merry Christmas to all. Enjoy Christmas with your families and friends.
Forbes

I looked at the Ramps 515 source (repeating what you’d already done) and verified that D44 was the assigned pin, and that laser support had been enabled. Previous versions for the Ramps (maintained by V1) did not have laser support enabled.

I checked the output of D44 with a dvm and it shows no change, just about .8 v or so. Guess the pin is fried. Any suggestions on another pin assignment?
Thank you

What command did you use to test it? I am not actually sure how to do quick test now that it is M3 I, that just enables it, you then need to trigger a fire and a move I think.

Before moving beyond pin 44, I would test the M42 command on other pins just to make sure you got the format right and other pins respond. The laser requires a pin capable of PWM. On the Mega, that is pins 2 through 13, 44, 45, and 46. Looking at the pinout for the Ramps 1.4 board, pins 4, 5, 6 and 11 are exposed on the Servos block. Be careful of pins 8, 9, and 10. They will switch the PWM on the ground side.

For lights, take a look at the Marlin case light interface. My guess is that you will need to enable and/or assign a pin in the firmware to make this work.

If you want to control fans, see M106/M107 g-code. The fan pins should be enabled in the V1 maintained version of Marlin.

As for bed leveling, see G29. It is possible you will have to set up what you want in configruation.h or configuration_adv.h.

Oh, and if pin 44 is dead, you might want to consider how it happened. If it is an ongoing problem, then you might burn out the next PWM you try.

1 Like

Last things first. I inadvertantly grounded pin 44 so that is why it’s dead.
Right now I need to concentrate on finding the best PWM pin. I’m hooking up scope app to monitor the D44 pin to be sure it is in fact fried.
Thanks for the info on my other questions.
Forbes/Dan

I use the laser menu to adjust power, turn laser on and off and the test fire. Basically I have used the laser menu to do all my testing.

The laser menu doesn’t work for me on the current Marlin version. I get a brief flash of laser then nothing. My theory is that the safety timeout is interfering with the menu. The safety timeout turns the laser off if there is no movement for 1 second (adjustable in the firmware). That is why I keep suggesting using M42 to test the pin, not the laser menu. There are some workarounds for keeping the laser on.

1 Like

Yeah, the M3 I part is new. The laser menu is old and worked with M105/6. That will not work for testing.

I have a Ramps 1.4 board on a Mega 2560.
I’m not sure what pin is laser on the current firmware hex file.
If I recompile, which ramps pins file do I use to change the laser pin as it appears D44 is fried.
Thanks and happy New Year.
Forbes