1
Mach4 General Discussion / Re: upgraded firmware now M6 fails most of the time
« on: April 17, 2018, 04:07:26 PM »
Sorry, but the PMDX is a 422 not 411
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.
function m6()
local inst = mc.mcGetInstance();
local selectedtool = mc.mcToolGetSelected(inst)
local currenttool = mc.mcToolGetCurrent(inst)
local hsig = mc.mcSignalGetHandle(inst, mc.ISIG_PROBE)
local changetoo = mc.mcToolGetDesc(inst,selectedtool)
local toollen = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, selectedtool)
--your machine info custom to you
local touchplate = -.195 -- this is the height above or below table surface for non flush touchplates.
local longesttool = 6 -- this is the longest bit that you own that you could possibly use
local zclearance = -11.375 -- this is the measurment from your collet to the fixed touchplate
local probeclearance = .5 -- this is safe distance above touchplate where you want probe to start
-- end of your machine info
local undefinedtoolprobe = (zclearance + longesttool +touchplate + probeclearance )
local undefinedprobetravel = (zclearance + longesttool + touchplate)
local probestart = (zclearance + toollen + probeclearance +touchplate)
if selectedtool == currenttool then
mc.mcCntlSetLastError(inst, "ToolChange Activated But Not Required")
else
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0") --move z axis all the way up
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 X0.464 Y-98.25") -- Move XY to above fixed touchplate location change to match your machine
mc.mcCntlGcodeExecuteWait(inst, "G49") -- Cancels any current offsets
if toollen ~= 0 then -- if toollen is defined in tool table do this
wx.wxMessageBox("Please change to tool "..selectedtool.." which is a "..changetoo.."")
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G1 Z"..probestart.." f25\n G91 G31 Z-1.25 F6") -- change "F#" to vary probing speed
ProbeState = mc.mcSignalGetState(hsig)
if ProbeState == 0 then -- if probe is not sensed this prevents a false zero from being utilized.
mc.mcCntlSetLastError(inst, "ERROR: Touch Probe was not detected")
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
wx.wxMessageBox("ERROR: Touch Probe was not detected reset tool")
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G1 Z"..probestart.." f25\n G91 G31 Z-1.25 F6")-- change "F#" to vary probing speed
ProbeState = mc.mcSignalGetState(hsig)
if ProbeState == 0 then -- no probe detected end cycle
mc.mcCntlSetLastError(inst, "ERROR: Touch Probe was not detected")
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
wx.wxMessageBox("ERROR: Touch Probe was not detected Cycle stopped")
mc.mcCntlCycleStop(inst)
else
local zoffset = mc.mcAxisGetPos (inst, 2) - touchplate
mc.mcToolSetData (inst, mc.MTOOL_MILL_HEIGHT, selectedtool, zoffset)
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
mc.mcCntlSetLastError(inst, "ToolChange Finished")
mc.mcToolSetCurrent(inst, selectedtool)
end
else
local zoffset = mc.mcAxisGetPos (inst, 2) - touchplate
mc.mcToolSetData (inst, mc.MTOOL_MILL_HEIGHT, selectedtool, zoffset)
>>> mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
mc.mcCntlSetLastError(inst, "ToolChange Finished")
mc.mcToolSetCurrent(inst, selectedtool)
end
else
wx.wxMessageBox("Tool Length is not Defined in Tool Table.\nset tool length manually and cycle start")
mc.mcCntlCycleStop(inst)
end
end
mc.mcCntlGcodeExecuteWait(inst, "G43") --Turns on Offsets
end
if (mc.mcInEditor() == 1) then
m6()
end
--(Revision 1.0) "Touch probe is at a fixed location" "tool table length is altered during probes" Measurements I used are in inches
-- Rev 1.0 this code is based on a CNC Router table where zero is in a fixed location. Mine is flush with the machine top.
-- In this version the tool table is altered every time by changing the bit length to whatever the probe measurement is. You can leave your tool table lengths
-- blank and it will probe from a safe height the first time and enter the length for you, otherwise the length needs to be close to the length from the collet
-- to the end of the bit.
-- (if you do a tool change to an undefined tool or a tool with no length, it will automatically adjust and probe from a safe height)
-- ****** you must define "Local touchplate, longesttool, zclearance, and probeclearance" below based on your machine**********
-- *** my fixture offsets for G54, 55 etc is the distance from the collet to the worksurface, same as the zclearance and stays constant**
-- ****Note, My touchplate is flush with my top, because if this I have not tested the math for a touchplate.
-- A Neg number may be needed where expecting a positive make sure you test for your setup)
function M6()
local inst = mc.mcGetInstance();
local selectedtool = mc.mcToolGetSelected(inst)
local currenttool = mc.mcToolGetCurrent(inst)
local hsig = mc.mcSignalGetHandle(inst, mc.ISIG_PROBE)
local changetoo = mc.mcToolGetDesc(inst,selectedtool)
local toollen = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, selectedtool)
--your machine info custom to you
local touchplate = 0 -- this is the height above or below table surface for non flush touchplates.
local longesttool = 6 -- this is the longest bit that you own that you could possibly use
local zclearance = -11.375 -- this is the measurment from your collet to the fixed touchplate
local probeclearance = .25 -- this is safe distance above touchplate where you want probe to start
-- end of your machine info
local undefinedtoolprobe = (zclearance + longesttool +touchplate + probeclearance )
local undefinedprobetravel = (zclearance + longesttool + touchplate)
local probestart = (zclearance + toollen + probeclearance +touchplate)
if selectedtool == currenttool then
mc.mcCntlSetLastError(inst, "ToolChange Activated But Not Required")
else
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0") --move z axis all the way up
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 X0.464 Y-99.808") -- Move XY to above fixed touchplate location change to match your machine
mc.mcCntlGcodeExecuteWait(inst, "G49") -- Cancels any current offsets
if toollen ~= 0 then -- if toollen is defined in tool table do this
wx.wxMessageBox("Please change to tool "..selectedtool.." which is a "..changetoo.."")
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z"..probestart.."\n G91 G31 Z-.5 F5") -- change "F#" to vary probing speed
ProbeState = mc.mcSignalGetState(hsig)
if ProbeState == 0 then -- if probe is not sensed this prevents a false zero from being utilized.
repeat
mc.mcCntlSetLastError(inst, "ERROR: Touch Probe was not detected")
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
wx.wxMessageBox("ERROR: Touch Probe was not detected reset tool")
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z"..probestart.."\n G91 G31 Z-.5 F5")-- change "F#" to vary probing speed
ProbeState = mc.mcSignalGetState(hsig)
until(ProbeState == 1)
local zoffset = mc.mcAxisGetPos (inst, 2) - touchplate
mc.mcToolSetData (inst, mc.MTOOL_MILL_HEIGHT, selectedtool, zoffset)
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
mc.mcCntlSetLastError(inst, "ToolChange Finished")
mc.mcToolSetCurrent(inst, selectedtool)
else
local zoffset = mc.mcAxisGetPos (inst, 2) - touchplate
mc.mcToolSetData (inst, mc.MTOOL_MILL_HEIGHT, selectedtool, zoffset)
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
mc.mcCntlSetLastError(inst, "ToolChange Finished")
mc.mcToolSetCurrent(inst, selectedtool)
end
else
wx.wxMessageBox("Please change to tool "..selectedtool.." which is a "..changetoo.."")
wx.wxMessageBox("Tool Length is not Defined in Tool Table, Continue to Probe for Length")
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z"..undefinedtoolprobe.."\n G91 G31 Z"..undefinedprobetravel.." F5")-- change "F#" to vary probing speed
ProbeState = mc.mcSignalGetState(hsig)
if ProbeState == 0 then -- if probe is not sensed this prevents a false zero from being utilized.
repeat
mc.mcCntlSetLastError(inst, "ERROR: Touch Probe was not detected")
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
wx.wxMessageBox("ERROR: Touch Probe was not detected reset tool")
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z"..undefinedtoolprobe.."\n G91 G31 Z"..undefinedprobetravel.." F5")-- change "F#" to vary probing speed
ProbeState = mc.mcSignalGetState(hsig)
until(ProbeState == 1)
local zoffset = mc.mcAxisGetPos(inst, 2) - touchplate
mc.mcToolSetData (inst, mc.MTOOL_MILL_HEIGHT, selectedtool, zoffset)
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
wx.wxMessageBox("Toolchange Finished, Ensure Tool Table Description matches Tool")
else
local zoffset = mc.mcAxisGetPos(inst, 2) - touchplate
mc.mcToolSetData (inst, mc.MTOOL_MILL_HEIGHT, selectedtool, zoffset)
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
wx.wxMessageBox("Toolchange Finished, Ensure Tool Table Description matches Tool")
mc.mcToolSetCurrent(inst, selectedtool)
end
end
end
mc.mcCntlGcodeExecuteWait(inst, "G43") --Turns on Offsets
--wx.wxMessageBox("Toolchange completed successfully, press OK to Continue") -- Enable this to insert a pause before resuming a running program
end
if (mc.mcInEditor() == 1) then
M6()
end