Modifying a postprocessor

Hi,

I’m using the trail version and I’m thinking of buying it.
But first, I have some problems that I want to fix.

I use usbcnc from EdingCNC for my homemade plasma table.
I use the Mach3-plasma post processor which I have modified a little, because my tool-out is broken, and I’m now using flood-out to light up the torch.

I don’t have a THC and I’m not planning on buying / making one.
The easy fix for this, is that I zero the torch before every cut.
The zeroing go’s automatically. There is a switch in the torch and when it touches the plate it zero’s.
Calling a simple subroutine triggers the zero action.

Currently, I put in the code line for zeroing in the G-code by hand but I prefer it to go automatically.

Code looks like this:

N0100 M06 T1 F850.0 (Plasma) // toolchange and speed
N0110 G00 Z10.0000 // go rapid to Z-height 10
N0120 X50.0000 Y50.0000 // go rapid to coordinate
N0130 Z3.0000 // Set Z to pierce height
N0140 M08 // ignite torch (using the flood to ignite)
N0150 G04 P0.5 // wait 0,5 second - pierce delay
N0160 G01 Z2.0000 F100.0 // go to cut height
N0170 … // start cutting

Code should be like this:

N0100 M06 T1 F850.0 (Plasma) // toolchange and speed
N0110 G00 Z10.0000 // go rapid to Z-height 10
N0120 X50.0000 Y50.0000 // go rapid to coordinate
N0130 GOSUB TN // this line calls the zeroing subrouting
N0140 Z3.0000 // Set Z to pierce height
N0150 M08 // ignite torch (using the flood to ignite)
N0160 G04 P0.5 // wait 0,5 second - pierce delay

anyone an idea

Follow the link and seit in action
http://www.youtube.com/watch?v=7ihHJ668CgQ&feature=share&list=UU_02lxTs_aKEsYCMfmnW96g

Thanks Sjuul CNC

Add this code just before you outpur the M08:
Post.Text(" GOSUB TN\N")
post.ModalText (" G00")
post.Text(" Z")
post.Number (pierceHeight * scale, “0.0000”)
post.Eol()


By the way, are you using the USBCNC plugin for SheetCam?

Thanks Les.

By the way, are you using the USBCNC plugin for SheetCam?"

No, I’m using USBCNC from EdingCNC
http://www.edingcnc.com/index.php?pagina=2_home&taalid=2

maby you mean usbcnc from planet cnc
http://www.planet-cnc.com/

unfortunately it didn’t work, i think i placed the code at the wrong place i think
I’m not a great programmer, this is my complete post processor code:

function OnAbout(event)
   ctrl = event:GetTextCtrl()
   ctrl:AppendText("Mach3 plasma post processor\n")
   ctrl:AppendText("\n")
   ctrl:AppendText("Generic plasma post for machines without THC\n")
   ctrl:AppendText("\n")
   ctrl:AppendText("Modal G-codes and coordinates\n")
   ctrl:AppendText("Comments enclosed with ( and )\n")
   ctrl:AppendText("M08/M09 turn the torch on/off\n")
   ctrl:AppendText("Incremental IJ\n")
end


--  revision 3/2/07
--  Removed final safety move. This is now done in SheetCam

--   revision 7/10/05
--   Added new arc handling

--   revision 11/7/05
--   Moved torch to cut height when preheating
--   Added dummy spindle speed to prevent Mach2 throwing a zero spindle speed error

--   revision 9/10/04
--   Added preheat

--   revision 28/6/04
--   Replaced startx,y,z with currentx,y,z

--   created 28/5/04
--   Based on Mach2 metric.post



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 (" G53 G90 G0 G40\n F1\n S500\n")
   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()
   post.Text (" M09 M30\n")
end

function OnRapid()
   post.ModalText (" G00")
   post.ModalNumber (" X", endX * scale, "0.0000")
   post.ModalNumber (" Y", endY * scale, "0.0000")
   post.ModalNumber (" Z", endZ * scale, "0.0000")
   post.Eol()
end

function OnMove()
   post.ModalText (" G01")
   post.ModalNumber (" X", endX * scale, "0.0000")
   post.ModalNumber (" Y", endY * scale, "0.0000")
   post.ModalNumber (" Z", endZ * scale, "0.0000")
   post.ModalNumber (" F", feedRate * scale, "0.0###")
   post.Eol()
end

function OnArc()
   if&#40;arcAngle <0&#41; then
      post.ModalText &#40;" G03"&#41;
   else
      post.ModalText &#40;" G02"&#41;
   end
   post.NonModalNumber &#40;" X", endX * scale, "0.0000"&#41;
   post.NonModalNumber &#40;" Y", endY * scale, "0.0000"&#41;
   post.ModalNumber &#40;" Z", endZ * scale, "0.0000"&#41;
   post.Text &#40;" I"&#41;
   post.Number &#40;&#40;arcCentreX - currentX&#41; * scale, "0.0000"&#41;
   post.Text &#40;" J"&#41;
   post.Number &#40;&#40;arcCentreY - currentY&#41; * scale, "0.0000"&#41;
   post.ModalNumber &#40;" F", feedRate * scale, "0.0###"&#41;
   post.Eol&#40;&#41;
end


function OnPenDown&#40;&#41;
   if &#40;preheat > 0.001&#41; then
      post.ModalText &#40;" G00"&#41;
      post.ModalNumber &#40;" Z", cutHeight * scale, "0.0000"&#41;
      post.Text &#40;"\n G04 P"&#41;
      post.Number &#40;preheat,"0.###"&#41;
      post.Eol&#40;&#41;
   end
   post.ModalText &#40;" G00"&#41;
   post.ModalNumber &#40;" Z", pierceHeight * scale, "0.0000"&#41;
   post.Text &#40;"\n M08\n"&#41;
   if &#40;pierceDelay > 0.001&#41; then
      post.Text &#40;" G04 P"&#41;
      post.Number &#40;pierceDelay,"0.###"&#41;
      post.Eol&#40;&#41;
   end
end


function OnPenUp&#40;&#41;
   post.Text &#40;" M09\n"&#41;
   if &#40;endDelay > 0&#41; then
      post.Text &#40;" G04 P"&#41;
      post.Number &#40;endDelay,"0.###"&#41;
      post.Eol&#40;&#41;
   end
end


function OnNewOperation&#40;&#41;
   post.Text &#40;" &#40;Operation&#58; ", operationName, "&#41;\n"&#41;
end

function OnComment&#40;&#41;
  post.Text&#40;" &#40;",commentText,"&#41;\n"&#41;
end

function OnToolChange&#40;&#41;
   post.Text &#40;" M06 T"&#41;
   post.Number &#40;tool, "0"&#41;
   post.ModalNumber&#40;" F",feedRate * scale,"0.0###"&#41;
   post.Text &#40;"  &#40;", toolName, "&#41;\n"&#41;
   if &#40;plungeRate <= 0&#41; then
      post.Warning&#40;"WARNING&#58; Plunge rate is zero"&#41;
   end
   if &#40;feedRate <= 0&#41; then
      post.Warning&#40;"WARNING&#58; Feed rate is zero"&#41;
   end
end

function OnNewPart&#40;&#41;
   post.Text&#40;" &#40;Part&#58; ",partName,"&#41;\n"&#41;;
end

function OnDrill&#40;&#41;
   OnRapid&#40;&#41;
   OnPenDown&#40;&#41;
   endZ = drillZ
   OnMove&#40;&#41;
   OnPenUp&#40;&#41;
   endZ = safeZ
   OnRapid&#40;&#41;
end

This should do the trick:

function OnAbout&#40;event&#41;
   ctrl = event&#58;GetTextCtrl&#40;&#41;
   ctrl&#58;AppendText&#40;"Mach3 plasma post processor\n"&#41;
   ctrl&#58;AppendText&#40;"\n"&#41;
   ctrl&#58;AppendText&#40;"Generic plasma post for machines without THC\n"&#41;
   ctrl&#58;AppendText&#40;"\n"&#41;
   ctrl&#58;AppendText&#40;"Modal G-codes and coordinates\n"&#41;
   ctrl&#58;AppendText&#40;"Comments enclosed with &#40; and &#41;\n"&#41;
   ctrl&#58;AppendText&#40;"M08/M09 turn the torch on/off\n"&#41;
   ctrl&#58;AppendText&#40;"Incremental IJ\n"&#41;
end


--  revision 3/2/07
--  Removed final safety move. This is now done in SheetCam

--   revision 7/10/05
--   Added new arc handling

--   revision 11/7/05
--   Moved torch to cut height when preheating
--   Added dummy spindle speed to prevent Mach2 throwing a zero spindle speed error

--   revision 9/10/04
--   Added preheat

--   revision 28/6/04
--   Replaced startx,y,z with currentx,y,z

--   created 28/5/04
--   Based on Mach2 metric.post



function OnInit&#40;&#41;

   post.SetCommentChars &#40;"&#40;&#41;", "&#91;&#93;"&#41;  --make sure &#40; and &#41; characters do not appear in system text
   post.Text &#40;" &#40;Filename&#58; ", fileName, "&#41;\n"&#41;
   post.Text &#40;" &#40;Post processor&#58; ", postName, "&#41;\n"&#41;
   post.Text &#40;" &#40;Date&#58; ", date, "&#41;\n"&#41;
   if&#40;scale == metric&#41; then
      post.Text &#40;" G21 &#40;Units&#58; Metric&#41;\n"&#41; --metric mode
   else
      post.Text &#40;" G20 &#40;Units&#58; Inches&#41;\n"&#41; --inch mode
   end
   post.Text &#40;" G53 G90 G0 G40\n F1\n S500\n"&#41;
   bigArcs = 1 --stitch arc segments together
   minArcSize = 0.05 --arcs smaller than this are converted to moves
end

function OnNewLine&#40;&#41;
   post.Text &#40;"N"&#41;
   post.Number &#40;lineNumber, "0000"&#41;
   lineNumber = lineNumber + 10
end


function OnFinish&#40;&#41;
   post.Text &#40;" M09 M30\n"&#41;
end

function OnRapid&#40;&#41;
   post.ModalText &#40;" G00"&#41;
   post.ModalNumber &#40;" X", endX * scale, "0.0000"&#41;
   post.ModalNumber &#40;" Y", endY * scale, "0.0000"&#41;
   post.ModalNumber &#40;" Z", endZ * scale, "0.0000"&#41;
   post.Eol&#40;&#41;
end

function OnMove&#40;&#41;
   post.ModalText &#40;" G01"&#41;
   post.ModalNumber &#40;" X", endX * scale, "0.0000"&#41;
   post.ModalNumber &#40;" Y", endY * scale, "0.0000"&#41;
   post.ModalNumber &#40;" Z", endZ * scale, "0.0000"&#41;
   post.ModalNumber &#40;" F", feedRate * scale, "0.0###"&#41;
   post.Eol&#40;&#41;
end

function OnArc&#40;&#41;
   if&#40;arcAngle <0&#41; then
      post.ModalText &#40;" G03"&#41;
   else
      post.ModalText &#40;" G02"&#41;
   end
   post.NonModalNumber &#40;" X", endX * scale, "0.0000"&#41;
   post.NonModalNumber &#40;" Y", endY * scale, "0.0000"&#41;
   post.ModalNumber &#40;" Z", endZ * scale, "0.0000"&#41;
   post.Text &#40;" I"&#41;
   post.Number &#40;&#40;arcCentreX - currentX&#41; * scale, "0.0000"&#41;
   post.Text &#40;" J"&#41;
   post.Number &#40;&#40;arcCentreY - currentY&#41; * scale, "0.0000"&#41;
   post.ModalNumber &#40;" F", feedRate * scale, "0.0###"&#41;
   post.Eol&#40;&#41;
end


function OnPenDown&#40;&#41;
   if &#40;preheat > 0.001&#41; then
      post.ModalText &#40;" G00"&#41;
      post.ModalNumber &#40;" Z", cutHeight * scale, "0.0000"&#41;
      post.Text &#40;"\n G04 P"&#41;
      post.Number &#40;preheat,"0.###"&#41;
      post.Eol&#40;&#41;
   end
   post.Text&#40;" GOSUB TN\n"&#41;
   post.ModalText &#40;" G00"&#41;
   post.NonModalNumber &#40;" Z", pierceHeight * scale, "0.0000"&#41;
   post.Text &#40;"\n M08\n"&#41;
   if &#40;pierceDelay > 0.001&#41; then
      post.Text &#40;" G04 P"&#41;
      post.Number &#40;pierceDelay,"0.###"&#41;
      post.Eol&#40;&#41;
   end
end


function OnPenUp&#40;&#41;
   post.Text &#40;" M09\n"&#41;
   if &#40;endDelay > 0&#41; then
      post.Text &#40;" G04 P"&#41;
      post.Number &#40;endDelay,"0.###"&#41;
      post.Eol&#40;&#41;
   end
end


function OnNewOperation&#40;&#41;
   post.Text &#40;" &#40;Operation&#58; ", operationName, "&#41;\n"&#41;
end

function OnComment&#40;&#41;
  post.Text&#40;" &#40;",commentText,"&#41;\n"&#41;
end

function OnToolChange&#40;&#41;
   post.Text &#40;" M06 T"&#41;
   post.Number &#40;tool, "0"&#41;
   post.ModalNumber&#40;" F",feedRate * scale,"0.0###"&#41;
   post.Text &#40;"  &#40;", toolName, "&#41;\n"&#41;
   if &#40;plungeRate <= 0&#41; then
      post.Warning&#40;"WARNING&#58; Plunge rate is zero"&#41;
   end
   if &#40;feedRate <= 0&#41; then
      post.Warning&#40;"WARNING&#58; Feed rate is zero"&#41;
   end
end

function OnNewPart&#40;&#41;
   post.Text&#40;" &#40;Part&#58; ",partName,"&#41;\n"&#41;;
end

function OnDrill&#40;&#41;
   OnRapid&#40;&#41;
   OnPenDown&#40;&#41;
   endZ = drillZ
   OnMove&#40;&#41;
   OnPenUp&#40;&#41;
   endZ = safeZ
   OnRapid&#40;&#41;
end

In SheetCam if you go to the plugins menu you should see an option ‘Enable USBCNC’. If you turn that on you should get a window that allows you to control your machine from within SheetCam. It will also automatically load the G-code into USBCNC when you run the post processor. Note that when the code is loaded into USBCNC it is not shown in the USBCNC main program. However it will run correctly.

It does, that saves me so much work
thank Les.

I don’t use the plugin, I generate the G-code in home before I take it to the workshop on a stick.

Sjuul CNC