"Plunge Safety Clearance" not working correctly

Hi all, I’ve just done a little tweak to the setup at work while trying to fix something which has revealed an unrelated issue.

The problem right now is that the “Plunge Safety Clearance” value being set isn’t being used, instead it’s using the pierce height in the same way (I think) it should be using the plunge safety clearance.

To be clear, it’s not going straight to the pierce. After a cut it’s going to the rapid clearance height, moving to the next cut location, diving blindly down to the value set by pierce height (I changed the pierce height to make sure it wasn’t using a value that happened to be the same as the pierce height, and the height it dived to changed as well to the new pierce height value), then starting the touch off code, then going to the pierce height and firing the torch etc.

It’s not a huge issue, but on thinner (warpier) and less flat material this can mean the torch hits the workpiece before starting the touch off procedure, leading to excess consumable wear etc.

I just updated to V7.0.19 to try and fix it, but no luck.

Here is my post processor (if relevant), I modified it from one of the GRBL ones I think to suit the machine we have at work

firstPierceTime = 0 --this is an extra delay added to the first pierce as needed by some machines

function OnAbout(event)
   ctrl = event:GetTextCtrl()
   ctrl:AppendText("GRBL plasma post processor\n")
   ctrl:AppendText("\n")
   ctrl:AppendText("Generic plasma post for machines with or without THC\n")
   ctrl:AppendText("\n")
   ctrl:AppendText("Modal G-codes and coordinates\n")
   ctrl:AppendText("No comments\n")
   ctrl:AppendText("M3/M5 turn the torch on/off\n")
   ctrl:AppendText("Incremental IJ\n")
end

post.ForceExtension("nc")
post.SetOptions(post.ARC_SEGMENTS)


function OnInit()

   post.SetCommentChars ("()", "[]")  --make sure ( and ) characters do not appear in system text
   if(scale == metric) then
      post.Text ("G21\n") --metric mode
      format = "0.0##"
   else
      post.Text ("G20\n") --inch mode
      format = "0.0###"
   end
   bigArcs = 1 --stitch arc segments together
   minArcSize = 0.05 --arcs smaller than this are converted to moves
   firstPierce = firstPierceTime
   oldFeed = -1
   post.Text ("G90\n")
   post.Text ("G92 X0 Y0 Z0\n")
end

function OnFinish()
   post.Text ("\nM11\nM5\n")
   post.Text ("\nG1 X0 Y0 Z15 F5000\n")
end

function OnRapid()
   post.Text ("G0")
   post.ModalNumber ("X", endX * scale, format)
   post.ModalNumber ("Y", endY * scale, format)
   post.ModalNumber ("Z", endZ * scale, format)
   post.Eol()
end

function OnMove()
   if oldFeed ~= feedRate then
      oldFeed = feedRate
      post.ModalNumber ("F", feedRate * scale, "0.0###")
      post.Eol()
   end
   post.Text ("G1")
   post.NonModalNumber ("X", endX * scale, format)
   post.NonModalNumber ("Y", endY * scale, format)
   post.ModalNumber ("Z", endZ * scale, format)
   post.Eol()
end

function OnArc()
   if oldFeed ~= feedRate then
      oldFeed = feedRate
      post.ModalNumber ("F", feedRate * scale, "0.0###")
      post.Eol()
   end
   if(arcAngle <0) then
      post.Text ("G3")
   else
      post.Text ("G2")
   end
   post.NonModalNumber ("X", endX * scale, format)
   post.NonModalNumber ("Y", endY * scale, format)
   post.ModalNumber ("Z", endZ * scale, format)
   post.Text ("I")
   post.Number ((arcCentreX - currentX) * scale, format)
   post.Text ("J")
   post.Number ((arcCentreY - currentY) * scale, format)
   post.ModalNumber ("F", feedRate * scale, "0.0###")
   post.Eol()
end


function OnPenDown()
   
   post.Text ("G4 P1000\n")
   post.Text ("\nM100\n")
   post.Text ("G4 P500\n")
   post.Text ("G30 Z0\n")
   post.Text ("G92 Z0\n")
   post.Text ("M101\n")
   post.Text ("G4 P1000\n")
   
   post.Text ("G1")
   post.NonModalNumber ("Z", pierceHeight * scale, format)
   post.Text ("\nM3\n")
   
   if (pierceDelay > 0.001) then
      post.Text ("G04 S")
      post.Number (pierceDelay + firstPierce,"0.###")
      firstPierce = 0
      post.Eol()
   end
   post.Text ("G1")
   
   post.NonModalNumber ("Z", cutHeight * scale, format)
   post.Text ("\nM10\n")
end


function OnPenUp()
   post.Text ("\nM11\nM5\n")
   if (endDelay > 0) then
      post.Text ("G4 S")
      post.Number (endDelay,"0.###")
      post.Eol()
   end
   post.Text ("G1 Z15\n")
end


function OnDrill()
   OnRapid()
   OnPenDown()
   endZ = drillZ
   OnMove()
   OnPenUp()
   endZ = safeZ
   OnRapid()
end

Here is a sample G Code file showing the issue. The problematic lines are marked with the -------. “Plunge Safety Clearance” is set to 25mm, But the 3mm “Pierce Height” variable from the tool is being used instead.

G21
G90
G92 X0 Y0 Z0
G0Z30.0			---------
G0X21.602Y-26.128	---------
G0Z3.0			---------
G4 P1000
M100
G4 P500
G30 Z0
G92 Z0
M101
G4 P1000
G1Z3.0
M3
G04 S0.5
G1Z1.6
M10
F1000.0
G1X21.602Y-26.128
F2500.0
G1X21.602Y-26.128
G3X26.128Y-26.128I2.263J2.263
G3X36.95Y0.0I-26.128J26.128
G3X0.0Y36.95I-36.95J-0.0
G3X-36.95Y0.0I0.0J-36.95
G3X0.0Y-36.95I36.95J-0.0
G3X23.923Y-28.161I-0.0J36.95
 M11 (On lead out)
F2475.0
G3X26.128Y-26.128I-23.923J28.161
G3X26.825Y-25.411I-26.128J26.128
 M11 (On lead out)
 M5 (On lead out)
G3X27.503Y-24.676I-26.825J25.411
G3X27.405Y-22.868I-0.953J0.855
M11
M5
G4 S2
G1 Z15
G0Z30.0			--------------
G0X72.09Y-67.564	--------------
G0Z3.0			--------------
G4 P1000
M100
G4 P500
G30 Z0
G92 Z0
M101
G4 P1000
G1Z3.0
M3
G04 S0.5
G1Z1.6
M10
F1000.0
G1X72.09Y-67.564
F2500.0
G1X72.09Y-67.564
G3X67.564Y-67.564I-2.263J-2.263
G2X0.0Y-95.55I-67.564J67.564
G2X-95.55Y0.0I-0.0J95.55
G2X0.0Y95.55I95.55J-0.0
G2X95.55Y0.0I0.0J-95.55
G2X69.652Y-65.41I-95.55J0.0
 M11 (On lead out)
F2475.0
G2X67.564Y-67.564I-69.652J65.41
G2X66.853Y-68.267I-67.564J67.564
 M11 (On lead out)
 M5 (On lead out)
G2X66.135Y-68.963I-66.853J68.267
G3X66.097Y-70.773I0.886J-0.924
M11
M5
G4 S2
G1 Z15
G0Z30.0
M11
M5
G1 X0 Y0 Z15 F5000

Thanks in advance for any help.

Just thought I’d share a hacky work around I came up with. I added to the post processor when the torch turns off, G1 Z30 and G92 Z0, so when it dives to what it thinks is the pierce height before probing, it is still at a safe height.

Sorry, I missed this thread. Plunge safety clearance is for milling/routing. It is not used for plasma. A slightly less hacky workaround is this:

function OnRapid()
   post.Text ("G0")
   post.ModalNumber ("X", endX * scale, format)
   post.ModalNumber ("Y", endY * scale, format)
   if(endZ ~= pierceHeight or currentZ ~= safeZ) then
      post.ModalNumber ("Z", endZ * scale, format)
   end
   post.Eol()
end

This will block the pierce height move before referencing.

Thanks!
Can I ask what scale does? Also is there any place I can find all of the variable names usable in the post processor, such as pierceHeight etc?

Scale converts it to whatever units you are using. SheetCam works in metric, but if you are using inches then it converts all measurements to inches. If you omit scale then everything is output in mm.
I believe there is a window that shows variables. I think there is a toolbar button that displays it.

There is a window/toolbar with a list of variables, but it’s blank for me unless I add some. I was wondering mostly about the ones used by the post like safeZ(?), pierceHeight etc. I’ve found some of them by just scrolling through post processors and experimenting with what each of them does, but a list of the default variables and what they correspond to would be great.

Just having some more issues with this. Your fixed solved it initially but now something else as cropped up, it dives to the pierce height again without probing, but only at the very start of a job. Something has changed overall with the start of the gcode, it used to go up to a safe Z height, move to the cut location, probe and cut as normal. Now it doesn’t move to a safe Z height, dives to pierce height, and then starts probing.

This only seems to happen at the very start of the gcode, not for each new cut or operation.

G21
G90
G92 X0 Y0 Z0
 (Part: NEW PART)
 (Operation: NEW OPP)
G0X25.0Y25.0
G0Z3.0 <<<PROBLEM LINE
G4 P1000
M100
G4 P500
G30 Z0
G92 Z0
M101
G4 P1000
G1Z3.0
M3
G04 S0.75
G1Z1.6
M10
F1000.0
G1X25.0Y25.0
F1500.0
G1X25.0Y25.0
G1X25.0Y25.0
 M11 (On small shapes)
F450.0
G3X33.45Y16.55I4.225J-4.225
G3X36.95Y25.0I-8.45J8.45
G3X25.0Y36.95I-11.95J0.0
G3X13.05Y25.0I0.0J-11.95
G3X25.0Y13.05I11.95J0.0
G3X33.45Y16.55I0.0J11.95
M11
M5
G4 S2
G0Z30.0
G0X47.592Y6.933
G0
G4 P1000
M100
G4 P500
G30 Z0
G92 Z0
M101
G4 P1000
G1Z3.0
M3
G04 S0.75
G1Z1.6
M10
F1000.0
G1X47.592Y6.933
F1500.0
G1X47.592Y6.933
G3X43.067Y6.933I-2.263J-2.263
G2X25.0Y-0.55I-18.067J18.067
G2X-0.55Y25.0I-0.0J25.55
G2X25.0Y50.55I25.55J-0.0
G2X50.55Y25.0I0.0J-25.55
 (Part: NEW PART)
G2X43.067Y6.933I-25.55J-0.0
 (Operation: NEW OPP)
M11
M5
G4 S2
G0Z30.0
G0X80.0Y25.0
G0
G4 P1000
M100
G4 P500
G30 Z0
G92 Z0
M101
G4 P1000
G1Z3.0
M3
G04 S0.75
G1Z1.6
M10
F1000.0
G1X80.0Y25.0
F1500.0
G1X80.0Y25.0
G1X80.0Y25.0
 M11 (On small shapes)
F450.0
G3X88.45Y16.55I4.225J-4.225
G3X91.95Y25.0I-8.45J8.45
G3X80.0Y36.95I-11.95J0.0
G3X68.05Y25.0I0.0J-11.95
G3X80.0Y13.05I11.95J0.0
G3X88.45Y16.55I0.0J11.95
M11
M5
G4 S2
G0Z30.0
G0X102.592Y6.933
G0
G4 P1000
M100
G4 P500
G30 Z0
G92 Z0
M101
G4 P1000
G1Z3.0
M3
G04 S0.75
G1Z1.6
M10
F1000.0
G1X102.592Y6.933
F1500.0
G1X102.592Y6.933
G3X98.067Y6.933I-2.263J-2.263
G2X80.0Y-0.55I-18.067J18.067
G2X54.45Y25.0I0.0J25.55
G2X80.0Y50.55I25.55J0.0
G2X105.55Y25.0I0.0J-25.55
G2X98.067Y6.933I-25.55J0.0
M11
M5
G4 S2
G0Z30.0
M11
M5
G1 X0 Y0 Z15 F5000

EDIT: Upon some playing around, it seems to be an issue with the specific post processor I modified, but I can’t find the line that’s doing it. It’s based off the “GRBL Plasma” post processor, other posts don’t seem to do it.
EDIT2: It’s being done by the onRapid function in the post (I commented out the Z portion of onRapid and it went away), so for some reason the if statement isn’t catching it on the first go, but is working on the rest of them.
EDIT3: The if statement works if I remove the “or currentZ ¬= safeZ”, probably related to the fact the machine for some reason doesn’t climb to a safe Z height at the start anymore. I added a move to safeZ in onInit, but it still doesn’t trigger on the first instance. I removed the or part of the if statement so that it never rapids to pierceHeight.

You can find the documentation in Options->machine->post processor->post documentation.

Change your test in OnRapid from currentZ ~= safeZ to currentZ < safeZ