--************************************************ --*** 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 --************************************************ refDistance = 25 --this is the distance between each torch reference in MILLIMETRES.(can be set from POST Options button in UNITS) 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 minLength = 0 -- default minumum length of cut for DTHC operation (set dynamically) dthcTune = 1 -- set this to 1 if you are using the new DTHCIV and want variable tuning of Z response from code fullTAP = 1 --set this to 1 for TAP via Hypertherm RS485 (requires options) plasmaDrill = 1 --set this to 1 to use a plasma for a drill tool . Set it to 0 to use a drill or router bit warnings = false -- set this to false to turn off the Check Parameters warnings on a toolchange verbose = true -- set this to false to turn off the G-Code comments (except code snips) debug = false -- make sure you have the PROBE input in LINUXCNC Input Signals enabled and mapped to the probe switch input noTouchOff = false -- set to true if you want to run in simulation without touchoffs. Normal setting would be false extTOff = true -- set this to true to use a subroutine in CommandCNC to call a touch off sequence and apply the external switchoffset value. -- Leave this at "true" for commandCNC versions 0.6.0 and later markerZ = true --this value when set to "true" will set the Z to lift to rapid height between paths when using the plate marker tool. --if false it will not lift the Z between paths but Will at the end of all cuts markerOn = false -- this when set to true leaves the output 2 on between cuts excepot for the final cut. only use this with -- markerZ set to "true" --Scriber X,Y,Z offsets in MILLIMETRES. Do not use inches here even if you want inch code --For the marker use the scriber Z as the offset from Z zero you want the Z to move to during a scribe. --Change these values to suit your scriber setup scriberX = 50 scriberY = 50 scriberZ = 25 --scriber axis. Leave this as nil if the scriber is fixed to the same axis as the torch scriberAxis = nil --drill tool for Z axis drilling (not center peck with plasma)used with plasmaDrill set to 0] PenMarkerX = 25 PenMarkerY = 25 PenMarkerZ = 50 FlameTorchOffX = 0 --for mounting falme torch on gantry FlameTorchOffY = 0 FlameTorchOFFZ = 0 drillOffsetX = 25 drillOffsetY = 25 drillOffsetZ = 50 drillAxis = " Z" --if altternate Z axis is used this needs to be the Axis letter of that axis -- new Output control codes added 4/18 for new EBOB --these turn outputs on and off directly (not for torch or first two: Mist and Flood) DirectOutPut4On = " M64 P4 " DirectOutPut4Off = " M65 P4 " DirectOutPut5On = " M64 P5 " DirectOutPut5Off = " M65 P5 " DirectOutPut6On = " M64 P6 " DirectOutPut6Off = " M65 P6 " DirectOutPut7On = " M64 P7 " DirectOutPut7Off = " M65 P7 " DirectOutPut8On = " M64 P8 " DirectOutPut8Off = " M65 P8 " Output1_ON = " M3 S100" Output2_ON = " M7" Output3_ON = " M8" Output1_OFF = " M5" Output2_OFF = " M9" Output3_OFF = " M9" drillZ = .250 startCode = " M3 S100" --S command needed for LINUXCNC --these codes are for the DCC extensions for Commandcnc and turn the DTHC on/off if you have DTHCII REV1.4 or DTHCIV REV1.6 or higher firmware. Used with --ALL DTHCIV units running with CommandCNC dynthcOnCode = " M67 E0 Q20" dynthcOffCode = " M67 E0 Q10" statthcONCode = " M68 E0 Q20" statthcOffCode = " M68 E0 Q10" --****************************************************************************************************************************************** -- 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 --******************************************************************************************************************************************* --************************************************************************** --*** End of settings *** --*** DO NOT CHANGE ANYTHING BELOW THIS LINE *** --************************************************************************** function OnAbout(event) ctrl = event:GetTextCtrl() ctrl:AppendText("Custom Post for CommadnCNC rev 1.1 and higher for Linux: \n") ctrl:AppendText("For CandCNC Linux Hardware ") ctrl:AppendText("with/without Plate Marker\n") --ctrl:AppendText("Added support for Marker pen and Drill head \n") ctrl:AppendText("Supports Full Automation for Plasma with Hypertherm RS485 Option \n") ctrl:AppendText("Adds options: SOFT PIERCE , MIN CUT LENGTH, PECK PIERCE and SOFT PECK\n") ctrl:AppendText("Adds options: AUTOSET and DTHC control at Opertaion level\n") ctrl:AppendText("Use with SheetCAM TNG version 6.0.20 or higher or Development (Linux) ver 6.1.57 \n") ctrl:AppendText("Designed for use CandCNC DTHCIV with Floating head Touch-n-Go\n") local window = ctrl:GetParent() local btn = wx.wxButton(window, wx.wxID_ANY, "Set custom post options") btn:Connect(wx.wxID_ANY, wx.wxEVT_COMMAND_BUTTON_CLICKED, OnButton) ctrl:GetContainingSizer():Insert(2, btn, 0, wx.wxALL, 5) end post.DefineVariable("cutDistance",sc.unitLINEAR,0,1e17) post.DefineVariable("slowPercent",sc.unitPERCENT,-1e17,1e17) if(fullTAP > 0) then post.DefineCustomToolParam("JetOperation", "Soft Pierce %", "softPierce", sc.unit0DECPLACE,100, 30, 100) post.DefineCustomToolParam("PlasmaTool", "Preset current", "presetAmps", sc.unit0DECPLACE, 45, 10, 200) post.DefineCustomToolParam("PlasmaTool", "Preset Air Pressure", "presetPSI", sc.unit0DECPLACE, 75, 50, 100) else softPierce = 0 presetAmps = 0 presetPSI = 0 end post.DefineCustomToolParam("PlasmaTool", "Preset volts", "presetVolts", sc.unit0DECPLACE, 49, 0, 200) post.DefineCustomToolParam("PlasmaTool", "DTHC delay -sec", "dthcDelay", sc.unit2DECPLACE, 1, 0, 99) post.DefineCustomToolParam("PlasmaTool", "HTSYNC-Part", "syncPart", sc.unitTEXT, 0, 0, 0) post.DefineCustomToolParam("JetOperation", "Disable DTHC this OP", "dthcOff", sc.unitBOOLEAN, 0, 0, 1) --1 is checked (off) post.DefineCustomToolParam("JetOperation", "Use AutoSet", "autoSet", sc.unitBOOLEAN, 1, 0, 1) --1 is checked (on) post.DefineCustomToolParam("JetOperation", "Min Cut Length for DTHC", "minLength", sc.unit1DECPLACE, 1, .0, 100) post.DefineCustomToolParam("FlameTool", "Set Z Zero Manually ? - 1 is YES", "manualZSet", sc.unit0DECPLACE, 0, 0, 1) post.DefineCustomToolParam("FlameTool", "Use Main Valve ", "mainvalveSet", sc.unitBOOLEAN, 0, 0, 1) --default off post.DefineCustomToolParam("FlameTool", "Ignitor On time - sec", "ignitorTime", sc.unit0DECPLACE, 0, 0, 10)-- defautl 0 (off0) -- post.DefineCustomToolParam("JetOperation", "Toolpath tracking", "toolTrack", sc.unit3DECPLACE, .010, .0, .100) if (toolTrack) then --nothing else toolTrack = .001 end if (dthcTune > 0 ) then --post.DefineCustomToolParam("JetOperation", "DTHCIV Response Profile", "dthcTune", sc.unit0DECPLACE, 1, 0, 9) end if(plasmaDrill > 0) then --this is a peck drill using plasma torch like a drill tool if(fullTAP > 0) then post.DefineCustomToolParam("DrillOperation", "Preset Current Amps", "presetAmps", sc.unit0DECPLACE, 45, 0, 200) post.DefineCustomToolParam("DrillOperation", "Preset Air Pressure PSI", "presetPSI", sc.unit0DECPLACE, 75, 0, 200) else softPierce = 0 presetAmps = 0 presetPSI = 0 end post.DefineCustomToolParam("DrillOperation", "Peck Delay Sec", "peckPierce", sc.unit2DECPLACE, 0, 0, 1) post.DefineCustomToolParam("DrillOperation", "Soft Mark Percent", "softPeck", sc.unit0DECPLACE, 50, 10, 100) end post.DefineCustomOption("Ref Distance", "refDistance", sc.unitLINEAR, 0, 10000) --post.DefineCustomOption("AuxA on at end", "auxAon", sc.unit0DECPLACE, 0, 5, 100)--This leave the output turned on by M7 on for ##sec after finish function OnButton(evt) post.ShowCustomOptions("Post settings") end 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 = 0 --don't pass a null end if(autoSet) then --value > 0 turns on autoset --nothing else autoSet = 0 --set it off by default end --end autoSet 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 if plungeSafety < 9.525 then --minimum plungeSafety clearance is 9.525mm (.375") plungeSafety = 9.525 end if safeZ <= plungeSafety then --Rapid claearnce has to be greater than plunge safety or we set it to double safeZ = plungeSafety * 2 end if (manualZSet) then else manualZSet = 0 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 DTHC no matter the state post.Eol() thcstate = 0 softPeck2 = 0 mainvalveSet = 0 ignitorTime = 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() if debug then post.Text(" ( ***** OnFinish ***** )\n") end 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, moving 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(" M68 E0 Q900") --resets global DTHC to ON if (verbose == true) then post.Text(" (Reset global DTHC to ON)") end post.Eol() post.Text(" G4 P0.1\n") post.Text(" M68 E0 Q80") --reset the autoset to on at end autoSet = 1 --leave autoset on if (verbose == true) then post.Text(" (Auto Preset is active ) \n") end post.Eol() post.Text(" G4 P0.1\n") post.Text(statthcOffCode) dthcOff = 1 --set disable DTHC to active (off) post.Text(" (DTHC is off)\n"); post.Text(" G4 P0.2\n") post.Text(" M5\n") post.Text (DirectOutPut4Off, "\n") -- turn off flametool main valve if it is on. post.Text(" M9\n") post.Text(" M30\n") end function OnRapid() if debug then post.Text(" ( ***** OnRapid ***** )\n") post.NonModalNumber(" ( endZ = ", endZ * scale, "0.000") post.Text(" )\n") end if(endX < 1e17 and endY < 1e17) then --don't update the distance moved if X or Y are unknown local len = math.hypot((endX + offX)-currentX , (endY + offY)-currentY) dist = dist + len end post.ModalText (" G0") if(toolClass == "MarkerTool") then if(finalCut == true) or (markerZ == true) then --check to see if its the final cut or if the option to lift between cuts is on if (firstRef == true) then -- if this is a refenrence touch off then just lift Z to normal rapid height post.ModalNumber (" Z", safeZ * scale, "0.000")--raise the Z to the rapid Z height plus the Rapid Z) else if (toolName == "PenMarker") then --if this is a penmarker we use that defined offset for Z post.ModalNumber (" Z", (safeZ + PenMarkerZ) * scale, "0.000")--raise the Z to the rapid Z height plus the offset) else post.ModalNumber (" Z", (safeZ + scriberZ) * scale, "0.000")--raise the Z to the rapid Z height plus the Rapid Z) --post.Text (" (added offz in onrapid)") end end post.Eol() end else --this is not a marker tool --post.Text ("not marker tool\n") if ( (finalCut == false) and ((firstRef == true) or (dist >= refDistance)) ) then post.ModalNumber (" Z", safeZ * scale, "0.000") else post.ModalNumber (" Z", endZ * scale, "0.000") end --post.ModalNumber (" Z", endZ * scale, "0.000") post.Eol() end -- end marker tool 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 debug then post.Text(" ( ***** OnMove ***** )\n") end local len = math.hypot(endX - currentX , endY - currentY) dist = dist + len if (toolName ~= "CenterPunch") then --could include plasma tool if(toolClass == "MarkerTool") then post.ModalText (" G1") post.ModalNumber (" Z", (endZ + offZ) * scale, "0.000") post.ModalNumber (" F", feedRate * scale, "0.0##") post.Eol() post.ModalNumber (" X", (endX + offX) * scale, "0.000") post.ModalNumber (" Y", (endY + offY) * scale, "0.000") post.Eol() else post.ModalText (" G1") post.ModalNumber (" X", (endX + offX) * scale, "0.000") post.ModalNumber (" Y", (endY + offY) * scale, "0.000") post.ModalNumber (" Z", (endZ + offZ) * scale, "0.000") post.ModalNumber (" F", feedRate * scale, "0.0##") post.Eol() -- no DTHC stuff should be done for marker tools end end end function OnArc() if debug then post.Text(" ( ***** OnArc ***** )\n") end if arcAngle > -0.001 and arcAngle < 0.001 then OnMove() return end 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(" (DTHC is off)"); end post.Eol() end end function DynThcOn() if(not dynthcOnCode) then return end if(toolClass == "MarkerTool") or (toolClass == "FlameTool") then return end if(thcstate ==0) then thcstate = 1 post.Text(dynthcOnCode) if (verbose == true) then post.Text(" (DTHC 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(" (DTHC is OFF)\n"); else post.Eol() end post.Eol() post.Text (" G4 P.1 ") post.Eol() end end function StatThcOn() if(not statthcOnCode) then return end if(toolClass == "MarkerTool") or (toolClass == "FlameTool") then return end if(thcstate ==0) then thcstate = 1 post.Text(statthcOnCode) if (verbose == true) then post.Text(" (DTHC is ON)\n"); else post.Eol() end post.Text (" G4 P.1 ") post.Eol() return end if(thcstate == 2) then thcstate = 0 end end function OnPenDown() if debug then post.Text(" ( ***** OnPenDown ***** )\n") end --post.CancelModaltext() -- Make sure modal codes are put in at the beginning of each cut. Helpful for run-from-line --post.CancelModalNumbers() if (toolClass == "FlameTool") then PenDownFlameCut() -- calls flamecutting function elseif (toolClass == "DrillTool") then -- which is a plasma peck or drill process PenDownDrillOp() -- calls drill and peck plasma drillops elseif (toolClass == "MarkerTool") then punchDown = true PenDownMarker() elseif (toolClass == "PlasmaTool") then --post.Text (" G1 ")--this adds in a G1 move to the same location to fix LINUXCNC bug of Run From here --post.NonModalNumber (" X", (currentX + offX) * scale, "0.000") --post.NonModalNumber (" Y", (currentY + offX) * scale, "0.000") --post.Eol() PenDownPlasma() end end -- OnPenDown function -- begin new functions called from OnPendown function PenDownFlameCut() if (mainvalveSet > 0 ) and (ignitorTime > 0)then post.ModalText ( " G0 Z" , safeZ, "\n") --raise torch to rapid height to light post.Text ( " G4 P2.0") post.Text (" (Raises torch to rapid height and pauses 2 sec) \n") post.Text (DirectOutPut4On) -- this needs to be left on until pen up post.Text (" (Turn on output4 fuel value)") post.Eol() post.Text (" G4 P2.0 \n")--wait 2 sec for flow to start before firing ignitor post.Text (DirectOutPut5On, "\n" ) --fire ignitor post.Number (" G4 " , ignitorTime, "0.0##") post.Eol() post.Text (DirectOutPut5Off , "\n") -- turns off ignitor after set delay on time post.Text (" G4 P.2 \n") end if (firstRef == true) then -- detects first run through cut Reference() --uses torch tip (ohmic) for touch off only if the manualZSet is 0 offX = FlameTorchOffX offY = FlameTorchOffY offZ = FlameTorchOFFZ post.Text (" (Flame Tool) ") post.Eol() post.NonModalNumber (" (FlameTorch X offset = " , FlameTorchOffX * scale, "0.000") post.NonModalNumber (" FlameTorch: Y offset = " , FlameTorchOffY * scale, "0.000") post.NonModalNumber (" FlameTorch: Z offset = " , FlameTorchOFFZ * scale, "0.000") post.Text (")") post.Eol() end --end first ref check post.ModalText (" G1") post.ModalNumber (" Z", pierceHeight * scale, "0.000") post.ModalNumber (" F", plungeRate * scale, "0.000") post.Eol() if (preheat > 0) then -- only used for flametools post.Text (" G4 P") post.Number (preheat,"0.0##") post.Eol() end post.ModalNumber (" Z ", cutHeight * scale, "0.000") post.ModalNumber (" F ", plungeRate * scale, "0.000") post.Eol() post.Text (" G4 P0.5\n") post.Text (Output1_ON, "\n") --fires oxy cut solenoid end --end flamecut function function PenDownDrillOp() if (plasmaDrill == 1) then --see if its a plasmadrill if (firstRef == true) then Reference() offX = 0 -- no offsets for plasma peck offY = 0 offZ = 0 post.Text (" ( This sequence starts purge air on first peck )\n") post.ModalText (" G0 Z1.000 \n") -- raise up and fire the torch for 1/2 sec to cycle torch post.Text (startCode.. "\n") post.Text (" G4 P.50 \n") post.Text (" M5") post.Eol() offZ = (drillStart/(-1) ) post.ModalNumber(" Z", offZ * scale, "0.000") -- now we need to drop and pierce the first hole post.Eol() post.Text (startCode.. "\n") if (peckPierce ) then post.Text (" G4 P", peckPierce) post.Text (" (Peck delay time)") post .Eol() end else -- not first ref --post.Text ("(not first pierce)\n") post.ModalText(" G1") offZ = (drillStart/(-1) ) post.ModalNumber(" Z", offZ * scale, "0.000") --move Z down to pierce height prior to firing torch post.Text (" F", plungeRate * scale) post.Eol() post.Text(startCode.. "\n") if (peckPierce ) then post.Text (" G4 P", peckPierce) post.Text (" (Peck delay time)") post .Eol() end end --first ref else -- not plasma drill. regular drill if (firstRef == true) then Reference()--uses torch tip (ohmic) for touch off offX = drillOffsetX offY = drillOffsetY offZ = drillOffsetZ post.Text (" (Drill Motor - drill bit)") post.Eol() post.NonModalNumber ("(Drill: X offset = " , drillOffsetX * scale, "0.000") post.NonModalNumber (" Drill: Y offset = " , drillOffsetY * scale, "0.000") post.NonModalNumber (" drill: Z offset = " , drillOffsetZ * scale, "0.000") post.Text (")") post.Eol() end --end first ref check post.ModalText (" G0")--this is not an onrapid move so the movements have to be defined post.ModalNumber (" X", (currentX + offX) * scale, "0.000") post.ModalNumber (" Y", (currentY + offY) * scale, "0.000") post.NonModalNumber (" Z", (currentZ + offZ) * scale, "0.000")--lift the Z before the offset move post.Text (" (move to offsets)") post.Eol() post.NonModalNumber (" Z", offZ * scale, "0.000")--drop the Z to the scriber offset height. post.Text (" (Z move to drill height)") post.Eol() post.Text( "",( Output3_ON),"") --fire the marker on an engraver post.Text(" (turn on Drill Motor Marker)\n") post.Eol() onDrill() -- call the drlling routine end --end check for plasma drill or regular drill end function PenDownMarker() if (toolName =="CenterPunch" ) then offX = scriberX offY = scriberY offZ = scriberZ post.Text (" (Center punch tool)") post.Eol() elseif (toolName =="PenMarker" ) then offX = PenMarkerX offY = PenMarkerY offZ = PenMarkerZ post.Text (" (Pen marker tool)") post.Eol() else --it's not special center punch tool or Penmarker, so it's a pneumatic plate marker offX = scriberX offY = scriberY offZ = scriberZ post.Text (" (Plate marker - engrave tool)") post.Eol() end --end plate marker if (firstRef == true) then --this runs a reference at the first but not afterwards Reference() end post.ModalText (" G0")--this is not an onrapid move so the movements have to be defined --post.NonModalNumber (" Current Z " ,(currentZ * scale) , "0.000") -- debug post.ModalNumber (" Z", (endZ + offZ) * scale, "0.000") --make sure the Z is above zero. post.Eol() post.ModalNumber (" X", (currentX + offX) * scale, "0.000") post.ModalNumber (" Y", (currentY + offY) * scale, "0.000") if (verbose == true) then post.Text (" (move to scriber offsets )") end post.Eol() post.Text(Output2_ON) --fire the marker on an engraver post.Text(" (turn on Plate Marker)") post.Eol() if (toolName =="PenMarker" ) then post.Text(Output3_ON) --pen marker requires this output on as well post.Eol() end --if (plasmaDrill == 0) then --its a drill tool and needs to turn on aux outout -- post.Text(Output2_ON) --fire the marker on an engraver -- post.Text(" (turn on Plate Marker)") -- post.Eol() --end -- end if plasma drill tool if (pierceDelay > 0) then --added 4-17 for plate marker delay after firing . StartDelay = PierceDelay post.Text (" G4 P") post.Number (pierceDelay,"0.###") post.Eol() end end -- end marker function function PenDownPlasma() if (firstRef == true) or (dist >= refDistance) then --reference torch if its first pierce or if its over Ref distance dist = 0 Reference() offX = 0 offY = 0 offZ = 0 end if (fullTAP > 0) and (softPierce > 0) and (softPierce < 100) then -- turn off the DTHC but set the current to softpierce before the torch fires softPierceRND = round(softPierce,10) post.NonModalNumber(" M68 E0 Q1", (softPierceRND/100), "0") post.Text(" (Set pierce AMPS)") post.Eol() post.Text(" G4 P.1") post.Eol() piercePlunge = (softPierce /100) feedRate2 = (plungeRate * piercePlunge) -- lower the feedrate for soft pierce else feedRate2 = plungeRate end -- end fullTAP -- ******** Move to pierce height ******** post.ModalText(" G0") post.ModalNumber(" Z", pierceHeight * scale, "0.000") if (verbose == true) then post.Text(" (Z move to pierce height)") end post.Eol() -- ******** TURN ON THE TORCH!!! ******** post.Text (startCode.. "\n") -- ******** Do the pierce delay ******** if (pierceDelay > 0) then post.Text(" G4 P") post.Number(pierceDelay,"0.###") post.Eol() end -- ******** Move at proper feedrate to cut height ******** post.ModalText(" G1") post.ModalNumber(" Z", cutHeight * scale, "0.000") post.ModalNumber(" F", feedRate2 * scale, "0.0###") if (verbose == true) then post.Text(" (Z move to cut height)") end post.Eol() --post.Text("(entityLength = "..(entityLength * scale)..")\n") if ((entityLength * scale) > minLength) then --see if it is min length --post.Text ("(dthcOff = "..dthcOff..")\n") if (dthcOff == 0) then -- dthc is ON for this cut/operation post.Text(dynthcOnCode)--turn on THC at bottom of Z plunge post.Text(" (Auto DTHC is ON)\n") post.Eol() else post.Text(dynthcOffCode) post.Text(" (Auto DTHC is OFF)\n") post.Eol() end else -- in case softpierce is set and the min cut rule is active, we need to set the DTHC off with AMPs at 100% post.Text(dynthcOffCode) post.Text(" (Auto DTHC OFF min cut)\n") post.Eol() end end -- end PenDownPlasma() function function Reference() if debug then post.Text(" ( ***** Reference ***** )\n") end if (toolClass == "DrillTool") then -- only turn off touchoffs on drilltools if its after first one if (plasmaDrill > 0) and (firstRef == false) then return -- no touch off end end if (toolClass == "FlameTool") and (manualZSet > 0 ) then --we have manual touch off selected post.Text (" (****************************************)\n") post.Text (" (Flame tools do not do an auto touch off)\n") return end if (noTouchOff == false) then -- check to see if there is supposed to be touchoffs in the code firstRef = false post.ModalText(" G0") post.ModalNumber(" Z", plungeSafety * scale, "0.000") --rapid down to safety clearance post.Eol() if (extTOff == true) then -- run the touch off from a stored subroutine post.Text (" o call ") post.Text (" (external Touch off from Commandcnc)") else post.Text (" G38.2 Z") -- Probe Touch-Off post.Number(-plungeSafety * scale, "0.00") post.Text (" F#<_hal[gscreen.toffrate-s]> ") if (verbose == true) then post.Text (" (Probe Touch-Off)") end post.Eol() post.Text (" # = [#<_z> - #5063] ") --Find distance past probe touch if (verbose == true) then post.Text(" (Find distance past probe touch)") end post.Eol() post.Text (" G92 Z[#<_ini[AXIS_2]HOME_OFFSET> + #] ") --Set Z to actual position if (verbose == true) then post.Text(" (Switch Offset)") end end post.Eol() else post.Text (" (Touch Off in this POST has been disabled )") post.Eol () end -- end check for noTouchOff post.CancelModalText() post.CancelModalNumbers() end --end ref function function OnPenUp() if (toolClass == "FlameTool") then post.ModalText (" G0") --this is supposed to add a tiny segment before the M5 post.ModalNumber (" X", (currentX + offX + off2X) * scale, "0.000") post.ModalNumber (" Y", (currentY + offY + off2Y) * scale, "0.000") if (verbose == true) then post.Text (" (Add tiny extension)") end post.Eol() post.Text (Output1_OFF) -- turn off flame torch post.Eol() end if (toolClass == "MarkerTool") and (punchDown == true) then -- marker is down if(finalCut == true) and (markerOn == true) then -- see if its the final cut and post.Text("",Output2_OFF, " (turn off marker on last line)") -- turn off marker output post.Eol() else if (markerOn == false) then -- the marker is down and we need to turnit off every cut post.Text("",Output2_OFF, " (turn off marker)") -- turn off marker output post.Eol() if (toolName == "PenMarker") then post.ModalText(Output3_OFF) post.Eol() end -- post.CancelModalText() punchDown = false -- marker is up end -- end markeron end -- end finalcut end if (toolClass == "DrillTool") and (plasmaDrill > 0 ) then post.Text("",Output1_OFF, " (turn off torch)") -- turn off marker output post.Eol() end if (toolClass == "PlasmaTool") then post.ModalText (" G0") --this is supposed to add a tiny segment before the M5 post.ModalNumber (" X", (currentX + offX + off2X) * scale, "0.000") post.ModalNumber (" Y", (currentY + offY + off2Y) * scale, "0.000") if (verbose == true) then post.Text (" (Add tiny extension)") end post.Eol() post.Text ("",Output1_OFF, "\n") -- turn off plasma torch post.Text (" o call") -- call the end cut subroutine to sync up the Z from the DTHC post.Eol() end if (endDelay > 0) then post.Text (" G4 P") post.Number (endDelay,"0.###") post.Eol() end post.CancelModaltext() -- Make sure modal codes are put in at the beginning of each operation. Helpful for run-from-line post.CancelModalNumbers() end --end OnPenUp function function OnNewOperation() post.CancelModaltext() -- Make sure modal codes are put in at the beginning of each operation. Helpful for run-from-line post.CancelModalNumbers() post.Text (" (Operation: ", operationName, ")\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 --post.Text("(Value of autoset = ",autoSet, )"\n") if (toolClass == "PlasmaTool") then post.Text(" M68 E0 Q900") --resets global DTHC to ON if (verbose == true) then post.Text(" (Reset global DTHC to ON)") end post.Eol() post.Text(" G4 P0.1\n") if(autoSet > 0 ) then --value > 0 turns on autoset post.Text (" M68 E0 Q80 ") --put in the prefix for LINUXCNC if (verbose == true) then post.Text(" (Auto Preset is active )") end post.Eol() post.Text (" G4 P0.1\n") else post.Text (" M68 E0 Q89 ") --put in the prefix for LINUXCNC if (verbose == true) then post.Text(" (Auto Preset is not active )") end post.Eol() post.Text (" G4 P0.1\n") end --end autoSet --if(dthcOff > 0 ) then --value > 0 turns off dthc -- autoDthc = "off" --else -- autoDthc = "on" --end --end dthcOff) end end --end function function TurnoffallOuputs() post.Text (" (Turning off Ouputs prior to toolcahnge)\n") post.Text("",Output1_OFF, " ") -- turn off torch/spindle post.Text("",Output2_OFF, " ") -- turn off marker --post.Text("",Output3_OFF, " ") -- turn off marker outp post.Eol() end --end function function OnToolChange() offX = 0 offY = 0 offZ = 0 TurnoffallOuputs() --rtunr off any off first three outputs that might be on if(toolClass == "FlameTool" ) then post.Text (" (Flame Cutting NO DTHC)\n") post.Text (" M68 E0 Q999\n")-- this turns off the DTHC post.Text (" G4 P.1") post.Eol() post.Text (" (Flame tool number: ", tool ,")") post.Eol() post.Text(" (Preheat: ", preheat , ") \n") post.Text(" (Feedrate: ", feedRate * scale , ") \n") post.Text (" M0 \n") post.Text (" (Make sure you are running an Oxy-Fuel CONFIG.)\n") post.Text (" (Hit the STOP button.") post.Text (" Jog the Z down manually or use an adjustable holder)\n") post.Text (" (touch the tip of the torch to the top of the metal,") post.Text (" and then hit the Z Home button)\n") post.Text (" (Hit the RUN FROM LINE to continue )\n") return --skip the rest of the tool change section end if (toolClass =="DrillTool" ) then if (plasmaDrill > 0) then --see if its a plasma peck drill post.Text (" (tool number: ", tool ," ") post.Text (" Plasma peck drill )") post.Eol() post.Text (" ( Distance between Touch-offs: " , refDistance * scale, " ") post.Text(" Feedrate: ", feedRate * scale , ") \n") if(scriberAxis and scriberAxis ~= currentZAxis) then endZ = safeZ OnRapid() currentZAxis = scriberAxis end if(fullTAP ~= 0) then --check for TAP being used if(presetAmps > 0) then post.Text( " M68 E0 Q4" ,presetAmps, "") if (verbose == true) then post.Text(" ( Preset Cut Current: ",presetAmps, " Amps)") post .Eol() else post.Eol() end post.Text (" G4 P.1") post.Eol() end if(presetPSI > 0) then post.Text( " M68 E0 Q8" ,presetPSI, " ") if (verbose == true) then post.Text(" ( Preset Air Pressure: ",presetPSI, " PSI)") post .Eol() else post.Eol() end --end verbose post.Text (" G4 P.1") post.Eol() else post.Text(" (Using Auto Air Pressure)") post.Eol() end -- end preset psi if (softPeck and softPeck > 9) then softPeck2 = (softPeck/10) if (verbose == true) then post.Text ( " ( Soft Mark : " ,softPeck ," percent ) ") post.Eol() end else softpeck2 = 0 end if (softPeck2 > 0) then post.Text (" M68 E0 Q1" ,softPeck2, " \n ") post.Text (" G4 P.1 \n") else --ThcOff() end end --end fullTAP if(scriberAxis and scriberAxis ~= currentZAxis) then endZ = safeZ OnRapid() currentZAxis = scriberAxis end firstRef = true end --toolclass=DrillTool --end --end if plasmadrill is 1 end -- drilltool if (toolClass== "PlasmaTool") then post.Text(" M68 E0 Q900") --resets global DTHC to ON if (verbose == true) then post.Text(" (Reset global DTHC to ON)") end post.Eol() post.Text(" G4 P0.1\n") if (verbose == true) then if(presetVolts > 0) then post.Text ( " (Preset Volts: ",presetVolts,")\n " ) else post.Eol() end if (fullTAP ~=0) then --check to see if full tap if(presetAmps >0) then post.Text ( " (Preset AMPS: " ,presetAmps,") ") post.Eol() else post.Eol() end if(presetPSI>0) then post.Text ( " (Air Pressure Preset: " ,presetPSI,") ") post.Eol() end if (softPierce > 0 ) then softPierce2 = (softPierce / 10) if (softPierce2 >= 10 ) then softPierce2 = 0 end else softPierce2 = 0 end -- end softpierce if(softPierce2 > 0 ) then post.Text (" (Soft Pierce : " ,softPierce," percent ) ") post.Eol() else -- post.Text (" (Soft pierce is off )") --post.Eol() end end -- end of fullTap check --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(scriberAxis and scriberAxis == currentZAxis) then --always use Z as the Z axis endZ = safeZ OnRapid() currentZAxis = "Z" end 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(fullTAP ~= 0) then --check for TAP being used if(presetAmps > 0) then post.Text( " M68 E0 Q4" ,presetAmps, " ") if (verbose == true) then post.Text (" (Preset Amps set to ", presetAmps, " Amps)") end post.Eol() post.Text (" G4 P.1") post.Eol() end -- end presetAMPS if(presetPSI > 0) then post.Text( " M68 E0 Q8" ,presetPSI, " ") if (verbose == true) then post.Text (" (Air pressure set to ", presetPSI, " PSI)") end post.Eol() post.Text (" G4 P.1") post.Eol() else post.Text("(Default Air Pressure)") post.Eol() end --end presetPSI end --end check for fullTAP 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 --StatThcOff() --after loading values turn off the DTHC 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 ") if (warnings == true) then post.Text ("(MSG, The PAUSE after this message is to allow the Operator to check the DTHC settings to confirn they are loaded from the G-Code and are correct. If you need to change anything do it before you hit the RESUME button to continue) \n") post.Text (" M1 \n")--pasue for operator response else -- post.Text (" M1") post.Text (" (Pause warning off)\n") post.Text ("( ###########################)\n") end --end warnings end -- end of plasma tool loop if (toolClass == "MarkerTool") and (toolName =="PenMarker") then post.Text (" (Pen Marker NO DTHC)\n") post.Text (" M68 E0 Q999\n") post.Text (" G4 P.1") post.Eol() firstRef = true --added 7/24 to reffirst on a merker tool bef in mixed sequence cuts if (scriberAxis and scriberAxis ~= currentZAxis) then --use scriberAxis for Z endZ = safeZ OnRapid() currentZAxis = scriberAxis end else --plate marker not pen if(toolClass == "MarkerTool" ) then post.Text (" (Plate Marker NO DTHC)\n") post.Text (" M68 E0 Q999\n") post.Text (" G4 P.1") post.Eol() firstRef = true --added 7/24 to reffirst on a merker tool bef in mixed sequence cuts if(scriberAxis and scriberAxis ~= currentZAxis) then --use scriberAxis for Z endZ = safeZ OnRapid() currentZAxis = scriberAxis end end --end markertool loop end --end for toolchangefunction function OnNewPart() post.Text(" (Part: ",partName,")\n"); end function OnDrillStart() --May want to put something in here end function OnDrill() if (plasmaDrill > 0 ) then if (thcstate == 1) then ThcOff() end OnRapid() currentX = endX currentY = endY OnPenDown() endZ = drillZ --OnMove() OnPenUp() endZ = safeZ OnRapid() else-- its a normal drill if (thcstate == 1) then ThcOff() end OnRapid() depth = drillStart buffer = plungeSafety endZ = depth + buffer OnRapid() if(drillRetract < buffer) then buffer = drillRetract end while depth > drillZ do OnRapid() depth = depth - drillPeck if (depth < drillZ) then depth = drillZ end endZ = depth OnMove() if (depth > drillZ) then --retract if we need to take another bite endZ = endZ + drillRetract if (endZ > safeZ) then endZ = safeZ end OnRapid() end endZ = depth + buffer end if (endZ < safeZ) then endZ = safeZ OnRapid() end end end -- end function