Large Plate Marker job, touch off only at start - need more

Hi Fellas,

  1. I recently installed plate marker on plasma table and it works “fine”, marker is attached to the same Z axis as plasma torch,
    however I attempted to run 1x1 meter plate marker JOB ONLY and I realized that once NO PLASMA operation
    is involved, sheetcam post ignores my setting “refDistance = 250” and performs touch off G28 only at start, then no more…
    I even tried to create separate operations on multiple layers in sheetcam - still I get only initial touch off.

I simply need plate marker to act just like plasma would on large jobs, ref Z with Feather Touch Ohmic Sensor every 250mm before next operation.

How do I change this behavior when doing plate marker job only?
How do I edit the post or am I missing some secret settings? :wink:

  1. I did use FESTO double acting pneumatic slide cylinder (hence not rigid mount), however I mounted ELECTRIC engraver from DREMEL on it.
    The point is: Tips for the engraver are 2.4mm diameter, so we can take all scrap TIG tungstens and sharpen them with NEUTRIX electrode grinder,
    this way we can ABUSE the engraver how much we want without worrying about pricey replacement tips for pneumatic scribe…

The final sharpened “TIG tip” on the engraver is very fine, making hair-like thin lines - great for high precision marks on plates, however even with the lowest possible
pressure for cylinder, due to higher weight of the engraver, it gets too deep into the plate and the lines and marks are not so perfect afterwards - even 2-3 mm difference matters…

For now I just FORCED touch offs my own way in sheetcam:

  • I created multiple layers and operations in sheetcam and insert in each segment PLASMA DRILL operation within desired radius
  • with plasma machine OFF, it will reference Z before pierce, relay in PWM clicks and does NOT WAIT for arc ok signal, then moves on to plate marker operation and so on…
    - to create initial job file is a great waste of time, so I need to edit the post to FORCE touch offs without creating separate layers and operations for plasma drill.
  1. I asked CandCNC guys for help - I was advised to look into “OnPenDown” function in post, but I am unable to fix the post on my own.

here is the original reply from CandCNC:

“That is how it is programmed in the POST because with a pneumatic plate marker where the marker is extended with the air,
you can vary by over an inch in height with no need for a touch off. The first touch off is simply to establish the Z to be able to raise the torch out of the way.”

“You can have a look at the ON PEN DOWN function int he POST and see where it checks to see what kind of tool it is using and the rules it applies.
It call a reference you simply call that function as “Reference()” in code. Note that it tests to see if its the first reference and runs the reference and does the XYZ offsets.
The normal code runs a variable that keeps track of the XY moves and when it sees it is greater than the setting will do a reference but that is in plasma tools.”

I attached the post I am trying to edit to this topic, I would like to ask Les or any of you guys very kindly for help,
again - I need to force plate marker to perform Z reference every 250mm just like plasma operation would.
Thank you very much in advance for any guidance.

Miro.

System: CandCNC BladeRunner 620-5, DTHCII, UBOB III rev12
Z axis: Feather Touch Ohmic Sensor
Post: MP3000-DTHCII-DCC+scriber6.scpost (see attachment)



--************************************************
--*** 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 = 1000

--Put your switch offset value here in MILLIMETRES
switchOffset = 0

--Scriber X,Y,Z offsets in MILLIMETRES. Do not use inches here even if you want inch code
--For the marker use the scriber Z as the offset from Z zero you want the Z to move to during a scribe.
--Change these values to suit your scriber setup
scriberX = -88.1
scriberY = 32.8
scriberZ = 14

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

--If this value is set to true then use G28 (home) for the Z reference
--Set it to false for G31 probe
refHome = true

--this value when set to "true" will set the Z to lift to rapid height between paths when using the marker tool.  
--if false it will not lift the Z between paths but will at the end
markerZ = false

--The cutter will slow down for corners and turn off THC below this radius
--Set slowRadius to "0" to turn off the auto slowdown
slowRadius = 0

--Minimum slow down speed.
--This is a scale factor. For instance 0.5 = 50% of the current feed rate
slowPercent = 0.6

--THC on and off codes. Use nil if you don't want THC control e.g:
-- thcOnCode = nil
-- thcOffCode = nil

--these codes are for the DCC extensions and turn the DTHC on/off if you have DTHC REV1/4 or higher firmware
thcOnCode = " S20"
thcOffCode = " S10"

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

function OnAbout(event)
   ctrl = event:GetTextCtrl()
   ctrl:AppendText("Plasma MP3000-DTHCII post processor with/without Plate marker\n")
   ctrl:AppendText("This POST for all units without RS485 needing DCC ")
   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 XXmm of movement thereafter\n")
   ctrl:AppendText("Designed for use with Mach3 and CandCNC MP3000-DTHC 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")
   ctrl:AppendText("slowRadius - slow down below this radius\n")
   ctrl:AppendText("slowPercent - minimum percentage to slow down\n")
   ctrl:AppendText("markerZ- allows marker rapid travel at system rapid height or Z offset height\n")
end

--  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.

--Modified 22/4/2013 (TLC)
--Added Preset Volts , Preset Amps , and DTHC Delay variables
--Added markerZ to turn safe Z lift on marker tool on/off
--Changed scriberZ as Z axis offset from Z0
--Added code to turn off slowdown if slowRadius = 0
--Added  NODTHC, Tip SIze and Air Pressure to tool table variables
--Removed using tool number above 100 as marker tool--must use "Marker Tool" to select scriber

post.DefineVariable("refDistance",sc.unitLINEAR,0,1e17)
post.DefineVariable("refFeed",sc.unitFEED,0,1e17)
post.DefineVariable("switchOffset",sc.unitLINEAR,-1e17,1e17)
post.DefineVariable("slowRadius",sc.unitLINEAR,-1e17,1e17)
post.DefineVariable("slowPercent",sc.unitPERCENT,-1e17,1e17)
post.DefineCustomToolParam("PlasmaTool", "Preset volts", "presetVolts", sc.unit0DECPLACE, 49, 0, 200)
post.DefineCustomToolParam("PlasmaTool", "DTHC delay -sec", "dthcDelay", sc.unit1DECPLACE, 0, 0, 99)
post.DefineCustomToolParam("PlasmaTool", "Tip Size -Amps", "tipSize", sc.unit0DECPLACE, 40, 20, 200)
post.DefineCustomToolParam("PlasmaTool", "NO DTHC - 0", "dthcOff", sc.unit0DECPLACE, 1, 0, 1)




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 (" F1\n G53 G90 G40\n")
   
   if(dthcOff) then 
--don't do anything   
   else
     dthcOff = 1 --don't pass a null
end
   
   minArcSize = 0.2 --arcs smaller than this are converted to moves
   firstRef = true
   currentZAxis = "Z"
   finalCut = false
   dist = 9999999
   lastz = 0
   thcstate = 1
   ThcOff()
   
end

function OnNewLine()
   post.Text ("N")
   post.Number (lineNumber, "0000")
   lineNumber = lineNumber + 10
end


function OnFinish()
   finalCut = true
   endZ = safeZ
   OnRapid()
   endX = 0
   endY = 0
   offX = 0
   offY = 0
   offZ = 0
   OnRapid()
   post.Text(" S900 \n")
   post.Text(" M22 \n")
   post.Text(thcOffCode)
   post.Text(" (DTHC is off)\n"); 
   post.Text(" M22 \n")
   post.Text (" M05 M30\n")
end

function OnRapid()
   if&#40;endX < 1e17 and endY < 1e17&#41; then --don't update the distance moved if X or Y are unknown
      local len = math.hypot&#40;&#40;endX + offX&#41;-currentX , &#40;endY + offY&#41;-currentY&#41;
      dist = dist + len
   end
   post.ModalText &#40;" G00"&#41;
   post.ModalNumber &#40;" X", &#40;endX + offX&#41; * scale, "0.0000"&#41;
   post.ModalNumber &#40;" Y", &#40;endY + offY&#41; * scale, "0.0000"&#41;
   if&#40;toolClass == "MarkerTool"&#41;  then
      if&#40;firstRef == true&#41; or &#40;finalCut == true&#41; or &#40;markerZ == true&#41; then
         post.ModalNumber &#40;" Z", safeZ * scale, "0.0000"&#41;
      end
      finalCut = false
   else --this is not a marker tool
      post.ModalNumber &#40;" Z", endZ * scale, "0.0000"&#41;
   end
   post.Eol&#40;&#41;
 end
 


function OnMove&#40;&#41;
   local len = math.hypot&#40;endX - currentX , endY - currentY&#41;
   dist = dist + len
   if&#40;len > slowRadius&#41; and &#40;dthcOff > 0&#41; then
     ThcOn&#40;&#41;
	end
   post.ModalText &#40;" G01"&#41;
   post.ModalNumber &#40;" X", &#40;endX + offX&#41; * scale, "0.0000"&#41;
   post.ModalNumber &#40;" Y", &#40;endY + offY&#41; * scale, "0.0000"&#41;
   if&#40;toolClass ~= "MarkerTool"&#41; then
      post.ModalNumber &#40;" Z", endZ * scale, "0.0000"&#41;
   end
   post.ModalNumber &#40;" F", feedRate * scale, "0.0###"&#41;
   post.Eol&#40;&#41;
end

function OnArc&#40;&#41;
   local radius = math.hypot&#40;currentX - arcCentreX, currentY - arcCentreY&#41;
   dist = dist + radius * math.abs&#40;arcAngle&#41;
   if&#40;radius < slowRadius&#41; and &#40;math.abs&#40;arcAngle&#41; > 0.5&#41; then
      feed = &#40;radius / slowRadius&#41;
      if&#40;feed < slowPercent&#41; then
         feed = slowPercent
      end
      feed = feed * feedRate
      ThcOff&#40;&#41;
   else
      feed = feedRate
	 if&#40;dthcOff >0&#41; then
      ThcOn&#40;&#41;
	  end
   end
   if&#40;arcAngle <0&#41; then
      post.ModalText &#40;" G03"&#41;
   else
      post.ModalText &#40;" G02"&#41;
   end
   post.ModalNumber &#40;" X", &#40;endX + offX&#41; * scale, "0.0000"&#41;
   post.ModalNumber &#40;" Y", &#40;endY + offY&#41; * 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", feed * scale, "0.0###"&#41;
   post.Eol&#40;&#41;
end


function ThcOff&#40;&#41;
   if&#40;not thcOffCode&#41; then return end
   if&#40;thcstate ==1&#41; then
      thcstate = 0
      post.Text&#40;thcOffCode&#41;
      post.Text&#40;" &#40;DTHC is off&#41;\n"&#41;;
   end
end

function ThcOn&#40;&#41;
   if&#40;not thcOnCode&#41; then return end
   if&#40;toolClass == "MarkerTool"&#41;  then return end
   if&#40;thcstate ==0&#41; then
      thcstate = 1
      post.Text&#40;thcOnCode&#41;
      post.Text&#40;" &#40;DTHC is on&#41;\n"&#41;;
      return
   end
   if&#40;thcstate == 2&#41; then
      thcstate = 0
   end
end

function OnPenDown&#40;&#41;
   if&#40;toolClass == "MarkerTool"&#41;  then
      if &#40;firstRef&#41; then
         Reference&#40;&#41;
         offX = scriberX
         offY = scriberY
         offZ = scriberZ
         if &#40;offZ > 0 &#41; then --put in the Z offset height if it the first scribe after a ref
            post.NonModalNumber&#40;" Z", offZ * scale, "0.0000"&#41;
            post.Eol&#40;&#41;
         end
         post.ModalNumber &#40;" X", &#40;currentX + offX&#41; * scale, "0.0000"&#41;
         post.ModalNumber &#40;" Y", &#40;currentY + offY&#41; * scale, "0.0000"&#41;
         post.Eol&#40;&#41;
      else --not a ref move
         if &#40;markerZ == true &#41; then --put in the Z offset height before the scribe after the rapid 
            post.ModalNumber&#40;" Z", offZ * scale, "0.0000"&#41;
            post.Eol&#40;&#41; 
         end   
      end
      post.Text&#40;" M08\n"&#41;
   else --tool is not marker tool
      if&#40;dist >= refDistance&#41; then
         dist = 0
         Reference&#40;&#41;;
      end
      post.ModalText &#40;" G00"&#41;
      post.NonModalNumber&#40;" Z", pierceHeight  * scale, "0.0000"&#41;
      post.Eol&#40;&#41;
      if &#40;preheat > 0&#41; then
         post.Text &#40;"\n G04 P"&#41;
         post.Number &#40;preheat,"0.###"&#41;
         post.Eol&#40;&#41;
      end
      post.Text &#40;"\n M03\n"&#41;
   end
   if &#40;pierceDelay > 0&#41; then
      post.Text &#40;" G04 P"&#41;
      post.Number &#40;pierceDelay,"0.###"&#41;
      post.Eol&#40;&#41;
   end
  thcstate = 0 
 if&#40;dthcOff > 0&#41; then
  ThcOn&#40;&#41;
  post.Text &#40;" M22 \n"&#41;
  end
end


function Reference&#40;&#41;
   firstRef = false
   if &#40;refHome&#41; then
      post.ModalText&#40;" G28.1 Z"&#41;
      post.Number&#40;3 * scale, "0.00"&#41;
   else
      post.ModalText&#40;" G31 Z -100"&#41;
   end
   post.ModalNumber &#40;" F", refFeed * scale, "0.0###"&#41;
   post.Eol&#40;&#41;
   post.ModalText&#40;" G92 Z0.0\n"&#41;
   post.ModalText &#40;" G00"&#41;
   post.Text&#40;" Z"&#41;
   post.Number &#40;switchOffset * scale, "0.0000"&#41;
   post.Eol&#40;&#41;
   post.ModalText&#40;" G92 Z0.0\n"&#41;
end

function OnPenUp&#40;&#41;
   if&#40;toolClass == "MarkerTool"&#41;  then
      post.Text&#40;" M09\n"&#41;
   else
      post.Text &#40;" M05\n"&#41;
   end
   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;
   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 OnToolChange&#40;&#41;
   post.Text &#40;" &#40;tool number&#58; ", tool ," "&#41;
   post.Text&#40;" Feedrate&#58; ", feedRate * scale , "&#41; \n"&#41;
    if&#40;dthcOff == 0&#41; then
      post.Text &#40;" &#40;DTHC has been disabled in this tool&#41;\n"&#41;
    end
      if&#40;presetVolts&#41; then
         post.Text &#40; "&#40;Preset Volts&#58; ",presetVolts," " &#41;
	  else
	  post.Text &#40;"&#40;"&#41;
      end
      if&#40;presetAmps&#41; then
         post.Text &#40; " Preset AMPS&#58; " ,presetAmps,"&#41; "&#41;
		 post.Eol&#40;&#41;
		 else
		 post .Text &#40;"&#41;"&#41;
		 post.Eol&#40;&#41;
      end
	  if&#40;presetPSI&#41; then
	     if&#40;presetPSI >0 &#41; then 
            post.Text &#40; " &#40; Air Pressure Preset&#58; " ,presetPSI,"&#41; "&#41;
			post.Eol&#40;&#41;
		 else 
		    post.Text &#40; " &#40; Default Air Pressure"&#41;
			post.Text &#40; "&#41;"&#41;
			post.Eol&#40;&#41;
		 end
      end
      if&#40;tipSize&#41; then
	     post.Text &#40; "&#40; Suggested Tip Size&#58; " ,tipSize," "&#41;
		 else
		 post.Text &#40; "&#40;"&#41;
	  end
      if&#40;dthcDelay&#41; then
	    if&#40;dthcDelay > 0 &#41; then
          post.Text &#40; "  DTHC Delay&#58; " ,dthcDelay," sec &#41; "&#41;
		  post.Eol&#40;&#41;
	      else
	      post.Text &#40; ", Default DTHC Delay &#41;"&#41;
		  post.Eol&#40;&#41;
        end
	else
    post.Text &#40; "&#41;"&#41;
	post.Eol&#40;&#41;
	end
   if &#40;toolClass == "MarkerTool"   &#41; then
      ThcOff&#40;&#41;
      if&#40;scriberAxis and scriberAxis ~= currentZAxis&#41; then
         endZ = safeZ
         OnRapid&#40;&#41;
         currentZAxis = scriberAxis
      end
      firstRef = true
   else --tool is not a marker
      if&#40;scriberAxis and scriberAxis == currentZAxis&#41; then
         endZ = safeZ
         OnRapid&#40;&#41;
         currentZAxis = "Z"
      end
	  if&#40;dthcOff == 0&#41; then
	     post.Text &#40;" S999 \n"&#41;
		 post.Text &#40;"  M22 \n"&#41;
	 else
		 post.Text &#40;" S900 \n"&#41;
		 post.Text &#40;"  M22 \n"&#41;
	  end 
      if&#40;presetVolts&#41; then
	    if&#40;presetVolts&#41; > 0 then
	     post.Text &#40; " S3" ,presetVolts, "\n" &#41;
		 post.Text &#40;"  M22 "&#41;
		 post.Eol&#40;&#41;
      else 
         post.Text &#40; "&#40;No Preset Volts&#41;\n" &#41;
      end 
     end	  
      if&#40;presetAmps&#41; then
	      if&#40;presetAmps > 0&#41; then 
	      post.Text&#40; " S4" ,presetAmps, "\n"&#41;
		  post.Text &#40;"  M22 "&#41;
		  post.Eol&#40;&#41;
           else 
         post.Text&#40;"&#40;No Preset Amps&#41;"&#41; 
         post.Eol&#40;&#41;
            end		 
      end
	  if&#40;presetPSI&#41; then 
	     if&#40;presetPSI > 0&#41; then
	         post.Text&#40; " S8" ,presetPSI, "\n"&#41;
		     post.Text &#40;"  M22 "&#41;
		     post.Eol&#40;&#41;
         else 
            post.Text&#40;"&#40;Default Air Pressure&#41;"&#41; 
            post.Eol&#40;&#41;		 
         end
	 end
	  if&#40;dthcDelay&#41; then
	     if&#40;dthcDelay > 0 &#41; then
           post.Text &#40; " S5"&#41;
		   post.Number &#40;dthcDelay * 10, "00"&#41;
		   post.Eol&#40;&#41;
		   post.Text &#40;"  M22 \n"&#41;
         end
     end		
      offX = 0
      offY = 0
      offZ = 0
	post.Text &#40;" M00"&#41;
	post.Text &#40;"&#40;Check the DTHC Settings  Hit RUN to continue&#41;\n"&#41;
	end --end for marker if
end --end for toolchangefunction
-- OnRapid&#40;&#41;
-- 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

Replace this bit of code:

   if&#40;toolClass == "MarkerTool"&#41;  then
      if &#40;firstRef&#41; then

with:

   if&#40;toolClass == "MarkerTool"&#41;  then
      if &#40;dist >= refDistance&#41; then
         dist = 0

That should make it reference in the same way as the plasma tool.

Only 2 lines to fix? Awesome!
I feel embarrassed… :blush:

Thank you very much for express solution Les.

Hi again Les,

I had a feeling I am not going to get away with 2 lines that easy…

Solution works - tested, it does reference before each plate marker segment how we wanted,
however, it does not move the torch to the starting point of each segment - ignoring Scriber offsets…

Would you please be able to add few more “tricky” lines to the post, so every torch referencing with ohmic sensor
will act just as the initial one?

I don’t mind extra moves - need to force the torch to perform to touch off exactly where the next plate marker segment begins.
Is it doable?

If yes, that would be the perfect combination with OnDrill() function you just created here,
large plate marker job, sharp tip, fine lines everywhere no matter how messed up the plate is…

Thank you very much in advance.


So far I only edit 2 lines in function OnPenDown():

function OnPenDown&#40;&#41;
   if&#40;toolClass == "MarkerTool"&#41;  then
      if &#40;dist >= refDistance&#41; then
         dist = 0   
         Reference&#40;&#41;
         offX = scriberX
         offY = scriberY
         offZ = scriberZ
         if &#40;offZ > 0 &#41; then --put in the Z offset height if it the first scribe after a ref
            post.NonModalNumber&#40;" Z", offZ * scale, "0.0000"&#41;
            post.Eol&#40;&#41;
         end
         post.ModalNumber &#40;" X", &#40;currentX + offX&#41; * scale, "0.0000"&#41;
         post.ModalNumber &#40;" Y", &#40;currentY + offY&#41; * scale, "0.0000"&#41;
         post.Eol&#40;&#41;
      else --not a ref move
         if &#40;markerZ == true &#41; then --put in the Z offset height before the scribe after the rapid 
            post.ModalNumber&#40;" Z", offZ * scale, "0.0000"&#41;
            post.Eol&#40;&#41; 
         end   
      end
      post.Text&#40;" M08\n"&#41;
   else --tool is not marker tool
      if&#40;dist >= refDistance&#41; then
         dist = 0
         Reference&#40;&#41;;
      end
      post.ModalText &#40;" G00"&#41;
      post.NonModalNumber&#40;" Z", pierceHeight  * scale, "0.0000"&#41;
      post.Eol&#40;&#41;
      if &#40;preheat > 0&#41; then
         post.Text &#40;"\n G04 P"&#41;
         post.Number &#40;preheat,"0.###"&#41;
         post.Eol&#40;&#41;
      end
      post.Text &#40;"\n M03\n"&#41;
   end
   if &#40;pierceDelay > 0&#41; then
      post.Text &#40;" G04 P"&#41;
      post.Number &#40;pierceDelay,"0.###"&#41;
      post.Eol&#40;&#41;
   end
  thcstate = 0 
 if&#40;dthcOff > 0&#41; then
  ThcOn&#40;&#41;
  post.Text &#40;" M22 \n"&#41;
  end
end

Oops, I think this:

         offX = scriberX
         offY = scriberY
         offZ = scriberZ
         if &#40;offZ > 0 &#41; then --put in the Z offset height if it the first scribe after a ref

should be

         offX = scriberX
         offY = scriberY
         offZ = scriberZ
         post.ModalText&#40;" G0"&#41;
         if &#40;offZ > 0 &#41; then --put in the Z offset height if it the first scribe after a ref

Thank you Les,

Tested - but nope, it didn’t do the trick…

Please note:
plate marker is mounted beside the plasma torch o Z axis (on the right),
scriberX = -88.1
scriberY = 32.8
scriberZ = 14

Here is what it does exactly in combination with new function OnDrill() on simple job below:

  1. plasma torch moves to touch off to point S1 - done
  2. plate marker moves to S1 and creates very precise cross mark - awesome - done
  3. plate marker moves to S2 and plasma torch performs touch off on the left ( X -88.1, Y 32.8 )
  4. plate marker creates another - not so perfect cross mark on S2 - due to plate marker offset

In this example, I was hoping to force the torch touch off in step 3 right above the point S2,
then same again on S3 and S4. I don’t mind extra moves…

The main reason is: once I am cutting on the left edge of the plate, torch will dive into hole while ref for plate marker…
Is it even doable by adding few more lines?



Thank you again for your time.


Sample job:




Current function OnPenDown():

function OnPenDown&#40;&#41;
   if&#40;toolClass == "MarkerTool"&#41;  then
      if &#40;dist >= refDistance&#41; then
         dist = 0
         Reference&#40;&#41;
         offX = scriberX
         offY = scriberY
         offZ = scriberZ
         post.ModalText&#40;" G0"&#41;
         if &#40;offZ > 0 &#41; then --put in the Z offset height if it the first scribe after a ref
            post.NonModalNumber&#40;" Z", offZ * scale, "0.0000"&#41;
            post.Eol&#40;&#41;
         end
         post.ModalNumber &#40;" X", &#40;currentX + offX&#41; * scale, "0.0000"&#41;
         post.ModalNumber &#40;" Y", &#40;currentY + offY&#41; * scale, "0.0000"&#41;
         post.Eol&#40;&#41;
      else --not a ref move
         if &#40;markerZ == true &#41; then --put in the Z offset height before the scribe after the rapid 
            post.ModalNumber&#40;" Z", offZ * scale, "0.0000"&#41;
            post.Eol&#40;&#41; 
         end   
      end
      post.Text&#40;" M08\n"&#41;
   else --tool is not marker tool
      if&#40;dist >= refDistance&#41; then
         dist = 0
         Reference&#40;&#41;;
      end
      post.ModalText &#40;" G00"&#41;
      post.NonModalNumber&#40;" Z", pierceHeight  * scale, "0.0000"&#41;
      post.Eol&#40;&#41;
      if &#40;preheat > 0&#41; then
         post.Text &#40;"\n G04 P"&#41;
         post.Number &#40;preheat,"0.###"&#41;
         post.Eol&#40;&#41;
      end
      post.Text &#40;"\n M03\n"&#41;
   end
   if &#40;pierceDelay > 0&#41; then
      post.Text &#40;" G04 P"&#41;
      post.Number &#40;pierceDelay,"0.###"&#41;
      post.Eol&#40;&#41;
   end
  thcstate = 0 
 if&#40;dthcOff > 0&#41; then
  ThcOn&#40;&#41;
  post.Text &#40;" M22 \n"&#41;
  end
end

OK, I think I understand what is going on. Try this:

function Reference&#40;&#41;
   if&#40;toolClass == "MarkerTool"&#41; then --move torch to reference point
      offX = 0
      offY = 0
      offZ = 0
      OnRapid&#40;&#41;
   end
   firstRef = false
   if &#40;refHome&#41; then
      post.ModalText&#40;" G28.1 Z"&#41;
      post.Number&#40;3 * scale, "0.00"&#41;
   else
      post.ModalText&#40;" G31 Z -100"&#41;
   end
   post.ModalNumber &#40;" F", refFeed * scale, "0.0###"&#41;
   post.Eol&#40;&#41;
   post.ModalText&#40;" G92 Z0.0\n"&#41;
   post.ModalText &#40;" G00"&#41;
   post.Text&#40;" Z"&#41;
   post.Number &#40;switchOffset * scale, "0.0000"&#41;
   post.Eol&#40;&#41;
   post.ModalText&#40;" G92 Z0.0\n"&#41;
   if&#40;toolClass == "MarkerTool"&#41; then --move scriber into place
      offX = scriberX
      offY = scriberY
      offZ = scriberZ 
      OnRapid&#40;&#41;
   end
end

Thank you Les!

New function Reference() worked - with two minor issues:

  1. it referenced also between two lines of 6mm cross mark for holes (not necessary)
  • so I changed the first setting in post to: “refDistance = 300” - DONE

2) it did not raise the torch after referencing while moving plate marker into position

  • I added these lines to function and tadaa, it works - DONE
post.ModalText &#40;" G00"&#41; 
      post.Text&#40;" Z"&#41; 
      post.Number &#40;scriberZ * scale, "0.0000"&#41; 
      post.Eol&#40;&#41;

If it is not the most elegant way, please consider this as my brainfart and I gladly accept
any smarter solution from professional. :slight_smile:

Thank you very much again for your help.



Here are all fixed functions related to plate marker:

function Reference&#40;&#41; --MK fixed
   if&#40;toolClass == "MarkerTool"&#41; then --move torch to reference point
      offX = 0
      offY = 0
      offZ = 0
      OnRapid&#40;&#41;
   end
   firstRef = false
   if &#40;refHome&#41; then
      post.ModalText&#40;" G28.1 Z"&#41;
      post.Number&#40;3 * scale, "0.00"&#41;
   else
      post.ModalText&#40;" G31 Z -100"&#41;
   end
   post.ModalNumber &#40;" F", refFeed * scale, "0.0###"&#41;
   post.Eol&#40;&#41;
   post.ModalText&#40;" G92 Z0.0\n"&#41;
   post.ModalText &#40;" G00"&#41;
   post.Text&#40;" Z"&#41;
   post.Number &#40;switchOffset * scale, "0.0000"&#41;
   post.Eol&#40;&#41;
   post.ModalText&#40;" G92 Z0.0\n"&#41;
   if&#40;toolClass == "MarkerTool"&#41; then --move scriber into place
      offX = scriberX
      offY = scriberY
      offZ = scriberZ
      post.ModalText &#40;" G00"&#41; --MK
      post.Text&#40;" Z"&#41; --MK
      post.Number &#40;scriberZ * scale, "0.0000"&#41; --MK
      post.Eol&#40;&#41; --MK
      OnRapid&#40;&#41;
   end
end



function OnPenDown&#40;&#41; --MK fixed
   if&#40;toolClass == "MarkerTool"&#41;  then
      if &#40;dist >= refDistance&#41; then
         dist = 0
         Reference&#40;&#41;
         offX = scriberX
         offY = scriberY
         offZ = scriberZ
         post.ModalText&#40;" G00"&#41; --MK
         if &#40;offZ > 0&#41; then --put in the Z offset height if it the first scribe after a ref --MK
            post.NonModalNumber&#40;" Z", offZ * scale, "0.0000"&#41;
            post.Eol&#40;&#41;
         end
         post.ModalNumber &#40;" X", &#40;currentX + offX&#41; * scale, "0.0000"&#41;
         post.ModalNumber &#40;" Y", &#40;currentY + offY&#41; * scale, "0.0000"&#41;
         post.Eol&#40;&#41;
      else --not a ref move
         if &#40;markerZ == true &#41; then --put in the Z offset height before the scribe after the rapid 
            post.ModalNumber&#40;" Z", offZ * scale, "0.0000"&#41;
            post.Eol&#40;&#41; 
         end   
      end
      post.Text&#40;" M08\n"&#41;
   else --tool is not marker tool
      if&#40;dist >= refDistance&#41; then
         dist = 0
         Reference&#40;&#41;;
      end
      post.ModalText &#40;" G00"&#41;
      post.NonModalNumber&#40;" Z", pierceHeight  * scale, "0.0000"&#41;
      post.Eol&#40;&#41;
      if &#40;preheat > 0&#41; then
         post.Text &#40;"\n G04 P"&#41;
         post.Number &#40;preheat,"0.###"&#41;
         post.Eol&#40;&#41;
      end
      post.Text &#40;"\n M03\n"&#41;
   end
   if &#40;pierceDelay > 0&#41; then
      post.Text &#40;" G04 P"&#41;
      post.Number &#40;pierceDelay,"0.###"&#41;
      post.Eol&#40;&#41;
   end
  thcstate = 0 
 if&#40;dthcOff > 0&#41; then
  ThcOn&#40;&#41;
  post.Text &#40;" M22 \n"&#41;
  end
end



function OnDrill&#40;&#41; --MK fixed
   if toolClass == "MarkerTool" then
      local ex = endX
      local ey = endY
      local siz = 6 / 2 --cross size is 6mm
     
      endX = ex + siz
      OnRapid&#40;&#41;
      currentX = endX
      currentY = endY
      OnPenDown&#40;&#41;
      endZ = cutHeight
      OnMove&#40;&#41;
      endX = ex - siz
      OnMove&#40;&#41;
      OnPenUp&#40;&#41;
      endZ = safeZ
      OnRapid&#40;&#41;
      
      endX = ex
      endY = ey + siz
      OnRapid&#40;&#41;
      currentX = endX --MK
      currentY = endY --MK
      OnPenDown&#40;&#41;
      endZ = cutHeight
      OnMove&#40;&#41;
      endY = ey - siz
      OnMove&#40;&#41;
      OnPenUp&#40;&#41;
      endZ = safeZ
      OnRapid&#40;&#41;
      return
   end

Oops, I should have thought of that

post.ModalText (" G00")
post.Text(" Z")
post.Number (scriberZ * scale, “0.0000”)
post.Eol()

>

That would work in most cases but it is dependent on your scriber offset. A better way would be to change the end of function Reference to this:

```text
   if&#40;toolClass == "MarkerTool"&#41; then --move scriber into place
      offZ = scriberZ
      endZ = safeZ
      OnRapid&#40;&#41; --lift to safe Z
      offX = scriberX
      offY = scriberY
      OnRapid&#40;&#41; --move scriber into position
   end
end

Thank you Les,

The more i keep staring at post, learning and applying your fixes - the more I want to mess with it… :smiley:

  1. you are right, my fix is dependent on scriber offset, so i simply replaced “scriberZ” with “safeZ:wink:,
    it works, so I am sticking with this - the reason is below…

  2. off topic: i prefer gcode line increments of 1, so in function OnNewLine() i changed to “lineNumber = lineNumber + 1”,
    yet generated code still starts from 10. Is SheetCam designed like that or am I missing something?

3) now onto this bugger:

if&#40;toolClass == "MarkerTool"&#41; then --move scriber into place
      offZ = scriberZ
      endZ = safeZ
      OnRapid&#40;&#41; --lift to safe Z
      offX = scriberX
      offY = scriberY
      OnRapid&#40;&#41; --move scriber into position
   end
end

Les, thank you for your patience and please consider that my last “real” code writing experience was in high school 1996,
I took Turbo Pascal 7 classes on PC 386 with DOS and Windows 3.1 installed. We used to play Wolfenstein and Flashback games,
and I still have about 2 kilos of floppy discs somewhere around… Hahahaha…

Now, the function Reference() with above code does not work, because there is 3 more conditions in function OnRapid()…
Even when I fix OnRapid(), then because OnDrill() is changed - result on sample job below is:

that second line of cross mark on small hole is done in safeZ (should be markerZ), and when in goes from small cross mark
to large cross (S1+S2) it does not lift again after torch reference…

… and that’s where I am giving up on messing with more functions in post and taking option in point 1)…

You helped me to achieve what I wanted - so why “fix” it more, also I don’t want to be super creative and deviate from CandCNC post logic too much.
I mean once we will upgrade to new hardware and Tom includes his latest post monstrosity (CandCNC posts are largest), I will shoot myself in the shop…

Thank you again for your attention, help and time.

With posts there isn’t one ‘right’ way to do things. If it works for you, that’s what counts.

  1. off topic: i prefer gcode line increments of 1, so in function OnNewLine() i changed to “lineNumber = lineNumber + 1”,
    yet generated code still starts from 10. > Is SheetCam designed like that or am I missing something?

Yes it defaults to starting at line 10 but if you add this to the start of OnInit() it should start at 1:

lineNumber = 1



Now, the function > Reference() with above code > does not work, because there is 3 more conditions in function OnRapid()…

I have to admit I haven’t tested any of these code suggestions so it doesn’t surprise me if it doesn’t do what you want. Your solution works so stick with it.

I mean once we will upgrade to new hardware and Tom includes his latest post monstrosity (CandCNC posts are largest), I will shoot myself in the shop…

Tom’s posts can be quite complicated. If you want really complicated, the rotary plasma post takes some beating. It is so big it’s split into two lua files and a dll :open_mouth: