Hello! I´ve found a guide online about how to use a Pendant in mach 4 by Shane | Engineer, added the code in screen load script and restarted mach4, has not plugged in and tested since I do not have an MPG / Pendant yet. but will build one soon.
The problem is that it removes on screen jog functions and Ref all home button? They get grayed out? or loose i´ts clickability and I still want to keep those features even if a pendant is installed? maybe if there is a Enable button for the pendant that deactivates jog on screen? or if the pendant only works when a axis is selected and then it deactivates the jog on screen features?
so if the pendant is not enabled the jog functions in mach 4 must be usable, and I don't care if the jog on-screen functions never get disabled, as long as both pendant and jog on screen works?
The Code below is added to the bottom of the screen load script:
--------------------------------------
-- MPG Code --
--------------------------------------
SigLib = {
[mc.ISIG_INPUT10] = function (state)
RunPendant()
end,
[mc.ISIG_INPUT11] = function (state)
RunPendant()
end,
[mc.ISIG_INPUT12] = function (state)
RunPendant()
end,
[mc.ISIG_INPUT13] = function (state)
RunPendant()
end,
[mc.ISIG_INPUT14] = function (state)
RunPendant()
end,
[mc.ISIG_INPUT15] = function (state)
RunPendant()
end,
[mc.ISIG_INPUT16] = function (state)
RunPendant()
end,
[mc.ISIG_INPUT17] = function (state)
RunPendant()
end
}
---------------------------------------------------------------
-- Pendant function.
---------------------------------------------------------------
function RunPendant()
local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT10) -- Is mapped to Port 2 Pin 4 *X Selection
local XSelection, rc = mc.mcSignalGetState(hSig)
local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT11) -- Is mapped to Port 2 Pin 5 *Y Selection
local YSelection, rc = mc.mcSignalGetState(hSig)
local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT12) -- Is mapped to Port 2 Pin 6 *Z Selection
local ZSelection, rc = mc.mcSignalGetState(hSig)
local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT13) -- Is mapped to Port 2 Pin 7 *A Selection
local ASelection, rc = mc.mcSignalGetState(hSig)
local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT14) -- Is mapped to Port 2 Pin 8 *.001 Selection
local Step001, rc = mc.mcSignalGetState(hSig)
local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT15) -- Is mapped to Port 2 Pin 9 *.010 Selection
local Step010, rc = mc.mcSignalGetState(hSig)
local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT16) -- Is mapped to Port 2 Pin 10 *.100 Selection
local Step100, rc = mc.mcSignalGetState(hSig)
local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT17) -- Is mapped to Port 2 Pin 15 *Estop
local PenStop, rc = mc.mcSignalGetState(hSig)
local PenJogOn, rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT10)-- Is mapped to Port 2 Pin 1 *Jog on LED
if XSelection == 1 then
mc.mcMpgSetAxis(inst, 0, 0) --X Axis
mc.mcCntlSetLastError(inst, "X Selected")
mc.mcSignalSetState(PenJogOn, 1)
elseif YSelection == 1 then
mc.mcMpgSetAxis(inst, 0, 1) --Y Axis
mc.mcCntlSetLastError(inst, "Y Selected")
mc.mcSignalSetState(PenJogOn, 1)
elseif ZSelection == 1 then
mc.mcMpgSetAxis(inst, 0, 2) --Z Axis
mc.mcCntlSetLastError(inst, "Z Selected")
mc.mcSignalSetState(PenJogOn, 1)
elseif ASelection == 1 then
mc.mcMpgSetAxis(inst, 0, 3) --A Axis
mc.mcCntlSetLastError(inst, "A Selected")
mc.mcSignalSetState(PenJogOn, 1)
else
mc.mcMpgSetAxis(inst, 0, -1) --No Axis
mc.mcCntlSetLastError(inst, "No Axis Selected")
mc.mcSignalSetState(PenJogOn, 0)
end
if Step001 == 1 then
mc.mcMpgSetInc(inst, 0, .001)
elseif Step010 == 1 then
mc.mcMpgSetInc(inst, 0, .010)
elseif Step100 == 1 then
mc.mcMpgSetInc(inst, 0, .100)
end
if PenStop == 1 then
mc.mcCntlEStop(inst)
end
end