My problem is that when i press "Zero Y" the dro changes its value from the current value to 570.000, 575 or a random (to me) position after restarting mach4.
Steps to reproduce:
Turn on and enable the machine.
Ref. All Home
- I have a custom script see below RefAllHomeWithOffset()
press Zero X (or Zero Y or Zero Z) one of them will fail with this wired behaviour.
The value changes if i run my M6 Script. Machine coordinates are still correct.
I have a PMDX-126 and a Warp9td ESS.
I Run Windows 10 Pro version 20H2
Mach Version is 4.2.0 build 4574
I completly rebuilt my machine and started with a new profile based on the Mach4Mill Profile.
I tried to find where the actions are defined but can not find any information in the API Documentation or in the scripting or Operation manuals.
If i change the button to just run the RefAllHomeWithOffset() without creating a coroutine and remove all Yield commands it homes but does not execute any gcode. Zero Y behaviour is still setting the DRO to 570.0000 or 575.0000
The only place where i can remember using this value (570.0000) is in the RefAllHomeWithOffset script.
Here are my scripts:
ScreenLoad additions:
---------------------------------------------------------------
-- Set Soft Limits () function.
---------------------------------------------------------------
function SetSoftLimits(inst, state) -- legal params = 0 and 1.
--local inst = mc.mcGetInstance (mInst)
for i=0, (11) do
if mc.mcAxisIsEnabled (inst,i) == 1 and state == 1
then mc.mcSoftLimitSetState (inst,i,1) end
if mc.mcAxisIsEnabled (inst,i) == 1 and state == 0
then mc.mcSoftLimitSetState (inst,i,0) end
end
end
---------------------------------------------------------------
-- Ref All Home With Offset() function.
---------------------------------------------------------------
function RefAllHomeWithOffset()
SetSoftLimits(inst,0)
mc.mcAxisDerefAll(inst)
mc.mcAxisHomeAll(inst)
coroutine.yield() --yield coroutine so we can do the following after motion stops
mc.mcCntlGcodeExecuteWait(inst, "G92 X-5 Y575 Z5")
wx.wxMessageBox('Referencing is complete')
mc.mcCntlGcodeExecuteWait(inst, "G1 X0 Y570 Z0 F2000")
SetSoftLimits(inst,1)
end
m6 Script:
function m6()
local inst = mc.mcGetInstance()
if mc.mcAxisIsHomed(inst, 0) and mc.mcAxisIsHomed(inst, 1) and mc.mcAxisIsHomed(inst, 2) and mc.mcAxisIsHomed(inst, 3) then
M6SetSoftLimits(inst,0)
local changeToTool = mc.mcToolGetSelected(inst)
local changeFromTool = mc.mcToolGetCurrent(inst)
local XPositionBeforeToolChange = mc.mcAxisGetPos(inst,0)
local YPositionBeforeToolChange = mc.mcAxisGetPos(inst,1)
local XToolProbePosition = "17.0"
local YToolProbePosition = "0.3"
local XManualToolChangePosition = "17.0"
local YManualToolChangePosition = "0.3"
local ColletAtProbeZCoordinate = -248 -- Machine Z-coordinate when collet tip touches TouchPlate (Must be more than ProbeOperationDistance - DefaultToolLength
local ExtraProbeDistance = 15 -- SafetyMargin
local ProbeOperationDistance = -30 -- Length of Probemove before giving up
local ProbePrepSpeed = 750
local ProbeSpeed = 100
local DefaultToolLength = 70 -- Used if tool info is not found. (Should be a value slightly longer than the longest tool in the shop

)
-- QUICK REFERENCE
-- G90 - Absolute (Go to coordinate)
-- G91 - Incremental (Godistance along axis from current position)
-- G53 - Machine Coordinate Move
wx.wxMessageBox("ToolChange from T"..changeFromTool.." to T"..changeToTool.." Press OK to run M6 cript")
if changeToTool == changeFromTool then
mc.mcCntlSetLastError(inst, "ToolChange Activated But Not Required")
return
else
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0\nM5" )
RunProbe(inst,changeFromTool,XToolProbePosition,YToolProbePosition,DefaultToolLength,ColletAtProbeZCoordinate,ExtraProbeDistance,ProbePrepSpeed,ProbeSpeed,ProbeOperationDistance)
local ToolZCoordinate = mc.mcAxisGetPos(inst,2)
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0 \n G90 G53 G0 X"..XManualToolChangePosition.." Y"..YManualToolChangePosition)
local changeToToolDescription = mc.mcToolGetDesc(inst,changeToTool)
wx.wxMessageBox("Please change to tool number "..changeToTool.." "..changeToToolDescription.." and press ok to continue")
RunProbe(inst,changeToTool,XToolProbePosition,YToolProbePosition,DefaultToolLength,ColletAtProbeZCoordinate,ExtraProbeDistance,ProbePrepSpeed,ProbeSpeed,ProbeOperationDistance)
mc.mcAxisSetPos(inst, 2 , ToolZCoordinate)
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
mc.mcCntlGcodeExecuteWait(inst,"G90 G0 X"..XPositionBeforeToolChange.." Y"..YPositionBeforeToolChange)
mc.mcToolSetCurrent(inst, changeToTool)
wx.wxMessageBox("If Toolchange was Sucessful - click ok to continue")
mc.mcCntlSetLastError(inst, "ToolChange Finished")
end
M6SetSoftLimits(inst,0)
else
wx.wxMessageBox("M6 Toolchange can not run Machine is not Referenced to home. All operations should be aborted!!!")
end
end
function RunProbe(finst,ftool,fXToolProbePosition,fYToolProbePosition,fDefaultToolLength,fColletAtProbeZCoordinate,fExtraProbeDistance,fProbePrepSpeed,fProbeSpeed,fProbeOperationDistance)
mc.mcCntlGcodeExecuteWait(finst, "G90 G53 G0 X"..fXToolProbePosition.." Y"..fYToolProbePosition)
local toollen = mc.mcToolGetData(finst, mc.MTOOL_MILL_HEIGHT, ftool)
if toollen == 0 then
toollen = fDefaultToolLength
mc.mcCntlSetLastError(finst, "Tool length not found - using Default Length")
end
local probestart = fColletAtProbeZCoordinate + fExtraProbeDistance + toollen
local GCODE = "G91 G31 G0 Z"..probestart.." F"..fProbePrepSpeed
GCODE = ""..GCODE.." \n G91 G0 Z1 F"..fProbePrepSpeed.." \n G91 G31 Z"..fProbeOperationDistance.." F"..fProbeSpeed
mc.mcCntlGcodeExecuteWait(finst,GCODE)
end
function M6SetSoftLimits(inst, state) -- legal params = 0 and 1. They are the X and Y extents
--local inst = mc.mcGetInstance (mInst)
for i=0, (11) do
if mc.mcAxisIsEnabled (inst,i) == 1 and state == 1
then mc.mcSoftLimitSetState (inst,i,1) end
if mc.mcAxisIsEnabled (inst,i) == 1 and state == 0
then mc.mcSoftLimitSetState (inst,i,0) end
end
end
if (mc.mcInEditor() == 1) then
m6()
end