View Full Version : Need a post mod


CNCadmin
12-11-2005, 07:18 PM
Here is my post code-


--Modal G-codes and coordinates
--Comments enclosed with ( and )
--M03/M05 turn the torch on/off
--Incremental IJ

-- revision 11/7/05
-- Moved torch to cut height when preheating
-- Added dummy spindle speed to prevent Mach2 throwing a zero spindle speed error

-- revision 9/10/04
-- Added preheat

-- revision 28/6/04
-- Replaced startx,y,z with currentx,y,z

-- created 28/5/04
-- Based on Mach2 metric.post



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")
if(scale == metric) then
text (" G21 (Units: Metric)\n") --metric mode
else
text (" G20 (Units: Inches)\n") --inch mode
end
text (" G53 G90 G40\n F1\n S500\n")
end

function newline()
text ("N")
number (line, "0000")
line = line + 10
end


function finish()
endz = safez
rapid()
text (" M05 M30\n")
end

function rapid()
modaltext (" G00")
modalnumber (" X", endx * scale, "0.0000")
modalnumber (" Y", endy * scale, "0.0000")
modalnumber (" Z", endz * scale, "0.0000")
eol()
end

function move()
modaltext (" G01")
modalnumber (" X", endx * scale, "0.0000")
modalnumber (" Y", endy * scale, "0.0000")
modalnumber (" Z", endz * scale, "0.0000")
modalnumber (" F", feedrate * scale, "0.###")
modalnumber (" S", spindlespeed, "0.##")
eol()
end

function arc()
if(math.hypot(endx-currentx , endy-currenty) <0.2) 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 * 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 pendown()
if (preheat > 0.001) then
modaltext (" G00")
modalnumber (" Z", cutheight * scale, "0.0000")
text ("\n G04 P")
number (preheat,"0.###")
eol()
end
modaltext (" G00")
modalnumber (" Z", pierceheight * scale, "0.0000")
text ("\n M03\n")
if (piercedelay > 0.001) then
text (" G04 P")
number (piercedelay,"0.###")
eol()
end
end


function penup()
text (" M05\n")
if (enddelay > 0) then
text (" G04 P")
number (enddelay,"0.###")
eol()
end
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 (" M06 T")
number (tool, "0")
modalnumber(" F",feedrate * scale,"0.#")
text (" (", toolname, ")\n")
end

function newpart()
text(" (Part: ",partname,")\n");
end



I need it to be modified so that once the program is run it goes to 0,0,0. Can someone give me what I need to post in this file to make it work?

Bubba
12-11-2005, 08:57 PM
Paul,
that looks like it might be a post from SheetCam, and here is how I have modified mine to do something like you want. Obviously, you might want to change some of the parameters, but this works.

function finish()
-- endz = safez
text (" T0\n")
text (" G00 Z4.5\n")
text (" G59\n")
text (" G00 X0 Y0\n")
-- rapid()
-- endy = 0
-- endx = 0
-- endz = 5
-- rapid()
text (" M05\n M30\n")
end

As I use fixtures, I want mine to end at my "tool change" origin and I use G59 for tool changes. YMMV, but I think you can get the idea. By the way, Luna (sheetcam post language uses "--" for commenting.