Hi Craig. Thanx for your reply.
As time has past and no one had a awnser I had to try myself. And I got it to work
Take a look at the LUA below. I only got the X,Y,Z axis active for now.
I allso added a line ( scr.SetProperty('mpgaxisdisplay', 'Label', 'X axis'); under each Axis selection to post on screen what axis are currently active.
To display the current Axis just make an Toggle button in screen edit, and name it "mpgaxisdisplay" This name can be what you desire, but MUST be the same as in the
( scr.SetProperty('mpgaxisdisplay', 'Label', 'X axis'); line. The name is allso Case Sensitive !!!. And ofcourse you will need to change the X letter with Y, Z,A.. and so on in this line to show correct axis.
Actually this line can be used to display anything you want at anny time
The momentary buttons on my Control Panel are connected to a POKEYS57U board, and can easly be mapped to your desired Signal Inputs in MACH Config.
In my case as you see in the script I use Input 50, 51 and 52 for my X Y and Z axis.
Thats it. Now Axis selection will work with momentary buttons, and the current axis will be displayed on screen.
--------------------------------------
-- CNC4PC Pendant --
--------------------------------------
-- These simply run the CNC4PCPendant function if their state changes.
[mc.ISIG_INPUT50] = function (state) CNC4PCPendant() end,
[mc.ISIG_INPUT51] = function (state) CNC4PCPendant() end,
[mc.ISIG_INPUT52] = function (state) CNC4PCPendant() end,
--[mc.ISIG_INPUT13] = function (state) CNC4PCPendant() end,
--[mc.ISIG_INPUT14] = function (state) CNC4PCPendant() end,
--[mc.ISIG_INPUT15] = function (state) CNC4PCPendant() end,
--[mc.ISIG_INPUT16] = function (state) CNC4PCPendant() end,
--[mc.ISIG_INPUT17] = function (state) CNC4PCPendant() end,
--[mc.ISIG_INPUT18] = function (state) CNC4PCPendant() end,
--[mc.ISIG_INPUT19] = function (state) CNC4PCPendant() end,
}
-------------------------------------------------------------
-- CNC4PC Pendant function. --
-------------------------------------------------------------
function CNC4PCPendant()
local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT50) -- Is mapped to Pokeys pin50 *X Selection
local XSelection, rc = mc.mcSignalGetState(hSig)
local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT51) -- Is mapped to Pokeys pin51 *Y Selection
local YSelection, rc = mc.mcSignalGetState(hSig)
local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT52) -- Is mapped to Pokeys pin52 *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 hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT18) -- Is mapped to Port 2 Pin 12 *B Selection
--local BSelection, rc = mc.mcSignalGetState(hSig)
--local hSig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT19) -- Is mapped to Port 2 Pin 13 *C Selection
--local CSelection, 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)
scr.SetProperty('mpgaxisdisplay', 'Label', 'X axis');
elseif YSelection == 1 then
mc.mcMpgSetAxis(inst, 0, 1) --Y Axis
mc.mcCntlSetLastError(inst, "Y Selected")
mc.mcSignalSetState(PenJogOn, 1)
scr.SetProperty('mpgaxisdisplay', 'Label', 'Y axis');
elseif ZSelection == 1 then
mc.mcMpgSetAxis(inst, 0, 2) --Z Axis
mc.mcCntlSetLastError(inst, "Z Selected")
mc.mcSignalSetState(PenJogOn, 1)
scr.SetProperty('mpgaxisdisplay', 'Label', 'Z axis');
--elseif ASelection == 1 then
-- mc.mcMpgSetAxis(inst, 0, 3) --A Axis
-- mc.mcCntlSetLastError(inst, "A Selected")
-- mc.mcSignalSetState(PenJogOn, 1)
--elseif BSelection == 1 then
-- mc.mcMpgSetAxis(inst, 0, 4) --B Axis
-- mc.mcCntlSetLastError(inst, "B Selected")
-- mc.mcSignalSetState(PenJogOn, 1)
--elseif CSelection == 1 then
-- mc.mcMpgSetAxis(inst, 0, 5) --C Axis
-- mc.mcCntlSetLastError(inst, "C 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
To make it work with momentary buttons I had to disable the:
--else mc.mcMpgSetAxis(inst, 0, -1) --No Axis
-- mc.mcCntlSetLastError(inst, "No Axis Selected")
-- mc.mcSignalSetState(PenJogOn, 0)