Hello Joeaverage! Thanks for the response. I will fill you in with where Im currently at in my "lua" journey. Wx4 screen set.
I have psychical Cycle start, feed hold, stop buttons coded and working as they should.. I also have coolant and "mist" buttons working correctly and triggering mach. Single block appears to work as well! Everything I have come up with so far is self modified / figured out versions of code that i have copied from around the web. After much head scratching i have made some small success. I will post all the code i have currently to make the buttons work, could you look at them and see if anything is crazy out of sorts? Everything appears to be working great.
The Homing part is what i do not understand. I like you idea for mapping to to one of my spare buttons on the HMI. I would like for the script to be in the homing sequence so it does it automatically... regardless of how it happens is the code the same? Something like after homing, X axis moves to center of table and Y axis moves a few inches... "reference complete". I sure do appreciate you time, let me know what you thoughts are!
The picture you posted.. Did you create this button? or is this a factory feature I'm not seeing?
Thanks again - Nick
SigLib = {
[mc.OSIG_MACHINE_ENABLED] = function (state)
machEnabled = state;
ButtonEnable()
end,
[mc.ISIG_INPUT0] = function (state)
if (state == 1) then
CycleStart()
end
end,
[mc.ISIG_INPUT1] = function (state)
if (state == 1) then
mc.mcCntlFeedHold (inst)
mc.mcCntlSetLastError (inst, "Do Feed Hold")
end
end,
[mc.ISIG_INPUT2] = function (state)
if (state == 1) then
CycleStop()
end
end,
----------Input 3------------
------Toggle Coolant---------
[mc.ISIG_INPUT3] = function (state)
if (state == 1) then
local inst = mc.mcGetInstance();
local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_COOLANTON);
local sigState = mc.mcSignalGetState(sigh);
if (sigState == 0) then
local OSigCool = mc.mcSignalGetHandle (inst,mc.OSIG_COOLANTON)
mc.mcSignalSetState(OSigCool,1)
mc.mcCntlSetLastError(inst, "Coolant On")
else
local OSigCool = mc.mcSignalGetHandle (inst,mc.OSIG_COOLANTON)
mc.mcSignalSetState(OSigCool,0)
mc.mcCntlSetLastError(inst, "Coolant Off")
end
end
end,
----------Input 4------------
------Toggle MIST - AIR Coolant---------
[mc.ISIG_INPUT4] = function (state)
if (state == 1) then
local inst = mc.mcGetInstance();
local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_MISTON);
local sigState = mc.mcSignalGetState(sigh);
if (sigState == 0) then
local OSigMist = mc.mcSignalGetHandle (inst,mc.OSIG_MISTON)
mc.mcSignalSetState(OSigMist,1)
mc.mcCntlSetLastError(inst, "Mist On")
else
local OSigMist = mc.mcSignalGetHandle (inst,mc.OSIG_MISTON)
mc.mcSignalSetState(OSigMist,0)
mc.mcCntlSetLastError(inst, "Mist Off")
end
end
end,
----------Input 5------------
------Toggle SingleBlock---------
[mc.ISIG_INPUT5] = function (state)
if (state == 1) then
local inst = mc.mcGetInstance();
local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SINGLE_BLOCK);
local sigState = mc.mcSignalGetState(sigh);
if (sigState == 0) then
local OSigSingle = mc.mcSignalGetHandle (inst,mc.OSIG_SINGLE_BLOCK)
mc.mcSignalSetState(OSigSingle,1)
mc.mcCntlSetLastError(inst, "Single Block On")
else
local OSigSingle = mc.mcSignalGetHandle (inst,mc.OSIG_SINGLE_BLOCK)
mc.mcSignalSetState(OSigSingle,0)
mc.mcCntlSetLastError(inst, "Single Block Off")
end
end
end,