-- ***************************************************************************** -- * USER OPTIONS: change to suit * -- * * -- * cParms & pmx485 show custom PlasmaC parameters in the SheetCam tool file. * -- * SheetCam does not use them but they are read by PlasmaCs materialverter * -- * to import parameters into the PlasmaC material file from a SheetCam * -- * toolset file. * -- * * -- * The PlasmaC GCode parser will remove line numbers so they don't show in * -- * in the GUI but if enabled here they will appear in any GCode file saved * -- * from SheetCam. * -- ***************************************************************************** cParms = 0 -- set to 1 to show basic custom parameters pmx485 = 0 -- set to 1 to show RS485 parameters lineNumbers = 0 -- set to 1 to show linenumbers noArcs = 0 -- set to 1 to convert arcs to line segments matPrompt = 0 -- set to 1 to bypass material prompt for material #0 -- *** DO NOT CHANGE ANYTHING BELOW THIS LINE ********************************** revNum = '8' revDate = 'Dec 23 2021' if cParms == 1 then post.DefineCustomToolParam('PlasmaTool', 'Puddle jump height', 'pjHeight', sc.unit1DECPLACE, 0, 0, 200) post.DefineCustomToolParam('PlasmaTool', 'Puddle jump delay', 'pjDelay', sc.unit2DECPLACE, 0, 0, 9) post.DefineCustomToolParam('PlasmaTool', 'THC enable', 'thcEnable', sc.unitBOOLEAN, 1, 0, 1) post.DefineCustomToolParam('PlasmaTool', 'Cut voltage', 'cutVolts', sc.unit0DECPLACE, 99, 0, 200) end if pmx485 == 1 then post.DefineCustomToolParam('PlasmaTool', 'Cut current', 'cutAmps', sc.unit0DECPLACE, 45, 10, 200) post.DefineCustomToolParam('PlasmaTool', 'Gas pressure', 'gasPressure', sc.unit0DECPLACE, 0, 0, 150) post.DefineCustomToolParam('PlasmaTool', 'Cut mode', 'cutMode', sc.unit0DECPLACE, 1, 1, 3) end function OnAbout(event) ctrl = event:GetTextCtrl() ctrl:AppendText('For a PlasmaC configuration on LinuxCNC\n\n') ctrl:AppendText('Revision: ' .. revNum .. ' - ' .. revDate .. '\n') end function OnInit() post.SetCommentChars ('()', '[]') --ensure ( ) characters do not appear in system text post.Text ('; file name: ', fileName, '\n') post.Text ('; date and time: ', os.date('%a') , ' ', os.date('%b') , ' ', os.date('%d') , ' ', os.date('%Y') , ' ', time, '\n') post.Text ('; postprocessor: ', postName, ' rev: ', revNum, '\n') post.Text (';\n') post.Text (';begin pre-amble\n') if scale == metric then minimumMove = '0.000001' post.Text (' G21 (units: metric)\n') --metric mode units = 'mm' precision = '0.000' else post.Text (' G20 (units: inches)\n') --inch mode minimumMove = '0.00000004' units = '"' precision = '0.00000' end post.Text (' G40 (cutter compensation: off)\n') post.Text (' G90 (distance mode: absolute)\n') post.Text (' M52 P1 (adaptive feed: on)\n') post.Text (' M65 P2 (enable THC)\n') post.Text (' M65 P3 (enable torch)\n') post.Text (' M68 E3 Q0 (velocity 100%)\n') if scale == metric then post.Text (' G64 P0.254 Q0.025 (tracking tolerances: 0.254mm)\n') else post.Text (' G64 P0.01 Q0.001 (tracking tolerances: 0.01")\n') end post.Text (' F#<_hal[plasmac.cut-feed-rate]>\n') post.Text (';end pre-amble\n') post.Text (';\n') bigArcs = 1 --stitch arc segments together minArcSize = 0.2 --arcs smaller than this are converted to moves cut = 1 cutLength = 0 cutType = 'Cutting' cutName = 'cut' pierces = 0 spots = 0 scribes = 0 scribeLength = 0 oldTool = 0 drilling = 0 end function OnNewLine() if lineNumbers == 1 then post.Text ('N') post.Number (lineNumber, '00000') post.Text (' ') lineNumber = lineNumber + 10 end end function OnComment() post.Text('(',commentText,')\n') end function OnToolChange() post.Text (';begin material setup\n') if string.match (toolName, 'Air Scribe') or string.match (toolName, 'Engraver') or string.match(toolClass, 'MarkerTool') then cutType = 'Scribing' cutName = 'scribe' spindleNum = 1 toolNum = 1 elseif string.match (toolName, 'Centre Spot') or string.match (toolName, 'Center Spot') or string.match(operationClass, 'DrillOperation') then cutType = 'Spotting' cutName = 'spot' spindleNum = 2 toolNum = 0 else cutType = 'Cutting' cutName = 'cut' spindleNum = 0 toolNum = 0 end if toolNum ~= oldTool then post.Text (' T', toolNum, ' M6 (select ', string.lower(cutType), ' tool)\n') post.Text (' G43 H0 (apply tool offsets)\n') post.Text (';\n') oldTool = toolNum end if tool == 0 and matPrompt == 0 then post.Text ('; Use manually selected tool\n') post.Text ('(msg,Ensure correct material is selected then press RESUME to continue)\n') post.Text (' M1\n') else post.Text (' M190 P' , tool,' (',string.lower(toolName), ' material)\n') post.Text (' M66 P3 L3 Q2 (wait for valid change)\n') end post.Text (' F#<_hal[plasmac.cut-feed-rate]>\n') post.Text (';end material setup\n') end function OnPenDown() post.Text ('\n M3 $', spindleNum, ' S1 (', cutName, ' start)\n') if cutType == 'Scribing' then scribeLength = scribeLength + (entityLength * scale) scribes = scribes + 1 elseif cutType == 'Spotting' then post.Text (' G91 (relative distance mode)\n') post.Text (' G1 X', minimumMove, ' (tiny move)\n') post.Text (' G90 (absolute distance mode)\n') spots = spots + 1 else cutLength = cutLength + (entityLength * scale) pierces = pierces + 1 end entityLength = 0 end function OnPenUp() post.Text ('\n M5 $', spindleNum, '(', cutName, ' stop)\n') if string.match (toolName, 'Air Scribe') then post.Text (' G4 P1 (pause for scribe retract)\n') end post.Text (';end ', string.lower(partName), ', ',string.lower(cutType), ' #', cut, '\n') cut = cut + 1 end function OnRapid() if math.hypot(endX - currentX, endY - currentY) < tonumber(minimumMove) then return end if (entityLength and entityLength >= tonumber(minimumMove)) or drilling == 1 then post.Text (';\n;begin ', string.lower(partName), ' #', cut, ', ',string.lower(cutType)) if cutType == 'Cutting' or cutType == 'Scribing' then post.Text (', ') post.Number (entityLength * scale, '0.00') post.Text (units) end else post.Text (';\n;park torch\n') end post.Text ('\n') post.ModalText('') post.ModalText (' G0') post.NonModalNumber (' X', endX * scale, precision) post.NonModalNumber (' Y', endY * scale, precision) post.Text ('\n') end function OnMove() if cutType == 'Cutting' or cutType == 'Scribing' then if math.hypot(endX - currentX, endY - currentY) < tonumber(minimumMove) then return end post.ModalText('') post.ModalText (' G1') post.NonModalNumber (' X', endX * scale, precision) post.NonModalNumber (' Y', endY * scale, precision) post.Text ('\n') end end function OnArc() if cutType == 'Cutting' or cutType == 'Scribing' then if noArcs == 1 then post.ArcAsMoves(0.25) else post.ModalText('') if(arcAngle < 0) then post.ModalText (' G3') else post.ModalText (' G2') end post.NonModalNumber (' X', endX * scale, precision) post.NonModalNumber (' Y', endY * scale, precision) post.Text (' I') post.Number ((arcCentreX - currentX) * scale, precision) post.Text (' J') post.Number ((arcCentreY - currentY) * scale, precision) post.Text ('\n') end end end function OnDrill() if cutType == 'Spotting' then drilling = 1 OnRapid() OnPenDown() OnPenUp() drilling = 0 end end function OnFinish() post.Text (';\n;begin post-amble\n') if toolNum > 0 then post.Text (' T0 M6 (select torch)\n') post.Text (' G43 H0 (apply tool offsets)\n') if cutType == 'Scribing' then post.Text (' M65 P0\n') end end post.Text (' G40 (cutter compensation: off)\n') post.Text (' G90 (distance mode: absolute)\n') post.Text (' M65 P2 (enable THC)\n') post.Text (' M65 P3 (enable torch)\n') post.Text (' M68 E3 Q0 (velocity 100%)\n') post.Text (' M5 $-1 (backup stop)\n') post.Text (';end post-amble\n') post.Text (';\n') post.Text (';begin statistics\n') if spots > 0 then post.Text('\n; Spots = ', spots, '\n') end if pierces > 0 then post.Text('\n;Pierces = ', pierces, '\n') end if cutType == 'Cutting' then post.Text('\n; Cuts = ', pierces , ', Length = ') post.Number (cutLength, '0.00') post.Text (units, '\n') end if scribes > 0 then post.Text('\n;Scribes = ', scribes , ', Length = ') post.Number (scribeLength, '0.00') post.Text (units, '\n') end post.Text (';end statistics\n') post.Text (';\n') post.Text (' M30 (end program)\n') end