how to insert arc start point with post processor

Having problems with or questions about SheetCam? Post them here.
Post Reply
SmokingGNU
Posts: 2
Joined: Wed Jan 25, 2023 2:20 pm

how to insert arc start point with post processor

Post by SmokingGNU »

I'm new to gcode and post processors so bare with me, this hatchet job only half worked and I could do with some help to fix it. I ran into the "radius to end of arc differs to radius to start on line #" error in mach 3, from some digging around here I found that the issue was that the xy co-ords were not defined before the cut. I believe this is due to the Laser off command coming after the move to start location similar to this:

N1670 G02 X51.8982 Y173.8706 I74.1210 J-47.8511
N1680 M05 (Laser Off)
N1690 G00 X95.3694 Y187.8662
N1700 M11P1 (Laser On)
N1710 G03 X80.3105 Y172.2989 I51.7976 J-65.1733
N1720 G03 X59.4848 Y178.2507 I-33.3227 J-77.1858
N1730 G02 X95.3694 Y187.8662 I40.2652 J-78.5007

I have made an attempt to fix this by having the post processor insert a command before the arc to define the start position again, with these commands:

function OnArc()
post.ModalText (" G01")
post.NonModalNumber (" X", currentX * scale, "0.0000")
post.NonModalNumber (" Y", currentY * scale, "0.0000")
post.Eol()

if(arcAngle <0) then
post.ModalText (" G03")
else
post.ModalText (" G02")
end
post.NonModalNumber (" X", endX * scale, "0.0000")
post.NonModalNumber (" Y", endY * scale, "0.0000")
post.Text (" I")
post.Number ((arcCentreX - currentX) * scale, "0.0000")
post.Text (" J")
post.Number ((arcCentreY - currentY) * scale, "0.0000")
post.ModalNumber (" F", feedRate * scale, "0.0###")
post.Eol()
end

The 4 bold lines are the new command lines I have added, to some degree this worked, the post would spit out this:

N2180 M05 (Laser Off)
N2190 G00 X140.0152 Y21.2493
N2200 M11P1 (Laser On)
N2210 G01 X140.0152 Y21.2493
N2220 G02 X104.1306 Y11.6338 I-40.2652 J78.5007
N2230 G01 X104.1306 Y11.6338
N2240 G03 X119.1895 Y27.2011 I-51.7976 J65.1733
N2250 G01 X119.1895 Y27.2011
N2260 G03 X140.0152 Y21.2493 I33.3227 J77.1858
N2270 M05 (Laser Off)
N2280 G00 X95.3703 Y11.6338
N2290 M11P1 (Laser On)
N2300 G01 X140.0152 Y21.2493
N2310 G02 X59.4856 Y21.2489 I-40.2652 J78.5007
N2320 G01 X59.4856 Y21.2489
N2330 G03 X80.3107 Y27.2011 I-12.2714 J82.3406
N2340 G01 X80.3107 Y27.2011
N2350 G03 X95.3703 Y11.6338 I67.4513 J50.1835

however it caused 2 problems:

1) the major problem that this command now defines an entirely different start point on the arc usually cutting a straight line to a new point not on the arc or different to the g00 move function. digging through the example above lines N2180 through N2280 define the movement as it should be but the problem seems to be N2300 the inserted g01 defining wrong and using co-ordinates from N2190 and N2210.

2) here is also a minor problem of excess code there is now an additional line for every arc in the path even though this is a closed loop line. this would be nice to clean up but is not really an issue.


If anyone could help me figure out where I've gone wrong or steer me back on track that would be much appreciated
if you need any additional info let me know
User avatar
Les Newell
Site Admin
Posts: 3668
Joined: Thu May 11, 2006 8:12 pm

Re: how to insert arc start point with post processor

Post by Les Newell »

Could you attach the whole post processor so I can take a lok at it. I think there may be something else odd going on in the post.
SmokingGNU
Posts: 2
Joined: Wed Jan 25, 2023 2:20 pm

Re: how to insert arc start point with post processor

Post by SmokingGNU »

Sorry for the delay, I didn't have the file on me yesterday, and thanks for the help.

Please bare in mind this is for a modified HX40A laser cutter I purchased second hand so the post file came from the previous owner. I've no clue on what most of it means sorry, only why the modified start command is used and the drill section may have been for one of his other machines but im unsure. my addition is in bold again

function OnAbout(event)
ctrl = event:GetTextCtrl()
ctrl:AppendText("Mach3 laser post processor\n")
ctrl:AppendText("\n")
ctrl:AppendText("Using M11P1 for on and M05 for off\n")
ctrl:AppendText("\n")
ctrl:AppendText("Modal G-codes and coordinates\n")
ctrl:AppendText("Comments enclosed with ( and )\n")
ctrl:AppendText("Incremental IJ\n")
end



function OnInit()

post.SetCommentChars ("()", "[]") --make sure ( and ) characters do not appear in system text
post.Text (" (Filename: ", fileName, ")\n")
post.Text (" (Laser Power should be set to XX% for material)\n")
post.Text (" (Post processor: ", postName, ")\n")
post.Text (" (Date: ", date, ")\n")
if(scale == metric) then
post.Text (" G21 (Units: Metric)\n") --metric mode
else
post.Text (" G20 (Units: Inches)\n") --inch mode
end
post.Text (" G53 G90 G91.1 G40\n")
bigArcs = 1 --stitch arc segments together
minArcSize = 0.05 --arcs smaller than this are converted to moves
end

function OnNewLine()
post.Text ("N")
post.Number (lineNumber, "0000")
lineNumber = lineNumber + 10
end


function OnFinish()
post.Text (" M5\n")
post.Text (" G00 X0 Y0\n")
post.Text (" M30\n")
end

function OnRapid()
post.ModalText (" G00")
post.ModalNumber (" X", endX * scale, "0.0000")
post.ModalNumber (" Y", endY * scale, "0.0000")
post.Eol()
end

function OnMove()
post.ModalText (" G01")
post.ModalNumber (" X", endX * scale, "0.0000")
post.ModalNumber (" Y", endY * scale, "0.0000")
post.ModalNumber (" F", feedRate * scale, "0.0###")
post.Eol()
end

function OnArc()
post.ModalText (" G01")
post.NonModalNumber (" X", currentX * scale, "0.0000")
post.NonModalNumber (" Y", currentY * scale, "0.0000")
post.Eol()

if(arcAngle <0) then
post.ModalText (" G03")
else
post.ModalText (" G02")
end
post.NonModalNumber (" X", endX * scale, "0.0000")
post.NonModalNumber (" Y", endY * scale, "0.0000")
post.Text (" I")
post.Number ((arcCentreX - currentX) * scale, "0.0000")
post.Text (" J")
post.Number ((arcCentreY - currentY) * scale, "0.0000")
post.ModalNumber (" F", feedRate * scale, "0.0###")
post.Eol()
end


function OnPenDown()
post.Text (" M11P1 (Laser On)\n")
if (pierceDelay > 0) then
post.Text (" G04 P")
post.Number (pierceDelay,"0.###")
post.Eol()
end

end


function OnPenUp()
post.Text (" M05 (Laser Off)\n")
end


function OnNewOperation()
post.Text (" (Operation: ", operationName, ")\n")
end

function OnComment()
post.Text(" (",commentText,")\n")
end

function OnToolChange()
post.Text (" M06 T")
post.Number (tool, "0")
post.ModalNumber(" F",feedRate * scale,"0.0###")
post.Text (" (", toolName, ")\n")
if (plungeRate <= 0) then
post.Warning("WARNING: Plunge rate is zero")
end
if (feedRate <= 0) then
post.Warning("WARNING: Feed rate is zero")
end
end

function OnNewPart()
post.Text(" (Part: ",partName,")\n");
end

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