91
Mach4 General Discussion / Re: Jogging/Pendant Interface-What is the best way? Ramblings
« on: May 16, 2015, 08:52:13 PM »
There are 'actions' and there are Lua scripts. These are different animals and screen buttons can do either or both.
'Clicked Script' would run Lua code one time when the button was used, and it sees a mouse click as a singular event. This would not work for jogging. There are a bunch of 'actions' defined for use with screen buttons. For example Jog X+ and Jog X off which are in the mouse down and mouse up entries in the standard MACH4 screen jog buttons.
To send a signal based on machine state would require monitoring. A way to do that is with the PLC script which runs continuously. All of my code for the joystick jogging is in the PLC script.
here is a fragment showing a way to monitor the machine condition:
--InTurn Code
EstopIssued = machEnabled;
-- Spindle power bar graph
--local EstopIssued = 0;
if (EstopIssued == 0) then
mc.mcRegSetValue(EstopTOInTurnRegister,1);
if ((scr.GetProperty('tbuttonSPIN','Button State')) ~= '0') then
scr.SetProperty('tbuttonSPIN','Button State','Up');
end
local InTurnSpindleHandle = mc.mcRegGetHandle(inst, "modbus0/InTurnIN12");
mc.mcRegSetValue(InTurnSpindleHandle, 0);
else
mc.mcRegSetValue(EstopTOInTurnRegister,0);
end
'Clicked Script' would run Lua code one time when the button was used, and it sees a mouse click as a singular event. This would not work for jogging. There are a bunch of 'actions' defined for use with screen buttons. For example Jog X+ and Jog X off which are in the mouse down and mouse up entries in the standard MACH4 screen jog buttons.
To send a signal based on machine state would require monitoring. A way to do that is with the PLC script which runs continuously. All of my code for the joystick jogging is in the PLC script.
here is a fragment showing a way to monitor the machine condition:
--InTurn Code
EstopIssued = machEnabled;
-- Spindle power bar graph
--local EstopIssued = 0;
if (EstopIssued == 0) then
mc.mcRegSetValue(EstopTOInTurnRegister,1);
if ((scr.GetProperty('tbuttonSPIN','Button State')) ~= '0') then
scr.SetProperty('tbuttonSPIN','Button State','Up');
end
local InTurnSpindleHandle = mc.mcRegGetHandle(inst, "modbus0/InTurnIN12");
mc.mcRegSetValue(InTurnSpindleHandle, 0);
else
mc.mcRegSetValue(EstopTOInTurnRegister,0);
end