Software Chain for Laser Cutting

Actually, I would think that regex would be the only way to get a search and replace to do what needs done.

I generated some marlin-compatible gcode with the piclaser software to see what it looks like. Here’s a sample:

M106
M03
G1 X0 Y0
M105 S236
G1 X0 Y0
M105 S236
G1 X0 Y0
M105 S236
G1 X0 Y0
M105 S235
G1 X0 Y0
M105 S235
G1 X0 Y0
M105 S235
G1 X0 Y0
M105 S236
G1 X0 Y0

Note that each line with coordinates needs to have a G1 code. The GRBL code apparently doesn’t need it, since it looks like this:

G1

M3

X0Y102.42S143
X0.18S134
X0.36S135
X0.54S133
X0.72S118
X0.9S111
X1.08S97
X1.26S92

Just thought I’d point that out, since you’re looking at modifying the function to create gcode we can use with our marlin-based machines.

Thanks again!

Karl

I just double-checked something on JTP’s website. The command to turn the laser on is M106, not 105, and laser off is 107.

Yeah I mentioned that earlier. M106 and M107 are the fan control M codes. I don’t know what all the G1 X0 Y0 commands are sprinkled in for. Makes no sense. I’m just going to mod the code to use “M106 S” in place of just “S” and to replace the M05 at the end with an M107.

I’m not sure why all the commands were for x0 y0, but that is the format the gcode needs to be in - for example, G1 X99 Y45. I think any line that has movement has to have the G1 at the beginning, and spaces between the coordinates.

Sorry guys. My old laptop is slow as molasses and needed a bunch of windows updates. I decided to play xbox to kill time and kill time I did:) I just finished the code mods. Karl, I went ahead and added the G1 codes before the coordinate moves but I don’t think the white space is necessary. Please test and if this doesn’t work I’ll add the whitespace in too. Good luck all! Keep me posted.
The generated code will look like this:
M106 S0

G1 X0Y0 M106 S186
G1 X0.18 M106 S185
G1 X0Y0.18 M106 S184
G1 Y0.36 M106 S182
G1 X0.18Y0.18 M106 S181
G1 X0.36Y0 M106 S180
G1 X0.54
G1 X0.36Y0.18 M106 S178
G1 X0.18Y0.36 M106 S179
G1 X0Y0.54 M106 S180
G1 Y0.72 M106 S179
G1 X0.18Y0.54 M106 S177
G1 X0.36Y0.36
G1 X0.54Y0.18 M106 S176
G1 X0.72Y0 M106 S177

Vicious1: Hope you don’t mind the file attachment. It’s open source GNU license.

I don’t mind at all I’m glad to be following along.

I can’t hold out much longer, I’ll need a laser to try out all the hard work that has been done in these forums.

Thank you, for your work.

Leo, thanks for making those changes! I tested out some of the lines using the manual control window in Repetier Host, and it looks like the white space between the coordinates is necessary. Also, the M106 Sxxx needs to be on its own line. I don’t know if it needs to precede or follow the coordinates.

I’m looking forward to trying this out. Like Ryan said, thanks for all your work on this! You’re adding value to the MPCNC for all of us.

Karl

Ok I’ll work on it later. Are you sure this will do it? Have you tried sending these commands individually with a gcode sender? Did the laser respond to the M106?

I will go test those things on the MPCNC and laser right now.

Okay verified that M106 and M107 work. I ran this code, which ran as expected, burning diagonal lines at increasing intensity.

G91

M106 S50
G1 X20 Y20
M107

G1 X10

M106 S100
G1 X-20 Y-20
M107

G1 X10

M106 S150
G1 X20 Y20
M107

G1 X10

M106 S200
G1 X-20 Y-20
M107

G1 X10

M106 S255
G1 X20 Y20
M107

G90

Thanks for the code clip Karl. You’re right, with all the newline and whitespace requirements it would definitely require regex to parse through a gcode file. I didn’t realize Marlin was so picky about whitespace and newlines. Most interpreters ignore it because all the extra whitespace adds up to more bandwidth when transferring files but it does look cleaner.

The changes you need were a little tougher to make and I had to create a new function to handle the gcode and mcodes separately. I think it works ok and I did a quick test with both the horizontal and diagonal scanning options as well as the outline option .The resulting code looks like what you posted. I changed the title bar to call this an MPCNC-Jtech mod because I don’t want the original author getting hassled over any bugs that I may have introduced.

Please test and let’s follow up for everyone’s benefit. I’m happy to be a part of this…let’s burn something now!

3dpBurner-Image2GcodeMPCNC-Jtech.zip (165 KB)

So awesome that you’ve put in the effort for this - thanks to both you and villamany for the software.

I just got my driver current set, so I’m getting close to actually being able to burn something worthwhile. I am going to run a picture through your modified program so it will be ready when the machine is!

Karl

Great! Looking forward to seeing the result.

The image2gcode picture came out better than I ever expected - very nice, indeed! The black and white logo, which I did with Laser Etch, is over-burned. I’m not sure what I need to tweak to fix it, yet. Lower power and/or faster speed, I imagine.

All in all, I am very happy with my initial burns. I will edit some video and put it up later, but for now here are some pics:

Laser tool on MPCNC

Here’s the laser on its quick release mount with the target line lasers, cooling fan and terminal board for prototyping the connections.

Laser driver and wiring

The whole thing’s a bit of a mess, until I get the bugs worked out and then I can wire it up properly.

Lasing a picture

Here it is, lasing its first picture.

Finished picture burn

This was the first try ever at burning a picture - came out great! I used Leo’s modified version of image2gcode. Highly recommended! Thanks, Leo!

Overburn

This is the same logo I’ve cut multiple times with a router at different sizes. Something is wrong with this burn. I’ll try speeding it up and see what happens.

How do I embed pics inline with my text? I’m sure I’ve seen it done on here.

Oh well, for now, pics are attached.

The etched picture looks great!

Looks great Karl.From here it’s just minor tweaking of power, focus, and feedrate for best results but the grayscale pic looks good.

Ryan, now that Karl has tested the software, can you remove the non- working version from a few posts back? I don’t want anyone to download it if it won’t work with the mpcnc firmware. Thanks!

Done

Doesn’t it! And that was the very first try - for me, and for Leo’s modifications to villamany’s great program!

I re-ran the black and white logo through LaserEtch at 1000mm/min and it came out much better. Apparently the default is 200mm/min, which is way too slow, and I would have changed it had I noticed the first time. I wonder how fast I can push it and still get good results.

Ryan, how do I embed pictures in my posts?

Ryan:

So are you still planning to add a laser to your machine? If so, will it be Jtech or will you buy a Nichia 2.8w laser module and use a generic driver? I’m asking because I’d like to see more “poor man’s” solutions for an MPCNC laser add-on. If you’re planning to do this and document it then that’s awesome but if not then I’ll try to get it done. Only thing is that I don’t use Ramps on my MPCNC so I’d be able to demonstrate how good/equivalent the cheaper 2.8w laser works but wouldn’t be able to create a how-to for wiring,software, etc… What do you think?.