function OnAbout(event) ctrl = event:GetTextCtrl() ctrl:AppendText("Designed for use with Mach3 and MachMotion's X15-250-PK(xxxx) controls, with the 301d Torch Height Controller.\n") ctrl:AppendText("Last Updated on 09-06-14\n") ctrl:AppendText("\n") ctrl:AppendText("Post Processor Comments:\n") ctrl:AppendText("Modal G-codes and coordinates\n") ctrl:AppendText("Comments enclosed with ( and )\n") ctrl:AppendText("M418 Is the initialization macro to ensure everything is setup correctly\n") ctrl:AppendText("M419 Needs to be added into Mach3's initialization string\n") ctrl:AppendText("M460 Auto torch reference, torch on, pierce delay. Cut height configurable on the control, along with reference feedrate\n") ctrl:AppendText("M422 Controls all the positive Z moves\n") ctrl:AppendText("M430 Controls the drill cycle\n") ctrl:AppendText("M431 Sends the drill bit size needed to the control\n") ctrl:AppendText("M6 Toolchange: Tools 1-99 are plasma, 100-249 are drill bits, and 250-255 custom/marker-tools.\n") ctrl:AppendText("Post variables:\n") ctrl:AppendText("Ref distance - set the distance between each reference\n") end --The cutter will slow down for corners and turn off THC below this radius SlowRadius = 15.8750 --Minimum slow down speed. --This is a scale factor. For instance 0.5 = 50% of the current feed rate SlowPercent = 0.4 -- This breaks the arc's up in 90 degree segments post.SetOptions(post.ARC_SEGMENTS) post.DefineVariable("SlowRadius",sc.unitLINEAR,-1e17,1e17) post.DefineVariable("SlowPercent",sc.unitPERCENT,-1e17,1e17) function OnInit() 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 (" G90 G90.1 G40 S500 M418\n") switchoffset = 0 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 (" M05 (Torch Off)\n") post.Text (" M30 (Program Rewind)\n") end function OnRapid() if endX > 10000 or endY > 10000 then return end if(math.hypot(endX-currentX , endY-currentY) < 0.001) then return end -- post.Text (" M422 (Torch Up)") post.Eol() post.Text (" G00") post.NonModalNumber (" X", endX * scale, "0.0000") post.NonModalNumber (" Y", endY * scale, "0.0000") post.Eol() end function OnMove() if endX > 10000 or endY > 10000 then return end if(math.hypot(endX-currentX , endY-currentY) < 0.001) then return end post.Text (" G01") post.NonModalNumber (" X", endX * scale, "0.0000") post.NonModalNumber (" Y", endY * scale, "0.0000") post.NonModalNumber (" F", feedRate * scale, "0.###") post.Eol() end --function OnArc() -- post.ArcAsMoves(0.01) --end function OnArc() local radius = math.hypot(currentX - arcCentreX, currentY - arcCentreY) if (radius < SlowRadius) and (math.abs(arcAngle) > 0.5) then feed = (radius / SlowRadius) if(feed < SlowPercent) then feed = SlowPercent end feed = feed * feedRate -- ThcOff() else feed = feedRate -- ThcOn() end if(arcAngle <0) then post.Text(" G03") else post.Text(" G02") end post.NonModalNumber (" X", endX * scale, "0.0000") post.NonModalNumber (" Y", endY * scale, "0.0000") post.Text (" I") post.Number ((arcCentreX) * scale, "0.0000") --post.Number ((arcCentreX - currentX) * scale, "0.0000") This is for incremental IJ mode post.Text (" J") post.Number ((arcCentreY) * scale, "0.0000") --post.Number ((arcCentreY - currentY) * scale, "0.0000") This is for incremental IJ mode post.NonModalNumber (" F", feed * scale, "0.0###") post.Eol() end function OnPenDown() if (toolClass == "MarkerTool") then post.Eol() post.Text (" M435 ") post.Text (" (Plate Marker Down)") post.Eol() post.CancelModalNumbers() if (pierceDelay > 0) then post.Text (" G04 P") post.Number (pierceDelay,"0.###") post.Text (" (Delay)") post.Eol() end end if(toolClass == "FlameTool") then post.Eol() post.Text(" M460 (PreHeat, Cut On, Pierce Delay)\n") post.CancelModalNumbers() end if (toolClass == "PlasmaTool") then post.Eol() post.Text(" M460 (Torch Reference, Torch On, Pierce Delay)\n") post.Eol() post.CancelModalNumbers() end end function OnPenUp() if (toolClass == "MarkerTool") then post.Eol() post.Text (" M436 ") post.Text (" (Plate Marker Up)") post.Eol() elseif(toolClass == "FlameTool") then post.Text (" M461 (Oxy Fuel Off, Up)\n") else post.Text (" M461 (Torch Off, Torch Up)\n") end if (endDelay > 0) then post.Text (" G04 P") post.Number (endDelay,"0.###") post.Text (" (Delay)") post.Eol() end end function OnNewOperation() post.Text (" (Process: ", operationName, ")\n") end function OnComment() post.Text(" (",commentText,")\n") end function OnToolChange() if toolClass == "DrillTool" then post.Text(" M431 P ") post.Number(toolDia * scale, "0.0###") post.Text(" Q ") post.Number(spindleSpeed, "0.0###") post.Text(" R ") post.Number(plungeRate, "0.0###") post.Eol() end if toolClass == "MarkerTool" then --post.Text("Arc voltage is PlateMarker") end post.Text (" M06 T") post.Number (tool, "0") post.Text (" (", toolName, ")\n") if (feedRate <= 0) then post.Warning("WARNING: Feed rate is zero") end end function OnNewPart() post.Text(" (Part: ",partName,")\n"); end function OnDrill() OnRapid() post.Eol() post.Text (" M430 ") post.Text (" (Drill Cycle)") post.Eol() end