I have written this example below which will blink output 5 when the tool change output is active as suggested by jbuehn. This should automatically turn on when running M6. Instead of using the feed hold output for your LED, I think it is better to map it to a normal output so that we are not overriding the state of the feed hold output which is controlled by Mach when going into/coming out of feed hold.
Drop this code into your screen load script. It is the timer that will 'blink' the output. Remember to change the output number where stated (currently set to output 5)
FeedHoldTimerPanel = wx.wxPanel (wx.NULL, wx.wxID_ANY, wx.wxDefaultPosition, wx.wxSize( 0,0 ) )
FeedHoldTimer = wx.wxTimer(FeedHoldTimerPanel)
FeedHoldTimerPanel:Connect(wx.wxEVT_TIMER,
function (event)
local inst = mc.mcGetInstance()
local hSig = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT5) --SET OUTPUT NUMBER
local sSig = mc.mcSignalGetState(hSig)
if sSig == mc.MC_ON then
mc.mcSignalSetState(hSig, mc.MC_OFF)
else
mc.mcSignalSetState(hSig, mc.MC_ON)
end
end)
Put this into your signal library. Remember to change the output number where stated (currently set to output 5)
[mc.OSIG_FEEDHOLD] = function (state)
--Use mach controlled feed hold output to activate the feed hold LED
local inst = mc.mcGetInstance()
local hSig = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT5) --SET OUTPUT NUMBER
if( state == 1) then
mc.mcSignalSetState(hSig, mc.MC_ON)
else
mc.mcSignalSetState(hSig, mc.MC_OFF)
end
end,
[mc.OSIG_TOOL_CHANGE] = function (state)
local inst = mc.mcGetInstance()
if( state == 1) then
--Start timer to flash feed hold LED 500ms interval
FeedHoldTimer:Start(500, false)
else
--Stop timer and turn off feed hold LED in case it's still on.
FeedHoldTimer:Stop()
local hSig = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT5) --SET OUTPUT NUMBER
mc.mcSignalSetState(hSig, mc.MC_OFF)
end
end