Laser engraving - not really getting great results

M106- I can’t tell for sure, but I think the issue is we are not setting a fan_speed acceleration rate. I am not understanding it completely but in planner.h Block_t (what I think the fan speed is using). Since we do not have a acceleration value maybe it is just using whatever is already in the planner?

Planner.h lines 77-160

 

As for M3-5, there is a line that says synchronize. If you follow that it says “Block until all buffered steps are executed / cleaned” (planner.h line 731). So maybe that line comes out and it would work for a laser?

 

Or maybe this I am over thinking this. Marlin describes both M3 and M106 as “Wait for moves to complete, then set…” So maybe it is actually clearing the acceleration buffer and the next X or Y move seems as if it is starting from 0? That would force an acceleration. So to test this, a slower etch (with a lower power to give the same approx burn color) should show less acceleration darkening. Or set the Jerk or junction deviations really high to try and eliminate the accelerations…Dang, never easy. If this is the case we could possibly store the current acceleration/travel speed value, then send the m3 or M106, then reinstate the previous acceleration/travel speed value?

hmm. you are right.
M3 (doesn’t mattar is it M3 O or M3 S)/M5 call planner.synchronize();
M106 doesn’t.

so you may see a little stall at these commads.
difference between M3 O255/M3 O0 and M3 S255/M5 is that last one uses:

// Wait for spindle to come up to speed
inline void delay_for_power_up() { gcode.dwell(SPINDLE_LASER_POWERUP_DELAY); }

// Wait for spindle to stop turning
inline void delay_for_power_down() { gcode.dwell(SPINDLE_LASER_POWERDOWN_DELAY); }

and even if you set macro values to 0

and


/**
 * Dwell waits immediately. It does not synchronize. Use M400 instead of G4
 */
void GcodeSuite::dwell(millis_t time) {
  time += millis();
  while (PENDING(millis(), time)) idle();
}

to avoid call to idle() you have to set delay to -1
so probaly it’s easier to just use M3 O.

Block_t has fans speed:

 #if FAN_COUNT > 0
    uint8_t fan_speed[FAN_COUNT];
  #endif

but malin uses it only in
Planner::check_axes_activity()
lines 1181-1187

lines 1754 and 1185 of planner.cpp are only 2 points whene marlin does something with per-motion-block fans speeds

The stops might also be due to the gcode motion. I wonder if you took out the intermediate M106 commands if it would still pause. Maybe it’s not doing the motion planning itself right and it thinks those are corners or something.

David, can you post that gcode?

Jeff, I’m still using the exact same gcode files from before…

[attachment file=88629]

EDIT: It keeps incrementing the file attachment but it’s the same file(s) I shared back on the first page of this thread…

imagetogcode-2.zip (734 KB)

Oh, I didn’t realize it was in the same zip. Thanks.

[scode]
G1 X0 Y0.5
G1 Y0.6
M106 S231
G1 X0.1
M106 S144
G1 X0.2
M106 S52
G1 X0.3
M106 S1
G1 X0.9
M106 S3
G1 X1
M106 S1
G1 X74.6
M106 S2
G1 X74.7
M106 S75
G1 X74.8
M106 S167
G1 X74.9
M107
G1 X74.9 Y0.7 F3000
[/scode]
This is strange looking. It does a bunch of moves incrementing the power a little (X0.1 X0.2 X0.3 X0.9) and then it jumps from X1 to X74.6 and then ramps down (X74.6 X74.7 X74.8 X74.9). I think this segment must be for the border, because it’s drawing 75mm wide. If I jump into the middle of the file, I see a similar pattern on the individual squares:

[scode]
G1 X0 Y37.1
G1 Y37.2
M106 S233
G1 X0.1
M106 S143
G1 X0.2
M106 S51
G1 X0.3
M106 S2
G1 X0.4
M106 S3
G1 X0.5
M106 S1
G1 X0.6
M107
G1 X1.2 F3000
M106 S1
G1 X1.4
M106 S4
G1 X1.5
M106 S100
G1 X1.6
M106 S124
G1 X1.7
M106 S127
G1 X1.8
M106 S129
G1 X1.9
M106 S127
G1 X14.3
M106 S129
G1 X14.4
M106 S128
G1 X14.5
M106 S127
G1 X14.6
M106 S128
G1 X14.8
M106 S127
G1 X15
M106 S103
G1 X15.1
M106 S2
G1 X15.2
M107
G1 X15.4 F3000
M106 S1
G1 X15.5
M106 S2
G1 X15.6
M106 S1
G1 X16
M106 S4
G1 X16.1
M106 S26
G1 X16.2
M106 S87
G1 X16.3
M106 S117
G1 X29.5
M106 S118
G1 X29.6
M106 S111
G1 X29.7
M106 S85
G1 X29.8
M106 S16
G1 X29.9
M107
[/scode]

This is two blocks. But there are a lot of different points. It looks like image2gcode is trying to compensate for the acceleration of Marlin. That would work if it was using close to the same acceleration and jerk values. Marlin would also have to see these moves as continuous, and not try to stop on them.

Does anyone know if Marlin is actually doing a good job at determining when straight lines are a corner? I thought this was working, but I remember some gcode that made me think it wasn’t. I wonder if I should cook up some manual moves to see if it is working, both something like this:

G1 X0
G1 X10 F3000
G1 X20
G1 X30
G1 X40
G1 X50
G1 X60
G1 X70
G1 X80

G1 X0 F3000

and something like this:

G1 X0
G1 X0.1 F3000
G1 X0.2

G1 X79.9
G1 X80
G1 X0

In the second case, the buffer for the planner might be getting drained, so it doesn’t know it’s going to be going straight forever. In the first, I would be surprised if it stopped. I hope it’s easy enough to see (although temporarily making the acceleration really small should make it worse).

I’ll try these in a minute and see what it does.

marlin_test.zip (2.08 KB)

The motion_test.gcode went fine, but the buffer_test.gcode was very jerky. I think it’s starving the buffer in my test, although this is admittedly harder than the shades of gray one.

As I’m thinking about this though, that might not be image2gcode adjusting the acceleration as much as jpeg compression having artifacts on sharp transitions…

I will add some M106 codes to the motion_test and see if it’s still smooth I think that will give us some answers about the lasers.

This has laser_motion_test.gcode, which includes the fan commands every 10mm. It doesn’t pause at all. The fan commands aren’t causing accelerations (yay!?)

So I think this is about as close as we can hope for. I suspect:

  1. The start and stop of each row will always have the acceleration artifacts. At least until we have a laser mode in Marlin that will try to adjust the power when not at full speed.
  2. The ones in the middle are due to a starved buffer, so the planner can’t see that it’s still on a long straight line, so it slows down enough to never exceed the acceleration limits.
  3. The reason it’s starved is there are lots of 0.1mm moves in between the blocks, due to either the original image’s jpeg compression.

Does image2gcode support svgs? I wonder what the gcode and laser output would look like for an image like the Japanese flag?

https://upload.wikimedia.org/wikipedia/en/9/9e/Flag_of_Japan.svg

If it still has the 0.1mm moves, then maybe it’s a question for the author of image2gcode.

There are configuration values to increase the buffer size. I don’t think the 328p is that low of flash that a bigger buffer would hurt. Maybe Guffy would have some idea on that?

marlin_test-1.zip (2.36 KB)

Um. I took a video of the buffer_test.gcode, and I think I had too much coffee… It’s pretty hard to see how jerky the machine was when my arm was floating around all over the place.

As a side note. I fired up my laser again this morning before work. Bad idea I think. It was 15 Degrees Fahrenheit. I think I broke my laser module. It wouldn’t turn on for my second test. I worry the sitting cold then heat from running then cold again (with a cooling fan) may have cracked something on my Cheap 15 watt.

In any case I ran the Shades of Grey Gcode through Marlin 2.0 and 1.1.5. They both produced the same stop & Start movements. Even when I replaced M107 with M106 S0. So I was wrong about 1.1.5 not doing that. But something is still strange. Because I know for a fact that the Horse image I burned looked great. And it was constantly changing the laser power with M106 commands to get the grey scaling to change. So If the problem really is firmware then I somehow didn’t notice with that horse image.

I am suspect of the Shades of Grey Gcode. I agree with Jeff that it should have fewer M106 commands. it should be more uniform. I believe the varying shades are the product of the raster image sampling each pixel slightly differently but I would like to see a test file with fewer variables.

I don’t know why I didn’t think of this before. In my laser calibration gcode file the speed stays the same for each line it draws. But it is constantly increasing the laser power with M106 commands. And yet the results are a beautiful darker progression. No accelerations until the end of the line. If you look close you can see the darker edge where it is slowing to a stop before it ends the line.

 

1 Like

Just to be clear… this gcode was generated with Viktor’s “ImageToGcode” program, downloaded from here…

https://www.thingiverse.com/thing:2726163

The original image file is in this attachment

[attachment file=88648]

This was installed and run under Wine on my Mint 19 box. This was NOT the MPCNC-custom “Image2Gcode” program discussed “way back when” in this forum…

 

 

garfield-shades_of_gray-1.zip (33.3 KB)

1 Like

Yeah, that’s what I’m seeing is the behavior with 2.0 and the Marlin.cpp edits. I don’t have the laser working yet, but that’s the motion I’m seeing with the firmware configured for it.

These are the jpeg artifacts I’m talking about:

[attachment file=“screenshot-2019-02-11-1549898864.png”]

Jpeg compression has a hard time with hard edges (it low pass filters images, and discards high frequency information). The svg doesn’t have any compression, and it’s sharp no matter how far away you are. Things like cartoons, logos, text, and diagrams would keep that sharp edge in an svg format.

[attachment file=“screenshot-2019-02-11-1549898934.png”]

You could potentially trace the shades of gray image in inkscape, and it would smooth out those artifacts, and return the rectangles to sharp edges. You’d have to be careful with the settings to keep the shades the same though. I could work on something like that later.

Before we figured out the problem and a workaround, in all my attempts to print Garfield, I noticed that the jpeg artifacting was having an effect. It was making the laser run in places where it shouldn’t but at a power so low it had no effect anyway. During my straw grasping, I did some editing to the image to remove as much of the artifacting in the white space around Garfield as I could and generated new gcode with both Image To Gcode and Image2Gcode (one of those should really change their name). It helped with the burn time, eliminating unnecessary movements, but that was obviously the only thing it helped.

Neither “To” nor “2” will handle SVG files. The Jtech laser gcode plugin for Inkscape won’t handle the fill, just the paths.

Is there a free-ish program that will handle SVGs but also handle both the paths and fill?

EDIT: “50-shades-grey.zip” file added containing a SVG file.

 

50-shades-grey.zip (1.43 KB)

Awesome, M106 is a buffer issue, +the delay… There are some things we can try but, not being a fan acceleration makes my day, and means I am not a complete dodo for not finding it in Marlin. Silver lining I understand Marlin a little better.

1 Like

Aaryn, has been testing the heck out of all laser programs I have ever heard of. If there is one he is bound to find it!

1 Like

fan commands itself do nothing with the motion queue.

right

i dunno. have no experience in programming motions. i guess it’s similar case as 3d printing of linearized arc with big radius. it’s question to marlin authors.

i think that’s сommon property of all raster (but not only) images. maybe author of that application just issued a block of command per pixel and doesn’t try to optimize a line. but a lot of gradients is a nature of photo pictures, so bad and worst cases will be pretty frequent.
buffer is in RAM. it just 8KB. Block_t is relative big so by default the queue has just 16 blocks. i don’t think that expanding it to more then 32 is good idea.

I still vote for overscan instead of per line power ramping (just think it would be easier to implement). The ImageToGcode has a resolution setting, maybe there is a sweet spot, the default is 0.1, our lasers vary from 0.1-0.4 spot size typically, so maybe just decreasing that to 0.3 or 0.4 might really help and not have to resolution suffer.

I have an idea for victor, and his ImageToGcode. If he isn’t following along I can message him. As it is now in ImageToGcode you can etch the picture as is, which for this Garfield is over scanned kinda because it is in a white box. If you adjust this threshold you get an optimized etch. If we had one more control, perhaps “color threshold” and those of use that chose to “overscan” could by including a dummy background color. Almost like a fake greenscreen?