How to avoid Z lines in post processor

I’ve got a plasma cutter with particularly weak error handling. It has no Z control, and if lines are inserted with Z coordinates, the program will not load, and there is no error message - the program just fails silently. Further complicating the problem is the fact that empty lines (CR/LF) also cause the program to fail silently. Also “G00” by itself causes failure, etc. etc. etc. - you get the idea.

I’ve fixed this problem by eliminating rises/falls of the cutting head by specifying things correctly in the job settings - no Z lines are required, thus the post processor never sees them. However, I will be sending out the post processor to various people who may not be quite as up to speed on the issue and who will forget to eliminate Z specifications. I want to “idiot-proof” this a bit in the post-processor. I tried removing the Z lines, but the post-processor just put “G00” on a line by itself, which… causes failure.

Is there a way to eliminate Z moves entirely, so no lines at all are printed in the output of the post processor? A secondary solution would be to print a warning, but I tried checking if z>0 in the various routines and then printing a warning message, but apparently that condition is always true.

JT


function OnAbout(event)
ctrl = event:GetTextCtrl()
ctrl:AppendText(“HyCut Plasma - Modified Minimal G-Code - no Z, no line numbers, no feed\n”)
ctrl:AppendText(“\n”)
ctrl:AppendText(“Min spec g-code for compatibility with as many controllers as possible\n”)
ctrl:AppendText(“Non modal G-codes\n”)
ctrl:AppendText(“Modal coordinates\n”)
ctrl:AppendText(“No comments\n”)
ctrl:AppendText(“Incremental IJ\n”)
ctrl:AppendText(“G-codes used (only these are understood):\n”)
ctrl:AppendText(“G00,G01,G02,G03,G70,G71,G90,G91,G40,G41,G42,G28\n”)
ctrl:AppendText(“M-codes used (only these are understood):\n”)
ctrl:AppendText(“M02,M07,M08\n”)
end



– revision May 8 2011 jtodd@loligo.com - created from Modified Minimal G-Code for HyCut Plasma
– Note: HyCut cannot understand Z, and will NOT load code if Z lines present - eliminate them by
– making no plunge or rapid height in your job spec. There should be no “Z” characters
– in your final code.
– Note: HyCut extremely sensitive to non-understood codes, spurious spaces, etc.

– This file should be named “HyCut.scpost” and put in c:\Documents and Settings\Administrator\Application Data\SheetCam TNG Development\posts
– (change file path to match where your SheetCam system stores post-processors)


function OnInit()
post.SetCommentChars (“()”, “”) --make sure ( and ) characters do not appear in system text
if(scale == metric) then
post.Text (“G21\n”) --metric mode
else
post.Text (“G20\n”) --inch mode
end
post.Text (“G92X0Y0\n”) – start us out at zero, wherever we’re placed on the table
bigArcs = 1 --stitch arc segments together
minArcSize = 0.05 --arcs smaller than this are converted to moves
end

function OnFinish()
post.Text (“M08\n”) – always turn the torch off
post.Text (“G00X0Y0\n”) – go back to zero
post.Text (“M02”) – always end the program so HyCut doesn’t go crazy
post.Eol()
end

function OnRapid()
post.Text (“G00”)
post.ModalNumber (“X”, endX * scale, “0.000”)
post.ModalNumber (“Y”, endY * scale, “0.000”)
post.ModalNumber (“Z”, endZ * scale, “0.000”) – this should never be used
post.Eol()
end

function OnMove()
post.Text (“G01”)
post.ModalNumber (“X”, endX * scale, “0.000”)
post.ModalNumber (“Y”, endY * scale, “0.000”)
post.ModalNumber (“Z”, endZ * scale, “0.000”) – this should never be used
post.Eol()
end

function OnPenUp()
post.Text (“M08”) – torch off
post.Eol()
end

function OnPenDown()
post.Text (“M07”) – torch on
post.Eol()
end

function OnArc()
if(arcAngle <0) then
post.Text (“G03”)
else
post.Text (“G02”)
end
post.ModalNumber (“X”, endX * scale, “0.000”)
post.ModalNumber (“Y”, endY * scale, “0.000”)
post.Text (“I”)
post.Number ((arcCentreX - currentX) * scale, “0.000”)
post.Text (“J”)
post.Number ((arcCentreY - currentY) * scale, “0.000”)
post.Eol()
end

That is a touchy control! You can suppress Z moves. Just add these lines to the beginning of function OnRapid()

   if&#40;endX > 1e10 or endY > 1e10&#41; then return end
   if &#40;math.hypot&#40;endX - currentX, endY - currentY&#41; < 0.01&#41; then return end

You’ll probably also want to add this line to the beginning of function OnMove():

   if &#40;math.hypot&#40;endX - currentX, endY - currentY&#41; < 0.01&#41; then return end

Thanks! That takes care of the last detail. I’ve tested now with the new code, and all is well. Please feel free to add this new post-processor that I’ve included in this message.

JT