With the help of Illya and Brian
As an update for all, the script does not go into the PLC Script, it goes in the Screen Load Script.
works sweet now.
thanks guys
SigLib = {
--Enable
[mc.OSIG_MACHINE_ENABLED] = function (state)
machEnabled = state;
end,
--HeadUp
[mc.ISIG_INPUT1] = function (on_off)--mc.ISIG_INPUT1
if( on_off==1 ) then
-- On
else
-- Off
end
end,
--HeadDn
[mc.ISIG_INPUT2] = function (state)--mc.ISIG_INPUT2
if( state == 1 ) then
-- On
else
-- Off Call A function here if you wanted
end
end,
[mc.ISIG_INPUT3] = function (state)--mc.ISIG_INPUT3 --Used as an enable button
if( state == 1 ) then
local inst= mc.mcGetInstance();
local reg = mc.mcSignalGetHandle(inst, mc.OSIG_MACHINE_ENABLED)
state = mc.mcSignalGetState(reg);
if(state == 1)then
state = 0
else
state = 1
end
mc.mcCntlEnable(inst, state);
end
end,
[mc.ISIG_INPUT4] = function (state)--mc.ISIG_INPUT2 button to do feed hold
if( state == 1 ) then
local inst= mc.mcGetInstance();
mc.mcCntlFeedHold(inst)
end
end,
[mc.ISIG_INPUT5] = function (state)--mc.ISIG_INPUT5
if( state == 1 ) then
CycleStart() --Run my cycle start function
end
end,
[mc.ISIG_INPUT6] = function (state)--mc.ISIG_INPUT6
local inst = mc.mcGetInstance();--Tool Release Button
local hsig = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT7);
if( state==1 ) then
--Check to see if the spindle is stopped here
--Turn On Tool Release (Unclam Tool)
mc.mcSignalSetState(hsig, 1 );
else
--Turn Off Tool Release (Clamp Tool)
mc.mcSignalSetState(hsig, 0 );
end
end
}
this still goes in the signal script:
if(SigLib[sig] ~= nil)then
SigLib[sig](state);
end