3D Laser Engraving with SmoothCarve

Hi folks,
[Could admin add the image links in please?]
I’ve had my blue box k40 laser setup with Smoothie for a couple of months now and one thing I couldn’t find a way to do was 3D engraving - varying the power along a line to create different depths of cut. This is normally controlled by a grayscale image where black = full power and white = minimum power.

Visicut is my controll software of choice and has an Engrave 3D mode but it only works for Epilog machines. I couldn’t immediately see anything else pertinent (except PicEngrave which is $$$), so I had a go at putting something together. I call it SmoothCarve:

Screenshot-2016-03-01-13.56.09.png

It’s fairly basic but, crucially, it does seem to work. Here’s my first attempt (feedrate was too slow, power too high etc., be kind!):

2016-03-01-11.26.16.jpg

Basically all it’s doing is scanning the input image line by line, pixel by pixel looking for where the gray value changes. Once it’s established the length of the gray that’s the same colour it produces a G code line to move the head that distance at the appropriate power rating for the gray value. At the beginning and end of each line it moves the head by the defined Acceleration Space at the same feedrate, this seems to give a more even cut than usign Viscut’s 2D engrave mode which starts the powe and the movement at the same time.

Here’s a sample of the gcode it produces:

G0 Y0.08
G1 X20 S0 F8000
G1 X7.68 S0.5
G1 X0.08 S0.492
G1 X0.08 S0.5
G1 X0.08 S0.496
G1 X0.08 S0.49
G1 X0.16 S0.5
G1 X0.08 S0.488
G1 X0.08 S0.5
G1 X0.08 S0.473
G1 X0.08 S0.19
G1 X0.08 S0.029
G1 X0.08 S0.057

The current program is written in Matlab, mainly because that’s what I had easily available and am currently most familiar with. Also it’s very easy and fast to work with large matrices in Matlab (it is a MATrix LABoratory, after all). There’s absolutely no error trapping or head tracking to prevent over-runs of the bed. Hell, it doesn’t even check to see if the output file already exists, just overwrites it without warning. It’s not pretty, but as I said it does work.

It’s been a fun little exercise to do. Unless there’s a better solution already out there I’d be interested in porting the code to something a bit more useable (C++ probably), as I don’t think my Matlab student license allows me to distribute the executable version of the code, so currenly it’s only of use to those that have access to Matlab.

Anyway, thought others may be interested in seeing the results, never thought I’d manage to do 3D engraving on my K40.

Cheers
koswix

Imported from wikidot

Hey there.

Great project ! Really love your results.

The latest version of Visicut now supports Smoothie ( though with a few bugs still ), and you should check out Laserweb, which does engraving too now.

About the Gcode :

G1 X0.08 S0.488
G1 X0.08 S0.5
G1 X0.08 S0.473
G1 X0.08 S0.19

These lines will be ignored, because there is no movement between then. You could probably clean things up by removing them.

Again, very nice result, I’ve seen raster engraving on K40s, but I think it’s the first time I see 3D “depth” engraving like this.

Cheers.

Hi Arthur,

The engraving is done in Relative mode (as it was easier on my maths skills :wink: ) so there is movement there. The 0.08mm move is actually the pixel size set in the GUI.

I’m on Visicut 1.7.9.something, I think 1.8 is on its way, but as far as I was aware the Engrave 3D function only worked for Epilogs (plus some old raster to gcode version for Lasersaur?), I’ll check again though.

I’ve also found that the single-power engraving on Visicut creates HUGE files, like 30MB or more, which take about a week to upload to smoothie over the network. The code for the above file came in at about 2MB on my one, I haven’t looked at how Visicut does the gcode but I wonder if it’s doing a code for every pixel, rather than grouping them into line movements?

As for LaserWeb - I do have it installed on my raspberry pi which is hooked up to my lasercutter, but I’ve found it to be buggy and crashy. Also taking a bitmap and converting it to gcode in laserweb on a Pi is not exactly fast. And then you have to recompute everything if you want to change the position… generally not keen on LaserWeb right now, but hopefully it will improve as it ages.

Can your software be found somewhere online so I can add it to the software list on the wiki ?

Thanks Arthur, that’d be great!

I’ve created a Git for the code. Also a friend with a full Matlab license has provided a standalone Windows executable (if you don’t have Matlab then you need to run the installer in the Releases section, it will download the required runtimes from Mathworks).

git hub slash koswix/SmoothCarve <— forgot I still can’t add links myself! d’oh!

Nice work koswix. I was planning to look at raster engraving with Smoothie. So far have just been getting myself used to Smoothie development by doing little things like a separate TTL pin and allowing the S range to be something other than 0 to 1.

I found that on my DC-K40 the laser behaves in a very non-linear way at the lower end. Below 4mA it doesn’t really want to fire at all and 4mA is definitely enough to remove rather than just darken wood if going for a 2D sort of engraving. Is yours similar or do we have very different PSUs?

Because of this non-linearity I was going to look at PPI control of the laser next. (See my other thread.) If you think this will be helpful I can make sure it operates well in conjunction with your work.

Thanks!

I have a two pin PSU (requires the fire pin to be pulled low and a PWM/TTL on a sepreate pin to set power level), but functionally it sounds similar to yours - below a certain threshold current is reached the tube effectively does nothing - actually I’ve found, after setting my minimum power to about 8% in smoothie config, that as the tube warms up this current does become enough to cause it to fire. Ruined a long multi-piece cut that way as about half way through the job I started getting ‘tracers’ between the end/start points :smiley:

What might be useful in my code is to add colour 255 (white) as a forced 0 power setting, and then scale 254-0 into the power range selected by the user.

I’ve been following your other thread with interest, I’d love to see PPI control on the Smoothie and if it can be made to work then it would be a much better solution for engraving. I’m in my final year at university at present (Mech Eng) so I don’t have much spare time to help out, in fact I really *shoudln’t* have spent as much time as I did getting SmoothCarve to work. But hey ho!

I wonder how far this will all get before Smoothie 2 becomes a reality and everyone gives up on the old boards. I’m currently playing with a National Instruments myRIO device (dual-core ARM Cortex-A9 processor and an Artix-7 FPGA) and it’s astounding the level, and speed, of signal processing you can do with these things. If Smoothie 2 comes anywhere near this performance it’ll be amazing!

Hey! You made it onto Hack-a-day. (I can’t link to it, of course. I’m sure you’ll find it.)