-- CNC4PC Pendant MPG16 --
--------------------------------------
-- Flood --
--------------------------------------
function Flood()
local IOName = mc.OSIG_COOLANTON; --Save the name of the Signal (as stored inside of Mach4)
local sigh = mc.mcSignalGetHandle(inst, IOName);
local sigState = mc.mcSignalGetState(sigh);
if (sigState == 1) then
mc.mcSignalSetState(sigh, 0);
else
mc.mcSignalSetState(sigh, 1);
end
end
--------------------------------------
-- MPG --
--------------------------------------
mc.mcMpgSetAxis(inst, 1, 2);
mc.mcMpgSetAxis(inst, 0, 0);
mc.mcMpgSetAxis(inst, 0, 0);
[mc.ISIG_INPUT10] = function (state)
CNC4PCPendantMPG16()
end,
[mc.ISIG_INPUT11] = function (state)
CNC4PCPendantMPG16()
end,
[mc.ISIG_INPUT12] = function (state)
CNC4PCPendantMPG16()
end,
[mc.ISIG_INPUT13] = function (state)
CNC4PCPendantMPG16()
end,
[mc.ISIG_INPUT14] = function (state)
CNC4PCPendantMPG16()
end,
[mc.ISIG_INPUT15] = function (state)
CNC4PCPendantMPG16()
end,
[mc.ISIG_INPUT16] = function (state)
CNC4PCPendantMPG16()
end,
[mc.ISIG_INPUT17] = function (state)
CNC4PCPendantMPG16()
end,
[mc.ISIG_INPUT18] = function (state)
CNC4PCPendantMPG16()
end,
[mc.ISIG_INPUT19] = function (state)
CNC4PCPendantMPG16()
end,
---------------------------------------------------------------
-- CNC4PC Pendant function.
---------------------------------------------------------------
function CNC4PCPendantMPG16()
local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT10) -- Is mapped to Port 2 or Port 3 Pin 4 *Cycle Start
local Cycle_Start, rc = mc.mcSignalGetState(hSig)
local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT11) -- Is mapped to Port 2 or Port 3 Pin 5 *Feed Hold
local Feed_Hold, rc = mc.mcSignalGetState(hSig)
local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT12) -- Is mapped to Port 2 or Port 3 Pin 6 *Spindle CW
local Spindle_CW, rc = mc.mcSignalGetState(hSig)
local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT13) -- Is mapped to Port 2 or Port 3 Pin 7 *Flood
local Flood_on_off, rc = mc.mcSignalGetState(hSig)
local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT14) -- Is mapped to Port 2 or Port 3 Pin 8 *.001 Selection
local Step001, rc = mc.mcSignalGetState(hSig)
local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT15) -- Is mapped to Port 2 or Port 3 Pin 9 *.010 Selection
local Step010, rc = mc.mcSignalGetState(hSig)
local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT16) -- Is mapped to Port 2 or Port 3 Pin 10 *.100 Selection
local Step100, rc = mc.mcSignalGetState(hSig)
local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT17) -- Is mapped to Port 2 or Port 3 Pin 15 *Estop
local PenStop, rc = mc.mcSignalGetState(hSig)
if Cycle_Start == 1 then
CycleStart()
mc.mcCntlSetLastError(inst, "CycleStart")
elseif Feed_Hold == 1 then
mc.mcCntlFeedHold(0);
mc.mcCntlSetLastError(inst, "FeedHold")
elseif Spindle_CW == 1 then
mc.mcCntlSetLastError(inst, "SpinCW")
SpinCW()
elseif Flood_on_off == 1 then
mc.mcCntlSetLastError(inst, "Flood")
Flood()
else
--mc.mcCntlSetLastError(inst, "No Axis Selected")
end
if Step001 == 1 then
mc.mcMpgSetInc(inst, 0, .001)
mc.mcMpgSetInc(inst, 1, .001)
elseif Step010 == 1 then
mc.mcMpgSetInc(inst, 0, .010)
mc.mcMpgSetInc(inst, 1, .010)
elseif Step100 == 1 then
mc.mcMpgSetInc(inst, 0, .100)
mc.mcMpgSetInc(inst, 1, .100)
end
if PenStop == 1 then
mc.mcCntlEStop(inst)
end
end