Sei sulla pagina 1di 4

--Mach2 post processor ---Modal G-codes and coordinates --Comments enclosed with ( and ) --Incremental IJ --uses G43 tool

length offsets -------------------revision 20/10/04 added tool length offsets revision 25/10/04 added G90.1 incremental IJ mode revision 28/7/04 Added drill start depth revision 19/7/04 added drill cycle revision 28/6/04 Replaced startx,y,z with currentx,y,z Revision 28/5/04 Unbodged first rapid move - main app is fixed now Added plunge,feed,spindle speed warnings Revision 25/5/04 fixed feed rate problem and bodged first rapid move Revision 18/5/04 Added Metric + Inch variables and easy inch/metric swapping changed to fixed number of trailing zeros Created 11/5/2004

function init() setcommentchars ("()", "[]") --make sure ( and ) characters do not appear in system text text (" (Filename: ", filename, ")\n") text (" (Post processor: ", postname, ")\n") text (" (Date: ", date, ")\n") text (" G90.1 (incremental IJ mode)\n") if(scale == metric) then text (" G21 (Units: Metric)\n") --metric mode else text (" G20 (Units: Inches)\n") --inch mode end text (" G40 G90\n F1\n") end function newline() text ("N") number (line, "0000") line = line + 10 end

function finish() endz = safez rapid() text (" G49\n M05 M30\n") end function rapid() modaltext (" G00") modalnumber (" X", endx * scale, "0.0000") modalnumber (" Y", endy * scale, "0.0000") modalnumber (" Z", (endz + tooloffset) * scale, "0.0000") eol() end function move() modaltext (" G01") modalnumber (" X", modalnumber (" Y", modalnumber (" Z", modalnumber (" F", modalnumber (" S", eol() end

endx * scale, "0.0000") endy * scale, "0.0000") (endz + tooloffset) * scale, "0.0000") feedrate * scale, "0.###") spindlespeed, "0.##")

function arc() if(math.hypot(endx-currentx , endy-currenty) <0.02) then move() --ignore if arc is too small return end if(arcangle <0) then modaltext (" G03") else modaltext (" G02") end modalnumber (" X", endx * scale, "0.0000") modalnumber (" Y", endy * scale, "0.0000") modalnumber (" Z", (endz + tooloffset) * scale, "0.0000") text (" I") number ((arccentrex - currentx) * scale, "0.0000") text (" J") number ((arccentrey - currenty) * scale, "0.0000") modalnumber (" F", feedrate * scale, "0.0###") modalnumber (" S", spindlespeed, "0.##") eol() end function spindlecw() text (" M03") modalnumber (" S", spindlespeed, "0.##") modalnumber (" F", feedrate * scale, "0.###") eol() end function spindleccw() text (" M04") modalnumber (" S", spindlespeed, "0.##") modalnumber (" F", feedrate * scale, "0.###") eol() end

function spindleoff() text (" M05\n") end function newprocess() text (" (Process: ", processname, ")\n") if (plungerate <= 0) then warning("WARNING: Plunge rate is zero") end if (feedrate <= 0) then warning("WARNING: Feed rate is zero") end end function toolchange() text (" M6 T") number (tool, "0") text (" (", toolname, ")\n") text (" G43 H") number (tool, "0") modalnumber(" F",feedrate * scale,"0.#") eol() end function spindlechanged() if (spindlespeed <= 0) then warning("WARNING: Spindle speed is zero") end end function newpart() text(" (Part: ",partname,")\n"); end function floodon() text(" M08 (Flood coolant on)\n") end function miston() text(" M07 (Mist coolant on)\n") end function coolantoff() text(" M09 (Coolant off)\n") end function drill() rapid() depth = drillstart buffer = 0.5 if(retract < buffer) then buffer = retract end while depth > drillz do endz = depth + buffer rapid() depth = depth - peckdepth

if (depth < drillz) then depth = drillz end endz = depth move() if (depth > drillz) then --retract if we need to take another bite endz = endz + retract if (endz > safez) then endz = safez end rapid() end end if (endz < safez) then endz = safez rapid() end end

Potrebbero piacerti anche