24
« on: January 20, 2017, 11:44:29 AM »
Just for someone that is starting out with Mach4, I was trying to add Button input from the machine panel to Mach4 and here is what I did.
My first problem was trying to find out were the add some lua code for the inputs to work:
Open Mach4... 1- up top click on the Operator menu, then EDIT SCREEN. 2- In the tree manger (left side top box) click on wxrouter or the top item. 3- In the Properties (left side bottom box) click on the events button (middle one), then click on the SIGNAL SCRIPT line (Should be the bottom line), then a button should show up to the right of the line, click on the button and a mclua editor page will open. Then the code I added was at the end of what was there.
You will need to set up you inputs in Mach4 to match what is in the code
-------------------------------------------
----- My Code for input from Machine
-------------------------------------------
--------------------------------------------
----Cycle Start buttons on MachMate
--------------------------------------------
if (sig == mc.ISIG_INPUT1) and (state == 1) then
local inst = mc.mcGetInstance()
mc.mcCntlCycleStart(inst)
end
SignalTable = {
[mc.ISIG_INPUT1] = function (on_off)
if (on_off == 1) then
mc.mcCntlCycleStart(inst)
end
end
}
---------------------------------------------
----Feed Hold Buttons on MachMate
----------------------------------------------
if (sig == mc.ISIG_INPUT2) and (state == 1) then
local inst = mc.mcGetInstance()
mc.mcCntlFeedHold(inst)
end
SignalTable = {
[mc.ISIG_INPUT2] = function (on_off)
if (on_off == 1) then
mc.mcCntlFeedHold(inst)
end
end
}
Hope this help someone out.