Hi,
easy, I added a toggle button to the DRO block. With ToolLegthComp ON (green and blinking) tool length
is compensated, ie subtracted from zOffset. Note the button is connected to Output#63
Then in the PLC script tests the state of Output#63 and compensate or not as the case may be.
--*****************************************************************************
local zOffset=mc.mcCntlGetOffset(inst,mc.Z_AXIS,mc.MC_OFFSET_FIXTURE)
local toolCompHandle=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT63)
local toolComp=mc.mcSignalGetState(toolCompHandle)
local toolNum=mc.mcToolGetCurrent(inst)
local toolLength=mc.mcToolGetData(inst,mc.MTOOL_MILL_HEIGHT,toolNum)
if (toolComp==0) then
zOffset=zOffset-toolLength
end
local workZMaxHandle=mc.mcRegGetHandle(inst,'core/inst/PathZmax')
local workZMax=mc.mcRegGetValue(workZMaxHandle)-zOffset
local workZMaxHandle=mc.mcRegGetHandle(inst,'iRegs0/workZMax')
mc.mcRegSetValue(workZMaxHandle,workZMax)
local workZMinHandle=mc.mcRegGetHandle(inst,'core/inst/PathZmin')
local workZMin=mc.mcRegGetValue(workZMinHandle)-zOffset
local workZMinHandle=mc.mcRegGetHandle(inst,'iRegs0/workZMin')
mc.mcRegSetValue(workZMinHandle,workZMin)
--**********************************************************************************
Note that I don't use tool lengths so it may be that the compensation is applied wrongly, ie negatively whereas
your expectation is for positive compensation. Please test it before use.
Craig