Use the motion inhibit input signal. ISIG_MOTION_INHIBIT
In the Screen load script:
function Checkhomed()
local inst = mc.mcGetInstance('CheckHomed')
local homedX, homedY, homedZ, homed, rc, hSig, inhibit
homedX, rc = mc.mcAxisIsHomed(inst, mc.X_AXIS)
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 5000, 'Could not retrieve X axis homed condition!')
return
end
homedY, rc = mc.mcAxisIsHomed(inst, mc.Y_AXIS)
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 5001, 'Could not retrieve Y axis homed condition!')
return
end
homedZ, rc = mc.mcAxisIsHomed(inst, mc.Z_AXIS)
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 5002, 'Could not retrieve Z axis homed condition!')
return
end
hSig, rc = mc.mcSignalGetHandle(mc.ISIG_MOTION_INHIBIT)
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 5003, 'Could not retrieve ISIG_MOTION_INHIBIT signal handle!')
return
end
inhibit, rc = mc.mcSignalGetState(hSig)
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 5004, 'Could not retrieve ISIG_MOTION_INHIBIT signal state!')
return
end
homed = homedX and homedY and homedZ
if ((homed == 0) and (inhibit == 0)) then
rc = mc.mcSignalSetState(hSig, 1) -- raise the mc.ISIG_MOTION_INHIBIT signal
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 5005, 'Could not set ISIG_MOTION_INHIBIT signal state to 1!')
return
end
elseif ((homed == 1) and (inhibit == 1)) then
rc = mc.mcSignalSetState(hSig, 0) -- raise the mc.ISIG_MOTION_INHIBIT signal
if (rc ~= mc.MERROR_NOERROR) then -- check retun codes!
mc.mcCntlMacroAlarm(inst, 5006, 'Could not set ISIG_MOTION_INHIBIT signal state to 0!')
return
end
end
end
Then call Checkhomed() from the PLC script
Steve