post processor resources

Here's the place for discussion related to CAM/CNC and the development of the Path module.
User avatar
sliptonic
Posts: 1318
Joined: Tue Oct 25, 2011 10:46 pm

Re: post processor resources

Postby sliptonic » Wed May 16, 2018 9:22 pm

There's definitely something wrong with the lead in/out dressup. It doesn't play well with an operation like face profile that his doing both the outer profile and the holes.
I disabled the holes and created a separate operation profiling the edge of the top left pocket and added the dressup to both. I also manually set the start points for both.

Those paths below look reasonable. The workflow, of course, is far from ideal.

I'll add a bug report for the leadin/out dressup.

I'm also going to add a feature request to re-implement the draft-snapper to make it easier to apply start points to a path.
edges.png
edges.png (8.94 KiB) Viewed 220 times
polemidis
Posts: 32
Joined: Thu Feb 09, 2017 4:58 pm

Re: post processor resources

Postby polemidis » Thu May 17, 2018 12:16 am

If that helps in resolving this bug it does not work well in edge profiling when I add a second hole to the base geometry.

Also Another question plz if I am not bugging you too much. From your image I can see your curve is smooth. On mine the curve is like a rough polygon. Can I adjust this resolution somewhere? Or is it something else? (I am considering that the tool diameter may also affect this?)
User avatar
sliptonic
Posts: 1318
Joined: Tue Oct 25, 2011 10:46 pm

Re: post processor resources

Postby sliptonic » Thu May 17, 2018 12:38 am

polemidis wrote:
Thu May 17, 2018 12:16 am
If that helps in resolving this bug it does not work well in edge profiling when I add a second hole to the base geometry.
Yep. For now, you would need to add a separate operation for each hole. Not ideal but the best we can do for now.
Also Another question plz if I am not bugging you too much.
Not bugging me at all. We're getting at real bugs and that's real progress. :D
From your image I can see your curve is smooth. On mine the curve is like a rough polygon. Can I adjust this resolution somewhere? Or is it something else? (I am considering that the tool diameter may also affect this?)
I could totally give you a hard time about not checking the FAQ but that's probably not fair. The answer wasn't there until a couple hours ago. It came up in another thread today and got added :lol:
polemidis
Posts: 32
Joined: Thu Feb 09, 2017 4:58 pm

Re: post processor resources

Postby polemidis » Thu May 17, 2018 11:12 am

polemidis wrote:
Thu May 17, 2018 12:16 am
I could totally give you a hard time about not checking the FAQ but that's probably not fair. The answer wasn't there until a couple hours ago. It came up in another thread today and got added
haha! And I was pretty sure I have read it!

So the post processor gives some errors

Code: Select all

PathPost.DEBUG: about to postprocess job: Job
PathPost.DEBUG: obj: Profile_Faces
grbl_post gcode postprocessor loaded.
grbl_plasma_post gcode postprocessor loaded.
grbl_plasma_post gcode postprocessor loaded.
PathPost.DEBUG: about to postprocess job: Job
PathPost.DEBUG: obj: Profile_Faces
post: grbl_plasma(/home/pomo/Freecad_Git/Grapples/01_Hardware/Mechanical_Parts/CADbrace plate lid upper.gcode, )
grbl_plasma_post gcode postprocessor loaded.
Show editor = 1
postprocessing...
No machine found in this project
Running the Python command 'Path_Post' failed:
Traceback (most recent call last):
  File "/usr/lib/freecad/Mod/Path/PathScripts/PathPost.py", line 259, in Activated
    (fail, rc) = self.exportObjectsWith(postlist, job)
  File "/usr/lib/freecad/Mod/Path/PathScripts/PathPost.py", line 192, in exportObjectsWith
    gcode = processor.export(objs, filename, postArgs)
  File "/usr/lib/freecad/Mod/Path/PathScripts/PathPostProcessor.py", line 104, in export
    return self.script.export(obj, filename, args)
  File "/usr/lib/freecad/Mod/Path/PathScripts//post/grbl_plasma_post.py", line 191, in export
    gcode += parse(obj)
  File "/usr/lib/freecad/Mod/Path/PathScripts//post/grbl_plasma_post.py", line 273, in parse
    if c.Parameters[param] < z_check:

local variable 'z_check' referenced before assignment
I started to read python, I will get it sooner or later. I knew I couldn't avoid it with Freecad!! hahha
chrisb
Posts: 13410
Joined: Tue Mar 17, 2015 9:14 am

Re: post processor resources

Postby chrisb » Thu May 17, 2018 11:40 am

polemidis wrote:
Thu May 17, 2018 11:12 am
polemidis wrote:
Thu May 17, 2018 12:16 am
I could totally give you a hard time about not checking the FAQ but that's probably not fair. The answer wasn't there until a couple hours ago. It came up in another thread today and got added
haha! And I was pretty sure I have read it!
It looks as if you are quoting one of your own posts. I am grateful, that you don't cite blindly the whole post, but you have to be careful which quote tags you delete. Using the right quote tags is useful, because the small arrow is a link to the cited post.
User avatar
sliptonic
Posts: 1318
Joined: Tue Oct 25, 2011 10:46 pm

Re: post processor resources

Postby sliptonic » Thu May 17, 2018 1:12 pm

It's trying to compare the Z value to the z_check value but z_check doesn't exist yet.
Add z_check=0 at the beginning of the parse() function.

Attached my version but still stressing that I haven't actually tested it.
Attachments
grbl_post.py
(11.28 KiB) Downloaded 7 times
polemidis
Posts: 32
Joined: Thu Feb 09, 2017 4:58 pm

Re: post processor resources

Postby polemidis » Sat May 19, 2018 11:44 pm

sliptonic wrote:
Thu May 17, 2018 1:12 pm
It's trying to compare the Z value to the z_check value but z_check doesn't exist yet.
Add z_check=0 at the beginning of the parse() function.

Attached my version but still stressing that I haven't actually tested it.
No worries :) As I dry run this logic I can see that it will put a "code that zeroes Z" twice in a row, as the tool descends twice.
I am attaching the post processor the SheetCAM uses in case someone can understand better how to implement this. It also has a scriber, just ignore it.

Code: Select all

--************************************************
--*** Set these values up to suit your machine ***
--************************************************

--this is the distance between each torch reference in MILLIMETRES
refDistance = 250

--this is the reference feed rate in mm/min
refFeed = 500

--Put your switch offset value here in MILLIMETRES
--Put a sheet of metal on your machine and place a sheet of paper on top.
--Slowly jog the torch down onto the paper until the touch-off switch just operates.
--Zero the Z axis then pull gently on the paper and slowly jog up until the paper slides out.
--The Z axis position is your switch offset.
switchOffset = 1.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 = 110
scriberY = 220
scriberZ = nil

--scriber axis. Leave this as nil if the scriber is fixed to the same axis as the torch
--scriberAxis = "A"
scriberAxis = nil

--this is an extra delay added to the first pierce as needed by some machines
firstPierceTime = 0 


--************************************************
--***           End of settings                ***
--************************************************



function OnAbout(event)
   ctrl = event:GetTextCtrl()
   ctrl:AppendText("plasma MP1000-THC post processor with 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("Designed for use with Mach3 and CandCNC MP1000-THC and Floating head Touch-n-Go\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/11/2010
-- Added: Reference the torch on the first pen down if the plate marker is the first tool used.


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
   if(scale == metric) then
      post.Text (" G21\n") --metric mode
   else
      post.Text (" G20\n") --inch mode
   end
   post.Text (" F1\n G53 G90 G40\n")
   minArcSize = 0.2 --arcs smaller than this are converted to moves
   firstRef = true
   currentZAxis = "Z"

   dist = 9999999
   lastz = 0
   thcstate = 1
   firstPierce = firstPierceTime;
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()
   if(endX > 1e17 and endY > 1e17) then return end
   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")
   if(offZ and firstRef == false and currentZ ~= safeZ) then
      post.ModalNumber (" " .. currentZAxis, (endZ + offZ) * scale, "0.0000")
   end
   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")
   if(offZ) then
      post.ModalNumber (" " .. currentZAxis, (endZ + offZ) * scale, "0.0000")
   end
   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 (" F", feedRate * scale, "0.0###")
   post.Eol()
end



function OnPenDown()
   if(toolClass == "MarkerTool") then
      if (firstRef) then
         Reference()
         post.ModalText (" G00")
         post.Text(" Z")
         post.Number (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, (currentZ + offZ)  * scale, "0.0000")
         post.Eol()
      end
      post.Text(" M08\n")
   else
      if(dist >= refDistance) then
         dist = 0
         Reference();
      end
      post.ModalText (" G00")
      post.Text(" Z")
      post.Number (pierceHeight  * scale, "0.0000")
      post.Eol()
      if (preheat > 0) then
         post.Text ("\n G04 P")
         post.Number (preheat,"0.0##")
         post.Eol()
      end
      post.Text ("\n M03\n")
   end
   if (pierceDelay + firstPierce > 0.001) then
      post.Text (" G04 P")
      post.Number (pierceDelay + firstPierce,"0.0##")
      firstPierce = 0
      post.Eol()
   end
end


function Reference()
   firstRef = false
   post.ModalText(" G38.2 z")
   post.Number(-50 * scale, "0.0##")
   post.ModalNumber (" F", refFeed * scale, "0.0###")
   post.Eol()
   post.ModalText(" G92 Z0.0\n")
   post.ModalText (" G00")
   post.Text(" Z")
   post.Number (switchOffset * scale, "0.0000")
   post.Eol()
   post.ModalText(" G92 Z0.0\n")
end

function OnPenUp()
   if(toolClass == "MarkerTool") 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 OnToolChange()
    if (toolClass == "MarkerTool") then
         if(scriberAxis and scriberAxis ~= currentZAxis) then
            endZ = safeZ
            OnRapid()
            currentZAxis = scriberAxis
         end
         if(firstRef ~= true) then
            offX = scriberX
            offY = scriberY
            offZ = scriberZ
         end
    else
         if(scriberAxis and scriberAxis == currentZAxis) then
            endZ = safeZ
            OnRapid()
            currentZAxis = "Z"
         end
         offX = 0
         offY = 0
         offZ = 0
    end
end

function OnDrill()
   OnRapid()
   currentX = endX
   currentY = endY
   OnPenDown()
   endZ = drillZ
   OnMove()
   OnPenUp()
   endZ = safeZ
   OnRapid()
end


function OnComment()
  post.Text(" (",commentText,")\n")
end
I ended up buying the SheetCAM and I can see there are a lot of other features that can be added. Like "preheat time" for oxy-fuel", delay, for plasma, different length for leadin, etc. The available tools change if you use the rotary vs the jet(plasma, laser, water jet etc) option.

Of course the workflow now is not ideal (Freecad --> SVG export, import to SheetCAM --> CAM), and I would like to support to remove the middle man (SVG), but my coding knowledge is non-existing. Let me know if I can help in some other way.