--************************************************ --*** Set these values up to suit your machine *** -- Values set HERE are in MM. If the value can be set in SheetCAM it is in the UNITS (MM or Inches) you have in SheetCAM --************************************************ lineNumber = 0 --set this to 1 if you want the G-Code to have assigned line numbers on each line. Default is 0 for LinuxCNC startCode = " M3 S100" --S command needed for LINUXCNC --****************************************************************************************************************************************** -- do not change the following values unless you are told to do so by an experienced LinuxCNC user or vendor of your controller or table toolTrack = .254 -- Default .254 mm. This is the blending tolerance in MM (deviation from toolpath) the Path Blending allows. -- Lower numbers favors tight tracking over the defined feedrate (slows down) toolTolerance = .0254 -- Default .0254 mm.T his is the linear tolerance for multiple nodes in the same toolpath. -- Lower numbers cause nodes out of line by less than the toolTolerance amount to be a single line --******************************************************************************************************************************************* --these are THC enable on/off codes dynthcOnCode = " M62 P01" dynthcOffCode = " M63 P01" statthcONCode = " M64 P01" statthcOffCode = " M65 P01" --************************************************************************** --*** End of settings *** --*** DO NOT CHANGE ANYTHING BELOW THIS LINE *** --************************************************************************** function OnAbout(event) ctrl = event:GetTextCtrl() ctrl:AppendText("Custom Post for Plasmac Barch of LinuxCNC for Linux: \n") ctrl:AppendText("Use with SheetCAM TNG version 6.0.14 or higher or Development ver 6.1.16 \n") ctrl:AppendText("Designed for use with LINUXCNC version 2.8-PRE Plasmac Branch\n") end post.DefineVariable("cutDistance",sc.unitLINEAR,0,1e17) post.DefineVariable("slowPercent",sc.unitPERCENT,-1e17,1e17) post.DefineCustomToolParam("PlasmaTool", "Preset volts", "presetVolts", sc.unit0DECPLACE, 49, 0, 200) post.DefineCustomToolParam("PlasmaTool", "DTHC delay -sec", "dthcDelay", sc.unit2DECPLACE, 0, 0, 99) post.DefineCustomToolParam("PlasmaTool", "Tip Size -Amps", "tipSize", sc.unit0DECPLACE, 25, 45, 200) post.DefineCustomToolParam("PlasmaTool", "NO DTHC - 0", "dthcOff", sc.unit0DECPLACE, 1, 0, 1) post.DefineCustomToolParam("JetOperation", "Min Cut Length for THC", "minLength", sc.unit1DECPLACE, 1, .0, 100) post.DefineCustomToolParam("FlameTool", "Set Z Zero Manually ? - 1 is YES", "manualZSet", sc.unit0DECPLACE, 0, 1, 1) -- post.DefineCustomToolParam("JetOperation", "Toolpath tracking", "toolTrack", sc.unit3DECPLACE, .010, .0, .100) if (toolTrack) then --nothing else toolTrack = .001 end post.DefineCustomOption("Ref Distance", "refDistance", sc.unitLINEAR, 0, 10000) function OnInit() offX = 0 offY = 0 offZ = 0 post.SetCommentChars ("()", "[]") --make sure ( and ) characters do not appear in system text post.Text (" (Filename: ", fileName, ")\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 (" F10.0\n G90 G40\n") post.Text (" G64 P") post.Number (toolTrack * scale, "0.000") post.Text(" Q") post.Number (toolTolerance * scale, "0.000") post.Text (" (tracking tolerances set to " , toolTrack * scale, ") \n") -- check all of the DCC variables to make sure there are no nulls if(dthcOff) then --don't do anything else dthcOff = 1 --don't pass a null end if(presetVolts) then --don't do anything else presetVolts = 0 --don't pass a null end if(dthcDelay) then --don't do anything else dthcDelay = 0 --don't pass a null end if(tipSize) then --don't do anything else tipSize = 25 --don't pass a null end if(presetAmps) then --don't do anything else presetAmps = 0 --don't pass a null end if(presetPSI) then --don't do anything else presetPSI = 0 --don't pass a null end if(softPierce) then --don't do anything else softPierce = 100 --don't pass a null end if(entityLength) then --don't do anything else entityLength = 0 --don't pass a null end off2X = .0254 off2Y = .0254 newOp = false minArcSize = 0.2 --arcs smaller than this are converted to moves firstRef = true currentZAxis = "Z" finalCut = false dist = 9999999 lastz = 0 post.Text (statthcOffCode)--turn off the THC no matter the state post.Eol() thcstate = 0 end function OnNewLine() if (linenumber == 1) then post.Text ("N") post.Number (lineNumber, "0000") lineNumber = lineNumber + 10 else post.Text (" ") end end local function round(x, n)--added by TLC --n = math.pow(10, n or 0) x = x * 100 if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end return x / n end function OnFinish() finalCut = true endXRND = round(endX, 100) endYRND = round(endY, 100) curXRND = round(currentX, 100) curYRND = round(currentY, 100) if (endXRND == curXRND) and (endYRND == curYRND) then --see if the current X and Y position is the same final move post.Text (" (No Parking values detected. Moving back to zero, zero)\n ") endX = 0 endY = 0 else post.Text (" (End of job , noving to predefined Parking position)\n ") end if endZ > safeZ then --use the largest number --nothing else endZ = safeZ end offX = 0 offY = 0 offZ = 0 -- OnRapid()--make the final rapid move post.Text ("G4 P15 \n") --wait for torch cooling air to stop post.Text ("G53 G0 X0 Y46 Z0 \n") post.Text ("G92.1 \n") post.Text(statthcOffCode) post.Text(" (DTHC is off)\n"); post.Text(" G4 P.2 \n") post.Text (" M5 M30\n") end function OnRapid() if(currentZ~= endZ)then return end post.ModalText (" G0 ") post.ModalNumber (" X", (endX + offX) * scale, "0.000") post.ModalNumber (" Y", (endY + offY) * scale, "0.000") post.Eol() end -- end on Rapid Function function OnMove() if(currentZ~= endZ)then return end post.ModalText (" G1") post.ModalNumber (" X", (endX + offX) * scale, "0.000") post.ModalNumber (" Y", (endY + offY) * scale, "0.000") post.ModalNumber (" F", feedRate * scale, "0.0##") post.Eol() feedRate2 = feedRate end --end of OnMove function function OnArc() local radius = math.hypot(currentX - arcCentreX, currentY - arcCentreY) dist = dist + radius * math.abs(arcAngle) if(arcAngle <0) then post.ModalText (" G3") else post.ModalText (" G2") end post.ModalNumber (" X", (endX + offX) * scale, "0.000") post.ModalNumber (" Y", (endY + offY) * scale, "0.000") post.Text (" I") post.Number ((arcCentreX - currentX) * scale, "0.000") post.Text (" J") post.Number ((arcCentreY - currentY) * scale, "0.000") post.ModalNumber (" F", feedRate* scale, "0.0###") post.Eol() end -- end OnArcfunction function DynThcOff() --Dynamic THC on/off is used when sync with motion is needed if(not dynthcOffCode) then return end if(thcstate ==1) then thcstate = 0 post.Text(dynthcOffCode) if (verbose == true) then post.Text(" (THC is off)"); end post.Eol() end end function DynThcOn() if(not dynthcOnCode) then return end if(thcstate == 0) then thcstate = 1 post.Text(dynthcOnCode) if (verbose == true) then post.Text(" (THC is on)"); end post.Eol() return end if(thcstate == 2) then thcstate = 0 end end function StatThcOff() --static THC ON/OFF is used when the THC is to be turned on/off when there is no subsequent motion move if(not statthcOffCode) then return end if(thcstate == 1) then -- if its not on it won't turn it off thcstate = 0 post.Text(statthcOffCode) if (verbose == true) then post.Text(" (THC is OFF)\n"); end post.Eol() end end function StatThcOn() if(not statthcOnCode) then return end if(thcstate ==0) then thcstate = 1 post.Text(statthcOnCode) if (verbose == true) then post.Text(" (THC is ON)\n"); else post.Eol() end end if(thcstate == 2) then thcstate = 0 end end function OnPenDown() if (dthcOff == 1) then if (thcstate == 0) then DynThcOn() end end post.Text (startCode) post.Eol() end --end OnPenDown function function OnPenUp() post.Text (" M5\n") if (thcstate == 1) then StatThcOff() end end --end OnPenUp function function OnNewOperation() newOp = true post.Text (" (Operation: ", operationName, ")\n") if (feedRate <= 0) then post.Warning("WARNING: Feed rate is zero") end end--end function function OnToolChange() offX = 0 offY = 0 offZ = 0 if (toolClass== "PlasmaTool") then if (verbose == true) then if(dthcOff == 0) then post.Text (" (DTHC has been disabled in this tool)\n") end if(presetVolts >0) then post.Text ( "(Preset Volts: ",presetVolts,") " ) else --post.Text ("(") end if(tipSize>0) then post.Text ( "( Suggested Tip Size: " ,tipSize," )") post.Eol() end if(dthcDelay > 0 ) then post.Text ( " ( DTHC Delay: " ,dthcDelay," sec ) ") post.Eol() else post.Text ( " (Default DTHC Delay )") post.Eol() end if(minLength > 0 ) then post.Text ( " ( Min Cut Length for DTHC ON : " ,minLength ," units ) ") post.Eol() end post.Eol() end -- end of verbose check -- if(dthcOff == 0) then -- post.Text (" M68 E0 Q999 ") -- if (verbose == true) then -- post.Text(" (Global DTHC ON/OFF is OFF ) \n") -- else -- post.Eol() -- end -- post.Text(" G4 P.1 \n" ) -- else -- post.Text (" M68 E0 Q900 ") -- if (verbose == true) then -- post.Text(" (Global DTHC ON/OFF is ON ) \n") -- else -- post.Eol() -- end -- post.Text (" G4 P.1 \n" ) -- end --end dthcOff loop -- if(presetVolts > 0) then -- post.Text ( " M68 E0 Q3" ,presetVolts, "" ) -- if (verbose == true) then -- post.Text(" (Preset Volts set to ",presetVolts ," Volts)") -- end -- post.Eol() -- post.Text (" G4 P.1 \n") -- else -- post.Text ( "(No Preset Volts)\n" ) -- end --end presetVolts -- if(dthcDelay > 0 ) then -- post.Text ( " M68 E0 Q5") -- post.Number (dthcDelay * 10, "00") ---multiplies times 10 to pass decimal values -- if (verbose == true) then -- post.Text(" (DTHC Delay set to ",dthcDelay ," Seconds)") -- end -- post.Eol() -- post.Text (" G4 P.1 \n") -- end --end dthcDelay -- post.Text(statthcOffCode) -- if (verbose == true) then -- post.Text(" (DTHC is OFF)\n"); -- else -- post.Eol() -- end --post.Eol() -- post.Text (" G4 P.1 \n ") post.Text (" G64 P") post.Number (toolTrack * scale, "0.000") post.Text(" Q") post.Number (toolTolerance * scale, "0.000") post.Text (" (tracking tolerances set to " , toolTrack * scale, ") \n") if (warnings == true) then post.Text (" M1") post.Text (" (Settings Check)\n") post.Text ("( ###########################)\n") post.Text (" (Paused: Check the DTHC Settings )\n") post.Text (" ( Hit RUN to continue)\n") post.Text ("( ###########################)\n") else post.Text (" M1") post.Text (" (Pause off)\n") post.Text ("( ###########################)\n") end --end warnings end -- end of plasma tool loop end --end for toolchangefunction function OnNewPart() post.Text(" (Part: ",partName,")\n"); end