Having trouble with Z offset and material thickness

I am trying to use the z offset and material thickness features and having trouble with it crashing the z axis.

I have created a simple shape to engrave to help me troubleshoot. Below is the g-code from this simple shape.

Starting stream
G00 G17 G40 G21 G54
G91
M4
M8
G0 X0Y-16.875
G0 Z-15
Layer Cut
G1 X-17.32Y33.75S1000F1500
X34.641
X-17.321Y-33.75
G0 Z18
M9
G1 S0
M5
G0 Z-3
G0 X0Y16.875
M2
[MSG:Pgm End]
Stream completed in 0:09

The G0 Z-15 looks correct this would be my z offset 18 minus the material thickness of 3. But then it moves up 18 after cutting then moves down 3. Seems to me this should just move up the 15 after cutting.

The real numbers that I need to use are 26 for the z offset and 9 for the material thickness, with these numbers it crashes my z axis.

I could be going about setting this up incorrectly so if there is a guide on how to use this I would appreciate someone letting me know where to look.

Here are some screen shots of my setup.

The doc gives some of the details:

Absolute Z axis positioning requires:

  • Z axis home switch working
  • Z axis homed properly
  • Material at a fixed location from the home position

If Z homing doesn’t work or the material isn’t where the controller expects it, then the absolute positions can’t work. This seems to match what you’re seeing.

It may be more useful to use relative Z offsets with homing disabled and the zero point set to the material surface.

You can use absolute Z offsets if you manually home the axis at the surface of the material every time, which requires a “home” switch to sense the material. Ruida laser controllers with a focus probe work that way, but it’s not typical for CNC machines.

Thanks for the reply, I have the z axis homing and working properly. Maybe I am misunderstanding how the z offset is to be used. but I think the problem is in the way the g-code is being produced.

I think you can see the problem in the g-code that I posted above. it does the following,
starting off with the machine homed so z is at 0.

G0 Z-15
now z is at -15
this is the z-offset - the material thickness the correct height to cut the project. after cutting it raises the z the full z offset. if the material thickness is greater than the z axis pull off this will crash the z.
G0 Z18 now z is at +3 above zero

and then drops the material thickness
G0 Z-3

If the second step just raised the z the same amount that the first step dropped it it would be fine. So if my material thickness is greater than my z pull off amount it crashes. Perhaps I need to try emailing tech support.

This may be the difference between CNC-style homing and laser-style homing; GRBL does it CNC-style.

For example, my little Sherline mill (run with LinuxCNC, the reference for GRBL) homes by moving the spindle upward to a limit switch at the top of its travel. At that point the Z axis coordinate is set to the maximum Z axis travel, so that Z=0 is at the minimum travel and positive coordinates are above that level.

So a material thickness of 3 mm would be at Z=3.

In truth, I actually touch off the Z coordinate at the surface of the material to make Z=0 there, with all negative coordinates inside the workpiece.

If the Z axis homed downward and set Z=0 at the minimum position, that would almost work. However, the spindle would collide with the vise / workholders / material / whatever, with the undesirable consequences you’re describing.

So the fix may be to get homing working properly for laser-style operations. The Z axis should home away from the minimum point, so that it can never collide with anything, and set the Z coordinate to the maximum travel.

Then the material thickness corresponds to the actual Z coordinate at the top of the material, with negative motions into the material and positive motions away from it.

Something like that, anyway. GRBL doesn’t implement all of the LinuxCNC controls, but this is a deep dive into the details:

https://linuxcnc.org/docs/stable/html/config/ini-homing.html

Getting it right will give you a deep understanding of how all that stuff works, which is never a Bad Thing™.

This is the way my z axis is homing already. The z is not crashing into the workpiece it’s hitting the stop at the top of it’s travel.

Can you see from the g-code that is dropping the z axis -15mm to cut and then raising it 18mm when it’s done cutting? After that it goes does a z-3 for the material thicknesses. If the material thicknesses is more than the pull off setting the z crashes at it upper stop.

Thanks for your help, sorry if I am not saying this in a way that is clear.

You set Z 0 at the top, on the homing switch.
You command Z-15, and down it goes.
You then command Z18, moving it up 3mm past 0 Relative or 18mm past 0 Absolute.

Absolute or Relative positioning here will put Z past the Home switch. If you had travel limit switches enabled (6 switches, 3 used for Home too), you would have gotten an over-travel alarm instead of a crash.

With my CNC/Laser machine, I have to watch carefully what I am setting. I usually draw vertical lines on paper to illustrate Z motion. I home the machine, then lower Z to the focus point on the material and reset Z-zero. Then Lightburn can adjust Z for incremental moves while cutting. There should be no Z motion commanded for burning (etching).

Just out of curiosity, why are you not setting Z-zero at the surface of the work material? That would typically be either toot tip (CNC Mill) or laser focus (Laser Burner).

Laser-only machines are hard to screw it up with manual focus for Z settings.

To be clear about where you are saying ‘you command’, this is g-code that light burn produces when I draw a simple shape. This g-code was copied from the console and pasted into this message.

You are mostly correct. I have one limit switch per axis and I have soft limits enabled. My pull off is set to 5mm, when there is a travel move that would send the machine past this I do get an over travel alarm. I am oversimplifying this by saying ‘crashed’, I guess I was just trying to sort of simplify the conversation.

Is it not an option to do the following?
enable z moves
set the material thickness value for your material
set the z offset for your focus distance
home the machine
Let lightburn adjust the z axis accordingly and cut
It is doing all of this as I would expect, with the exception that raises the z-axis more than it just lowered it. You can see that lightburn tries to raise the z in 2 steps up 18 and then down 3 why not up15???

If it were not for what I think is a bug, you would only need to set your material thickness. The machine can home itself on startup, easy right?

So this leaves me asking the same question. Why would lightburn lower the axis from home then raise it by a greater amount? This sure seems like a bug to me. The g code is deliberately set to G91, how could moving down then moving a up greater not be a mistake?

Help me understand how the Z axis homing / offsets / coordinates / motions behave.

What is the maximum travel of the Z axis from the home position?

After homing and before starting LightBurn, where is the physical position of the laser head?

  • At the surface of the platform
  • At the top of the Z axis travel
  • Somewhere else

After homing and with G90 (absolute coordinates) in effect, where does G0 Z0 put the head?

  • At the surface of the platform
  • At the top of the Z axis travel
  • Somewhere else

With the head at that Z=0 position and G90 in effect, where does G0 Z5 put the head?

  • 5 mm above where it was (crash into home switch?)
  • 5 mm below where it was (crash into platform?)
  • no change

Then maybe I can visualize what’s going on …

I mentioned in the previous message that I have been saving crashed into the top of the z axis when I really should have said triggered the soft limits. I was just trying to keep it short.

Z-axis has 70mm of travel
The z axis homes in the positive direction, up.
Zero for Z 5mm below the point at it triggers the limit switch, in the position that the machiine comes to rest just after homing
G90 G0 Z5 would send it up and trigger the soft limit

Is it not reasonable for me to want to use the machine as follows?
Enable z moves
Set the material thickness value for my material
Set the z offset for your focus distance
Home the machine
Let lightburn adjust the z axis accordingly and cut

Because it is doing this. However I think that there is a bug in the g-code it produces, as it drops the laser head to the correct height to burn/cut then raises it too high and ‘crashes’ or actually it triggers the soft limit alarm.

If you look at the g-code generated by lightburn that I posted you can see that it sets incremental mode G91 then moves down 15mm then moves up 18mm and then does another z move down 3mm. How is this not a bug?

I do appreciate you trying to help. Does tech support monitor these forums? Is there a better place to report what I think is a bug?

If it’s due to a configuration setting for your machine that does not match what LightBurn expects, then it’s broken as designed. :grin:

The Material Thickness value indicates where the top of the material is above Z=0. You have Z=0 at the top of travel, with the material at the bottom, so a “thickness” of 3 mm tells LightBurn to travel 3 mm upward and crunch your switch.

I think things will work better if you conjure a GRBL offset (perhaps with G92) to put the Z=0 coordinate at the platform surface.

Then use the Material Thickness in the layer settings to put the focus on the material surface, 3 mm (or whatever) above Z=0.

Then the Z Offset and Z Step Per Pass settings will be relative to those values, above and below the material surface.

For comparison, Ruida controllers with autofocus put Z=0 at the material surface and prohibit negative coordinates, which prevents moving the focus into the material. The workaround is to “focus” at the platform (at the bottom of the material), then use the other settings as described.

This is tricky to get working, but I think you’re most of the way there.

The moves that are causing me trouble are in incremental G91 mode and I like using start from ‘current position’. So I don’t see how setting Z=0 at the platform surface does anything, right? Lightburn is not telling the machine to goto Z0 it is telling it to go down then up in relative terms. I can play around with Absolute Coordinates and see if I find a configuration that works.

Thanks again, I will keep working on it.

Is it possible to upload the LB file that is generating said GCodes? I follow what you are saying, and understand your question, but do not see why LB is commanding unexpected moves.

z test file.lbrn2 (9.8 KB)

Here is the file. If you want to reproduce it here are the settings that are probably important.

start from current position
z offset 16 mm, this set the focus above my material
material thickness 3mm (no crash) 5mm (crash)
XYZ are all set to 0 right after homing, but this should not effect the g91 based moves

I am curious to see if you see the same or similar movements. Does it move down then move up past where it started?

I am playing with ednisley’s suggestion of setting the z to honeycomb then using absolute coordinates. This suggestion does work well but I more accustomed to ‘start from current position’. Maybe I can just get used to working in absolute coordinates.

Thank you both for your help.

I keep thinking about this quote and it is brilliant in a lot of ways :grinning:

I going to start engraving ‘broken as designed’ on select items.

Thanks for the upload. I will look at it tomorrow.

Well, if it hurts when you do that, don’t do that. :grin:

One thing that might help: set up a camera to slap a view of the workspace on the monitor. Then you will switch to Absolute Coordinates and never go back.

Mulling it over, though, you may have found a corner case where the assumptions of 2D laser cutting collide with 3D CNC controllers.

In the XY plane, Start from current position is basically touching off the job origin at an XY position. Without digging into the code (and, lacking a G-Code laser, much of the motivation to do so), it looks like a G91 followed by coordinates relative to the XY Job Origin location and wherever the laser head was. You could probably do the same with either a G92 offset or setting up / switching to a different G5x coordinate system, but that doesn’t seem to be how it works.

However, G91 applies to all three axes. Unlike XY, Z has mechanical obstructions within the limits and behaves differently during operation. LightBurn seems to be running in 2.5 D mode, with Z tweaks that make sense in absolute mode with a known material position. Those tweaks basically don’t work in relative mode, but there’s no way to separate relative XY coordinates from the absolute Z coordinates.

So, yeah, don’t do that. :grin:

The file you supplied was not the one you used to generate the above code…

; LightBurn 1.4.00
; GRBL device profile, absolute coords
; Bounds: X38.58 Y28.5 to X65.42 Y51.75
G00 G17 G40 G21 G54
G90
M4
; Cut @ 1500 mm/min, 100% power
M8
G0 X52Y28.5
G0 Z-15
; Layer Cut
G1 X38.577Y51.75S1000F1500
G1 X65.423
G1 X52Y28.5
G0 Z3
M9
G1 S0
M5
G90
; return to user-defined finish pos
G0 X0 Y0
M2

As you can see, this file output a G90 and no Z18 command. Either this is not the file you used or you have been manually editing the NC code. Pick one.

If you are set to absolute coordinates you will not get the same g code. You need to set lightburn to ‘start from current location’ then it should produce the similar code.

I mentioned this when I poseted the file.

There is a screenshot with the code in my post above. You can see the code in the console window. You can see all the settings used to create the code. There is not any way for you to doubt this screenshot is there?

Don’t be so defensive. I am just trying to understand what you are doing. Unfortunately, those screen shots are a bit fuzzy (not sure if monitor or glasses!) and is difficult to read.

Having been a CNC Technician for lots of years, I tend to favor Absolute. The table is a graph paper and all moves are measured from 0,0. I worked with an engineer that worked Relative and he crashed machines more than once. Your LBRN2 file generated a nice neat NC code. Nothing strange, scary, or WTF in there. I tend to err on the side of least complicated because time is money and scrap is not.

I know I can’t change your mind, but you can. Be open to the options at your disposal. Listen to these guys; many earn a living with their lasers.
Soapbox: END