-------------------------------------------------------------------------------------------- --This function will be used to turn on a specific output and wait for an input or time out. --Use this macro for the part enter routine. -------------------------------------------------------------------------------------------- function m1002() local rc = 0; --return code. local inst = mc.mcGetInstance(); --retrieve the current instance of MACH --Modify the following variables to match the output you wish to turn on. --Turns ON the outputs. local grinder = mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.OSIG_OUTPUT2),1) --Creates a message in the History. mc.mcCntlSetLastError(inst, "Waiting for Part in Position LS") --Waits for Input5 for 20 secs, then continues if signal not seen. mc.mcSignalWait(inst, mc.ISIG_INPUT5, mc.WAIT_MODE_HIGH, 20) local state, rc = mc.mcSignalGetState (mc.mcSignalGetHandle (0, mc.ISIG_INPUT5)) local inst = mc.mcGetInstance() if (state ==1) then --Turns OFF the Outputs. mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.OSIG_OUTPUT2),0) else mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.OSIG_OUTPUT2),0) mc.mcCntlCycleStop (inst); mc.mcCntlReset (inst); end --Creates a message in the History. mc.mcCntlSetLastError(inst, "Push Cycle Start") --This is for the end of the function. end if (mc.mcInEditor()==1) then m1002() end