[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.
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!):
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.