Unexplained G0 code before Layers

Using Snapmaker 40W and trying to just use User Origin as a starting point.

I set origin of machine and laser to bottom left, so why does it add a G0 command before the first layer ? Anybody any idea ? Specifically the G0 X-21.708Y0.134

G00 G17 G40 G21 G54
G90
G0 X0 Y0
G91
M4
; Scan @ 500 mm/min, 15% power
M8
G0 X-21.708Y0.134
; Layer C00 Pass 1 of 3
G1 X0.208F500S0
G1 X8.044S38.3

That’s the motion from wherever the laser head might be to the start of the first cutting / engraving vector.

The initial G00 with no XY parameters on the first line is basically a way of getting a known response from the controller without moving. A bare G0 has the side effect of presetting the motion mode, so you could just send X0 Y0 and have the machine move to the home coordinates; this tends to be surprising the first time you see it happen.

The G91 sets the controller to use relative coordinates, so the X-21.708 moves relative to the head’s current position. Presumably you have the origin set to more-or-less the middle of the platform, so the start of the first engraving line is offset from that position.

You can venture far into the G-Code rabbit hole:

https://linuxcnc.org/docs/stable/html/

I know it moves it. But why ?

It was supposed to move and burn from current position (origin set on machine) to up and right.

all relative commands seem correct.

But it adds that initial movement in the wrong direction ? In front of the comment it emits about the shape content. So why ?

EDIT: Laser: Start From: User Origin. But Absolute Mode (meant current position mode) does the same thing. Why move away from the current position before starting ?

re. the motion you reference in User Origin mode- LB is moving to the User Origin coordinate first, then it moves to the shape cut.

I don’t recall Absolute mode working this way, since that would have the control point moving to the X0Y0 position, which it does not do on my machine.

Sorry meant current position mode. and where the heck does lightburn read the “user origin” from ? I thought that the position stored on the device ?

In Current Position mode, LB is moving to the origin of the shape marked for cutting, depending on the 9 dot pattern you have set for that origin.

User Origin is set with a button in the Move window.

My use case for User Origin is as a temporary WCS XY zero position, but it is NOT stored in any controller WCS offset register as far as I know, certainly not in grbl. Its stored internal and exclusive to LB.

All I want is to start at the point in the lower left (as marked as origin) and have the laser start moving from that position (wherever i position it when starting)

Instead it adds some kind of initial offset I sadly do not understand yet.

It seems as though you should be using Absolute mode. What you see is what you get in that mode. No offsets.

But absolute mode would be relative to the machine. I obviously do not want that. I do not want to start in the bottom left of the machine.

In any case all I need to understand is what part of settings etc has influence on creating the line before the actual content

Use current position as you already did, but also enable “cut selected graphics” and “use selection origin”. Then, the origin of the selected object should be cut at the current position of the laser. I always do it like that. If that does not work, there might be some Snapmaker-specific gcode generation in between?

I assume:

  • The black and blue squares are on Fill layers
  • The settings for those layers include nonzero overscan and some small scanning interval

From your screenshot:

  • The Laser window shows it is set to Start From: Current Position
  • The origin is at the lower left corner of the black square

The laser head must move from its current position leftward to the start of the overscan region and slightly upward to the center of the first scan line, which is what this sequence does:

G91
G0 X-21.708Y0.134

The Preview window will show all those motions, with the first rapid motion going from the corner of the square to the start of the first engraving scan line.

The Preview shows it starts at the lower left. exactly where the origin is. but what is that ‘overscan’ position ? Why is it 2.1 cm ?

I thought it should be really easy (based on documentation) to align an item with the bottom left (the origin marker) to be the position on the laser when i start.

due to the unexplicable -2.1cm movement the left it leaves the region though.,
2.1 cm is more than the width of this test pattern.

PS: I did find a ‘laser offset’ in device settings (-21.60) but that does also not match up with -21.708.

I do not know what units you have set for the LightBurn workspace, but the squares appear to be 8 “units” on a side. My version of Lightburn allows the grid to be in either inches or millimeters (not centimeters), but your version may be different. I assume the squares are 8 mm (not cm) across.

That seems very small, but the Preview window shows the total cut distance is only 650-ish mm, which Is consistent with engraving a tiny square.

The layer settings control the overscan distance, but IIRC the default is 2.5% of the shape width, which would be about 0.2 mm.

Given the number of assumptions I’ve made, I’d say adding the offset to the overscan accounts for the initial move:

-21.708 ≅ -21.60 - 0.20

You can get the exact numbers from the layer settings and machine configurations, but AFAICT the machine is doing exactly what you told it to do.

It is, but if you want to understand the exact G-Code commands, you must first understand everything that happens between the simple geometry in the LightBurn layout and the laser beam hitting the material.

Whenever I find a disagreement between what’s obviously true and the machine’s actual behavior, at least some of my assumptions were wrong.

Think of it as a learning experience, because there’s plenty to learn!

Thanks for the input. In my initial test it moved way outside the box, afterwards I looked at the g-code, but maybe it was already overwritten with a new setup, I will doublecheck.

You are saying it has to move initially to compensate for the laser pointer offset + some overscan (overscan as in airbrushing where you start the movement slightly outside the target region). That sounds like a good explanation.

EDIT: When disabling laser offset i do get X-0.108Y0.122 so that would be the overscan indeed and the rest is the laser offset. Thanks

Did another test. Even worse sadly.

It moves half the range away in the opposite direction when running boundary. As if X and Y is offset by the size of the object. So origin being top right instead of bottom left.

You should upload the LightBurn file(s) you’re using for the tests, so that we can determine the actual settings, rather than trying to piece together what you may have done.

Last one I was working was this one.

Not finished, because i havent found out yet how to negate it, but it looks ok otherwise in the preview, when starting it on the snapmaker (after setting an orgin somewhere and pressing start) it moves left and down

Easter Makes Me Happy.lbrn2 (715.4 KB)

EDIT: Inverting was made more complicated due to the PNG having a transparent background instead of white. When i set it to white it worked as expected btw.

You had previously categorically rejected using Absolute Coordinates, but that’s what the file calls for. AIUI, the origin selection carries along with the file, not my setup here.

If using Absolute Coordinates was intentional:

  • Does the machine home correctly on startup?
  • Is an offset applied to the home position?
  • What are the coordinates of the home position?
  • Where is the home position located on the platform?
  • Where is the image positioned with respect to the home position?

If that change was not intentional, then something else is going on.

Until you understand how the various origin settings work, stick with a simple raster Fill layer: don’t complicate the situation with images. It makes showing what you’re trying to do much easier.