----------------------------------------------------------------------------- -- Machine Type: Standard Control -- Author: MachMotion Development Team -- Created: 2013-09-24 -- Modified by: MachMotion Development Team -- Modified on: 2017-03-06 -- Copyright: © 2013-2018 Edge Solutions LLC All Rights Reserved ----------------------------------------------------------------------------- -- Inherit from the OEM module. local UserGUIModule = ModuleLoader.RequireOEMUserGUIModule(UserGUIModule) --[[ List Of Included Functions: PLC CycleStart FeedHold CycleStop Disable Enable GetCurrentGearRange GetCurrentToolPocket HomeAll HomeX HomeY HomeZ HomeA HomeB HomeC ZeroAll ZeroX ZeroY ZeroZ ZeroA ZeroB ZeroC PositionDisplayLocked PositionDisplayUnLocked RunFromHere CalculateManualToolSetterPosition CalculateAutoToolSetterPosition CalculateToolLengthManualBtn CalculateZWorkOffsetManualBtn CalculateToolLengthAutoBtn --]] --[[ function UserGUIModule.UserPLCScript() ------------------ Add user code below this line ------------------ local MachState = mc.mcCntlGetState(inst); ------------------ Don't Edit below this line ------------------ return true, true, "PLC Script Complete" end ]]-- function UserGUIModule.UserScreenLoadScript() m.screen.HideAxis(mc.OB1_AXIS) m.screen.HideAxis(mc.B_AXIS) return true, true, w.FunctionCompleted() end --[[ --Retract Code local GcodeString = "G40 G69 G50 \n G90 G53 G00 Z-0.25 \n M05" local a,b,c = w.SetRegValueString("core/inst", "RetractCode", GcodeString) if b ~= true then return nil, false, w.FunctionError(c) end --END Retract Code ]]-- ------------------ Don't Edit below this line ------------------ --[[ function UserGUIModule.HomingSaftey() local a,b,c = w.MDICommand("G54\n M232 R1" , false, "Setting Up Table Motors", false) if b ~= true then return nil, false, w.FunctionError(c) end w.SetSignalState(mc.OSIG_OUTPUT21, true) w.SetSignalState(mc.OSIG_OUTPUT22, false) w.SetSignalState(mc.OSIG_OUTPUT23, false) local a,b,c = w.SetOEMParamSig("TC_CarouselEngagedOutput", false) if b ~= true then return nil, false, w.FunctionError(c) end local a,b,c = w.WaitForOEMParamSig("TC_CarouselEngagedInput", false, 2000, "Wait for Carousel Engaged Input to turn off") if b ~= true then return nil, false, w.FunctionError(c) end return true, true, w.FunctionCompleted() end function UserGUIModule.UserHomeAllEnd() local a,b,c = w.PleaseWaitDialog(6, "Finishing Homing..", false, 800) if b ~= true then return nil, false, w.FunctionError(c) end local a,b,c = w.MDICommand("G90 G53 G00 Y-0.25 A-0.25" , false, "Moving Y and A to Zero", false) if b ~= true then return nil, false, w.FunctionError(c) end return true, true, w.FunctionCompleted() end function UserGUIModule.UserScreenUnLoadScript() ------------------ Add user code below this line ------------------ local MachState = mc.mcCntlGetState(inst); ------------------ Don't Edit below this line ------------------ return true, true, w.FunctionCompleted() end function UserGUIModule.UserSignalScript(sig, state) ------------------ Add user code below this line ------------------ local MachState = mc.mcCntlGetState(inst); ------------------ Don't Edit below this line ------------------ return true, true, w.FunctionCompleted() end --]] --[[ function UserGUIModule.UserCycleStart() --Here is where you add any other safety checks. --If you need to lockout the function return false on the second return. Example: return nil, false, "User Function Failed" --return nil, false, "User Function Failed" return true, true, w.FunctionCompleted() end --]] --[[ function UserGUIModule.UserFeedHold() local a,b,c = m.ManualModeIsActive(true) if a == true or b ~= true then return nil, false, w.FunctionError(c) end -- Ignore Feed-hold in tool change a,b,c = w.GetSignalState(mc.OSIG_TOOL_CHANGE) if b ~= true then return nil, false, w.FunctionError(c) end if a == true then return nil, false, w.FunctionError("Feed Hold Ignored in Tool Change") end -- Ignore Feed-hold in Macro Hold state local rc = mc.mcCntlGetState(inst) if rc == mc.MC_STATE_FRUN_MACROH or rc == mc.MC_STATE_MRUN_MACROH then return nil, false, w.FunctionError("Feed Hold Ignored in Macro Hold") end if rc == mc.MC_STATE_FRUN or rc == mc.MC_STATE_FRUN_PROBE or rc == mc.MC_STATE_MRUN or rc == mc.MC_STATE_MRUN_PROBE or rc == mc.MC_STATE_FRUN_TAP or rc == mc.MC_STATE_MRUN_TAP then local CutterCompActive = mc.mcCntlGetPoundVar(inst, mc.SV_MOD_GROUP_7) if CutterCompActive == 40 then --Use Retract local waitstate if rc == mc.MC_STATE_FRUN then waitstate = mc.MC_STATE_FRUN_FH elseif rc == mc.MC_STATE_FRUN_PROBE then waitstate = mc.MC_STATE_FRUN_PROBE_FH elseif rc == mc.MC_STATE_FRUN_THREAD then waitstate = mc.MC_STATE_FRUN_THREAD_FH elseif rc == mc.MC_STATE_MRUN then waitstate = mc.MC_STATE_MRUN_FH elseif rc == mc.MC_STATE_MRUN_PROBE then waitstate = mc.MC_STATE_MRUN_PROBE_FH elseif rc == mc.MC_STATE_MRUN_THREAD then waitstate = mc.MC_STATE_MRUN_THREAD_FH end local a,b,c = w.SetSignalState(mc.ISIG_RTRCT, true) if b ~= true then return nil, false, w.FunctionError(c) end if waitstate ~= nil then local a,b,c = w.PleaseWaitDialog(1, "Retracting Z Axis...", false, waitstate) w.SetSignalState(mc.ISIG_RTRCT, false) if b ~= true then return nil, false, w.FunctionError(c) end else w.Sleep(100) end local a,b,c = w.SetSignalState(mc.ISIG_RTRCT, false) if b ~= true then return nil, false, w.FunctionError(c) end else --Use Feed Hold local rc = mc.mcCntlFeedHold(inst) if rc ~= mc.MERROR_NOERROR then return nil, false, w.FunctionError(rc) end end end return false, true, w.FunctionCompleted() end --]] --[[ function UserGUIModule.UserCycleStop() --Here is where you add any other safety checks. --If you need to lockout the function return false on the second return. Example: return nil, false, "User Function Failed" return true, true, w.FunctionCompleted() end --]] --[[ function UserGUIModule.UserDisable() --Here is where you add any Outputs that need to be turned off on Disable. --Example: w.SetSignalState(mc.OSIG_SPINDLEON,false) return true, true, w.FunctionCompleted() end --]] --[[ function UserGUIModule.UserEnable() --Here is where you add any other safety checks. --If you need to lockout the function return false on the second return. Example: return nil, false, "User Function Failed" --If you return false on the first return and a true on the second then the the user macro must compleat the whole enable proses. return true, true, w.FunctionCompleted() end --]] --[[ function UserGUIModule.UserGetCurrentGearRange() This function needs to return the current gear range. The actual gear shifting happens in the M40-M45 macros return CurrentGearRange, true, w.FunctionCompleted() end --]] --[[ function UserGUIModule.UserGetCurrentToolPocket() This function needs to return the current tool pocket. return CurrentPocket, true, w.FunctionCompleted() end --]] --[[ --Only do output if spindle off and idle. function UserGUIModule.UserAuxiliaryBtn1(MouseUp, MouseDn, OutputSig, Toggle) -- if first Return is true the screen controls the output -- if first Return if false the user script needs to control the output -- if there is a error and you want a report return false on the second return followed by a message on the third return local inst = mc.mcGetInstance("MachMotion Macro") -- Get the current instance local state = mc.mcCntlGetState(inst) -- check for spindle off and idle to continue. Otherwise return a false for the first return so the screen won't control the user output for chuck. if (state ~= mc.MC_STATE_IDLE) or (w.GetSignalState(mc.OSIG_SPINDLEON) == true) or (w.GetSignalState(mc.OSIG_SPINDLEREV) == true) or (w.GetSignalState(mc.OSIG_SPINDLEFWD) == true) then m.SetWarningMessage("Must be idle with spindle off to control chuck", true, false) return false, true, w.FunctionCompleted() end return true, true, w.FunctionCompleted() end --]] --[[ function UserGUIModule.UserAuxiliaryBtn2(MouseUp, MouseDn, OutputSig, Toggle) -- if first Return is true the screen controls the output -- if first Return if false the user script needs to control the output -- if there is a error and you want a report return false on the second return followed by a message on the third return local inst = mc.mcGetInstance("MachMotion Macro") -- Get the current instance local state = mc.mcCntlGetState(inst) if MouseUP then end return true, true, w.FunctionCompleted() end --]] function UserGUIModule.CreateUserCommands() -- w.CreateCommandActionOption("Example", function(from_opr_panel) w.SetSignalState(mc.OSIG_OUTPUT0, true) end) -- w.CreateCommandFeedbackOption("Example", function() return w.GetSignalState(mc.OSIG_OUTPUT0) end) -- w.CreateSimpleCommand("Example") end return UserGUIModule