Hello Guest it is April 19, 2024, 09:28:56 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - rafiki

Pages: 1
1
Mach4 General Discussion / M6 Script Problem
« on: May 19, 2020, 10:10:01 AM »
I have written the simplest possible script to position the tool over a touch plate at machine zero, capture the Z, change to a new tool,  and update the Z axis for the new tool.

This code runs just fine, but Mach exhibits bizarre behavior.  After the code runs the Z work zero can be off by anywhere between a few hundreths of a mm to 50mm.  This happens even if you leave the same tool in before and after the change.

Code: [Select]
function m6()

local inst = mc.mcGetInstance()

local selectedTool = mc.mcToolGetSelected(inst)
local currentTool = mc.mcToolGetCurrent(inst)

local MoveDistance = -15     
local MoveSpeed = 15                   

local TouchZ
local CycleWait

  if selectedTool == currentTool then
mc.mcCntlSetLastError(inst, "Current tool same as selected tool.  No tool change required.")
  else
    mc.mcCntlSetLastError(inst, "Tool Change")

mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0 X0.0 Y0.0")

CycleWait = mc.mcCntlWaitOnCycleStart(inst, "Position the tool less than 1/2 inch over the touch plate and click Start", 1000000)

mc.mcCntlGcodeExecuteWait(inst,"G91 G31 Z"..MoveDistance.." F"..MoveSpeed)

TouchZ = mc.mcAxisGetPos(inst, 2)

mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")

CycleWait = mc.mcCntlWaitOnCycleStart(inst, "Change the tool, reposition it over touch plate and click Start", 1000000)

mc.mcCntlGcodeExecuteWait(inst,"G91 G31 Z"..MoveDistance.." F"..MoveSpeed)

mc.mcAxisSetPos(inst, 2, TouchZ)

mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
 
mc.mcToolSetCurrent(inst, selectedTool)

CycleWait = mc.mcCntlWaitOnCycleStart(inst, "Turn the spindle on, click cycle start, and we are cutting.", 1000000)

mc.mcCntlSetLastError(inst, "Tool Change Completed.")
  end

end

if (mc.mcInEditor() == 1) then
m6()
end

It seems like there is a bug somewhere in Mach4.  I don't see any line in this code that could possibly cause this behavior.  Also, the touch screen hangs, and this code hangs if I run either of them after a fresh boot of Mach4.  After Mach4 loads I need to load a GCode file and start it before the touch screen or this script will run properly.

Very frustrating.

2
Mach4 General Discussion / Re: Mach4 precision problems
« on: April 30, 2020, 07:04:28 PM »
I thought it meant constant velocity, but I wasn't sure.

When I used Mach3 it would sometimes flip over into exact stop, and I would switch it back.

I always run in CV.

My look ahead is set at 20.

3
Mach4 General Discussion / Re: Mach4 precision problems
« on: April 30, 2020, 11:42:22 AM »
Thanks for the ideas.

I am using ethernet, but I cannot get it to not autoconfigure.  I get a warning when Mach4 loads.  I have spent hours trying to fix this, and I am just resigned to living with it.  Do you think it could affect performance?  I have the network card set as a static address, and I have configured the pokeys to "use this address" but it autoconfigures anyway.

What is CV?

The problem seems almost random.  It's like the machine is drunk.  At first I thought my tool change Lua script had a problem because the Z axis was wildly off between tools.  I slowed down all the velocities and accelerations, and thought maybe that helped, but now it doesn't even cut a straight line.

I'm at a total loss.

4
Mach4 General Discussion / Mach4 precision problems
« on: April 29, 2020, 12:59:44 PM »
The attached image shows a piece I cut with Mach3 on the left, and the same piece I cut with Mach4.  As you can see, I suffered an extreme loss of precision.

I have a homemade 3-axis mill.  I replaced the Mach3 controller board with a pokeys57cnc motion controller for mach4; otherwise, it is the same machine and the same part files.

Any ideas?

5
Mach4 Toolbox / Re: M6 Tool change for the rest of us.
« on: April 29, 2020, 12:49:20 PM »
Yes.  Thanks for all your good work.

I'm using Mach4 on Win10, and the whole thing is remarkably buggie.  I reinstalled the controller board and Mach4, and that seemed to help a little.

I simplified your code to the extent possible and I stripped the code down to the bare minimum that I needed for my tool changes on a homemade mill, and then a lot of trial and error to get it to run.  Here's the code I ended up with:

function m6()

   local inst = mc.mcGetInstance()
   
   local selectedTool = mc.mcToolGetSelected(inst)
   selectedTool = math.tointeger(selectedTool)
   local currentTool = mc.mcToolGetCurrent(inst)
   currentTool = math.tointeger(currentTool)
   
   local ProbeOperationDistance = -15      -- This is how far Z will move while looking for a probe hit.
   local ProbeSpeed = 15                   -- This is how fast Z will probe at. Keep this number small for acuracy.
       
   
  if selectedTool == currentTool then
      mc.mcCntlSetLastError(inst, "Current tool == Selected tool so there is nothing to do")
  else
                
      mc.mcCntlSetLastError(inst, "Tool Change")
      mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0 X0.0 Y0.0")
      
      mc.mcCntlSetLastError(inst, "Position the tool less than 1/2 inch over the touch plate and click Start")
      mc.mcCntlToolChangeManual(inst,true)
      
      mc.mcCntlGcodeExecuteWait(inst,"G91 G31 Z"..ProbeOperationDistance.." F"..ProbeSpeed)

      local toolz = mc.mcAxisGetPos(inst, 2)
      mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
   
      mc.mcCntlSetLastError(inst, "Change the tool, reposition it over touch plate and click Start")
      mc.mcCntlToolChangeManual(inst,true)   
      
      mc.mcCntlGcodeExecuteWait(inst,"G91 G31 Z"..ProbeOperationDistance.." F"..ProbeSpeed)
      
      mc.mcAxisSetPos(inst, 2, toolz)
      mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
             
      mc.mcCntlSetLastError(inst, "Turn the spindle on, click cycle start, and we are cutting.")
      mc.mcCntlToolChangeManual(inst,true)   
                     
  end

end

if (mc.mcInEditor() == 1) then
   m6()
end

6
Mach4 Toolbox / Re: M6 Tool change for the rest of us.
« on: April 21, 2020, 01:59:26 PM »
When I put this code in my m6.mcs and type m6 in MDI, half of the screen buttons gray momentarily, and then nothing happens.  I assume there is a Lua error.

The default m6.mcs script will run in MDI.

Why does Mach4 not tell us what the error is?

Does anybody know a good fix?

This code will run in script editor when I click the double arrows.

Pages: 1