function OnAbout(event) ctrl = event:GetTextCtrl() ctrl:AppendText("Designed for use with Mach4 and MachMotion's X15-250-PK(xxxx) controls, with the Neuron Torch Height Controller.\n") ctrl:AppendText("Last Updated on 04-20-16\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("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.8 LasttoolClass = "" THCDisable = false --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) post.DefineCustomToolParam("PlasmaTool", "Amperage", "Amperage", sc.unit4DECPLACE, 40, 0, 600) post.DefineCustomToolParam("PlasmaTool", "Arc Voltage", "ArcVoltage", sc.unit4DECPLACE, 110, 0, 350) post.DefineCustomToolParam("FlameTool", "Preheat Height", "PreheatHeight", sc.unitLINEAR, 2.54, 0, 75) 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") post.Text (" (Material: Type: , Thickness: ", materialThick * scale,")\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\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 * scale) > 10000 or (endY * scale) > 10000 then return end if(math.hypot(endX-currentX , endY-currentY) < 0.001) then return end 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 * scale) > 10000 or (endY * scale) > 10000 then return end --if(math.hypot(endX-currentX , endY-currentY) < 0.001) then return end --Carl removed this line on 12-5-16 post.Text (" G01") post.NonModalNumber (" X", endX * scale, "0.0000") post.NonModalNumber (" Y", endY * scale, "0.0000") post.ModalNumber (" 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 --feed = feedRate 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.Text (" J") post.Number ((arcCentreY) * scale, "0.0000") post.ModalNumber (" F", feed * scale, "0.0###") post.Eol() end function OnPenDown() if (toolClass == "MarkerTool") then OnRapid() post.Eol() post.Text (" M70 ") post.Text (" (Plate Marker Down)") post.Eol() post.CancelModalNumbers() elseif (toolClass == "PlasmaTool") or (toolClass == "FlameTool") then post.Eol() post.Text(" M3 (Torch Down, Torch On)\n") post.Eol() post.CancelModalNumbers() end --if(toolClass == "FlameTool") then -- post.Eol() -- post.Text(" M460 (PreHeat, Cut On, Pierce Delay)\n") -- post.CancelModalNumbers() --end end function OnPenUp() if (toolClass == "MarkerTool") then post.Eol() post.Text (" M71 ") post.Text (" (Plate Marker Up)") post.Eol() elseif (toolClass == "PlasmaTool") or (toolClass == "FlameTool") then post.Text (" M5 (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 (LasttoolClass ~= toolClass) and (toolClass == "PlasmaTool") then local TempArcVoltage = 0 local TempAmperage = 0 if ArcVoltage ~= nil and ArcVoltage > 0 then TempArcVoltage = ArcVoltage end if Amperage ~= nil and Amperage > 0 then TempAmperage = Amperage end post.Text (" (Plasma: Pierce Height: ") if pierceHeight > 0 then post.Number (pierceHeight * scale, "0.0000") end post.Text (" Pierce Time: ") if pierceDelay > 0 then post.Number (pierceDelay, "0.0000") end post.Text (")") post.Eol() post.Text (" (Plasma: Cut Height: ") if cutHeight > 0 then post.Number (cutHeight * scale, "0.0000") end post.Text (")") post.Eol() post.Text (" (Plasma: Arc Voltage: ") if TempArcVoltage > 0 then post.Number (TempArcVoltage, "0.0000") end post.Text (" Amperage: ") if TempAmperage > 0 then post.Number (TempAmperage, "0.0000") end post.Text (")") post.Eol() end if (LasttoolClass ~= toolClass) and (toolClass == "FlameTool") then local TempPreheatHeight = 0 if PreheatHeight ~= nil and PreheatHeight > 0 then TempPreheatHeight = PreheatHeight * scale end post.Text (" (Flame: Preheat Height: ") if TempPreheatHeight > 0 then post.Number (TempPreheatHeight, "0.0000") end post.Text (" Preheat Time: ") if preheat > 0 then post.Number (preheat, "0.0000") end post.Text (")") post.Eol() post.Text (" (Flame: Pierce Height: ") if pierceHeight > 0 then post.Number (pierceHeight * scale, "0.0000") end post.Text (" Pierce Time: ") if pierceDelay > 0 then post.Number (pierceDelay, "0.0000") end post.Text (")") post.Eol() post.Text (" (Flame: Cut Height: ") if cutHeight > 0 then post.Number (cutHeight * scale, "0.0000") end post.Text (")") post.Eol() end if (LasttoolClass == "DrillTool") and (toolClass ~= "DrillTool") then --turn off spindle post.Text (" M5 (Spindle Off)") post.Eol() end if (toolClass == "PlasmaTool") then post.Text (" M06 T1") elseif (toolClass == "FlameTool") then post.Text (" M06 T2") elseif (toolClass == "MarkerTool") then post.Text (" M06 T10") elseif (toolClass == "DrillTool") then post.Text (" M06 T") post.Number (tool, "0") post.Eol() post.Text (" M3 (Spindle On)") end post.Text (" (", toolName, ")\n") if (feedRate <= 0) then post.Warning("WARNING: Feed rate is zero") end if toolClass == "DrillTool" and spindleSpeed > 0 then post.Eol() post.Text(" S") post.Number(spindleSpeed, "0.0###") post.Text(" (Spindle Speed)") post.Eol() end post.NonModalNumber(" F", feedRate * scale, "0.###") LasttoolClass = toolClass end function OnNewPart() post.Text(" (Part: ",partName,")\n"); end function OnDrill() if toolClass == "PlasmaTool" then OnRapid() post.Eol() post.Text (" M3 ") post.Text (" (Plasma Pierce)") post.Eol() post.Text (" M5 ") post.Text (" (Retract)") post.Eol() else OnRapid() post.Eol() post.Text (" M80 ") post.Text (" (Drill Cycle)") post.Eol() end end --[[function ThcOff() if THCDisable ~= true then post.Eol() post.ModalText (" M62 P60 (THC Freeze On)") post.Eol() THCDisable = true end end function ThcOn() if THCDisable ~= false then post.Eol() post.Text (" M63 P60 (THC Freeze Off)") post.Eol() THCDisable = false end end --]]