--************************************************ --*** Set these values up to suit your machine *** --************************************************ --this is the distance between each torch reference in MILLIMETRES refDistance = 75 --this is the reference feed rate in mm/min refFeed = 500 --Put your switch offset value here in MILLIMETRES switchOffset = 5 --Scriber X,Y,Z offsets in MILLIMETRES. Do not use inches here even if you want inch code --Use the special code 'nil' on the Z axis to disable it. --In that case no Z values will be output at all while scribing. --e.g scriberZ = nil scriberX = 0 scriberY = 0 scriberZ = 0 --scriber axis. --scriberAxis = "B" scriberAxis = "A" --If this value is set to true then use G28 (home) for the Z reference --Set it to false for G31 probe refHome = false --rotary axis. Normally this would be "A" rotaryAxis = "B" --Number of units for one full revolution of the rotary axis --Note: In Mach3 the axis should be defined as linear, not rotary! unitsPerRev=360 --************************************************ --*** End of settings *** --************************************************ function OnAbout(event) ctrl = event:GetTextCtrl() ctrl:AppendText("Post for rotary-plasma plugin and Mach3 with optional engraver\n") ctrl:AppendText("\n") ctrl:AppendText("Modal G-codes and coordinates\n") ctrl:AppendText("Comments enclosed with ( and )\n") ctrl:AppendText("M03/M05 turn the torch on/off\n") ctrl:AppendText("M08/M09 turn the engraver on/off\n") ctrl:AppendText("Incremental IJ - set in mach2\n") ctrl:AppendText("The torch is referenced at cut start and every 500mm of movement thereafter\n") ctrl:AppendText("Post variables:\n") ctrl:AppendText("refDistance - set the distance between each reference\n") ctrl:AppendText("refFeed - set the feed rate when referencing\n") ctrl:AppendText("switchOffset - set your net switch offset amount \n") ctrl:AppendText("Scriber uses any tool number\n") end -- created 1/1/06 -- Based on plasma1.post -- Modified 21/6/2010 -- added option for 'nil' plate marker z -- Added support for plate marker tool type as well as tool number based plate marker -- Modified 4/6/2019 -- Added -- G64P0.05 , for accuracy and for smooth rotation p > 0.05 -- Added -- post.ModalNumber (" S", power, "0.###") , for setting the plasma power post.DefineVariable("refDistance",sc.unitLINEAR,0,1e17) post.DefineVariable("refFeed",sc.unitFEED,0,1e17) post.DefineVariable("switchOffset",sc.unitLINEAR,-1e17,1e17) 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 (" G40 G90 G64P0.05\n F1 S1\n") --minArcSize = 0.2 --arcs smaller than this are converted to moves firstRef = true currentZAxis = "Z" dist = 9999999 lastz = 0 bigArcs = 1 --stitch arc segments together 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() endZ = safeZ OnRapid() -- endX = 0 endY = 0 offX = 0 offY = 0 offZ = 0 OnRapid() post.Text (" M05 M30\n") end function OnRapid() local len = math.hypot((endX + offX)-currentX , (endY + offY)-currentY) dist = dist + len post.ModalText (" G00") post.ModalNumber (" X", (endX + offX) * scale, "0.0000") post.ModalNumber (" Y", (endY + offY) * scale, "0.0000") post.ModalNumber (" " .. currentZAxis, (endZ + offZ) * scale, "0.0000") post.ModalNumber (" " .. rotaryAxis, endA, "0.0000") post.Eol() end function OnMove() local len = math.hypot(endX - currentX , endY - currentY) dist = dist + len post.ModalText (" G01") post.ModalNumber (" X", (endX + offX) * scale, "0.0000") post.ModalNumber (" Y", (endY + offY) * scale, "0.0000") post.ModalNumber (" " .. currentZAxis, (endZ + offZ) * scale, "0.0000") post.ModalNumber (" " .. rotaryAxis, endA, "0.0000") post.ModalNumber (" F", feedRate * scale, "0.0###") post.Eol() end function OnArc() local radius = math.hypot(currentX - arcCentreX, currentY - arcCentreY) dist = dist + radius * math.abs(arcAngle) if(arcAngle <0) then post.ModalText (" G03") else post.ModalText (" G02") end post.ModalNumber (" X", (endX + offX) * scale, "0.0000") post.ModalNumber (" Y", (endY + offY) * scale, "0.0000") if(offZ) then post.ModalNumber (" " .. currentZAxis, (endZ + offZ) * scale, "0.0000") end post.Text (" I") post.Number ((arcCentreX - currentX) * scale, "0.0000") post.Text (" J") post.Number ((arcCentreY - currentY) * scale, "0.0000") post.ModalNumber (" " .. rotaryAxis, endA, "0.0000") post.ModalNumber (" F", feedRate * scale, "0.0###") post.Eol() end function OnPenDown() sc.QueryDll(qryRAPIDY, endY, dllId) -- local matZ = sc.QueryDll(qryGETZ, 0, dllId) local matZ = sc.QueryDll(qryCHKEND, endY, dllId) if(toolClass == "MarkerTool") or tool > 99 then if (firstRef) then post.ModalText (" G00") post.Text(" Z") local clearZ = sc.QueryDll(qryGETSAFEZ, 0, dllId) post.Number ((clearZ + safeZ) * scale, "0.0000") post.Eol() offX = scriberX offY = scriberY offZ = scriberZ post.ModalNumber (" X", (currentX + offX) * scale, "0.0000") post.ModalNumber (" Y", (currentY + offY) * scale, "0.0000") post.Eol() end if (offZ) then post.ModalNumber (" " .. currentZAxis, (matZ + currentZ + offZ) * scale, "0.0000") post.Eol() end post.Text(" M08\n") else post.ModalText (" G00") post.Text(" Z") post.Number ((matZ + pierceHeight) * scale, "0.0000") post.Eol() if (preheat > 0) then post.Text ("\n G04 P") post.Number (preheat,"0.###") post.Eol() end post.ModalNumber (" S", power, "0.###") post.Text ("\n M03\n") end if (pierceDelay > 0) then post.Text (" G04 P") post.Number (pierceDelay,"0.###") post.Eol() end end function OnPenUp() if(tool > 99) then post.Text(" M09\n") else post.Text (" M05\n") end if (endDelay > 0) then post.Text (" G04 P") post.Number (endDelay,"0.###") post.Eol() end end function OnNewOperation() post.Text (" (Operation: ", operationName, ")\n") end function OnNewPart() post.Text(" (Part: ",partName,")\n"); end function OnDrill() OnRapid() OnPenDown() endZ = drillZ OnMove() OnPenUp() endZ = safeZ OnRapid() end package.path = sc.Globals:Get().thisDir .. "/plugins/RotaryPlasma/?.lua" require("rotaryhelper")