Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: McRoth on April 20, 2025, 06:07:53 PM
-
I'm trying to add a script to my screen load script for a physical button to activate the knock out to release the tool. I could probably just trigger it but I want to have logic to make sure the spindle is stopped. I've tried a lot of combinations but it refuses to activate the output. Here's the latest code I've tried:
[mc.ISIG_INPUT3] = function (state)
local output6 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT6)
-- local spin0 = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT0);
-- local spin0state = mc.mcSignalGetState(spin0)
mc.ISIG_INPUT0 = function (state1)
if(state == 1) and
(state1 == 1) then
mc.mcSignalSetState(output6, 1)
end
end
end,
I've tried what's commented out. Tried using SpindleAtZero, this the I made input 0 the same as SpindleAtZero. Any suggestions?
Thanks,
Mike
-
I just figured it out! Only issue now is the last section doesn't shut off output6 if I wiggle the spindle. I tried it with an or instead of 2 if statements, but it didn't work either. it won't activate if the spindle is running though, which is the main thing I wanted.
[mc.ISIG_INPUT3] = function (state)
local output6 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT6)
local spin0 = mc.mcSignalGetHandle(inst, mc.ISIG_SPINDLE_AT_ZERO);
local spin0state = mc.mcSignalGetState(spin0)
if(state == 1) and
(spin0state == 1) then
mc.mcSignalSetState(output6, 1)
end
if(state == 0) then
mc.mcSignalSetState(output6, 0)
end
if(spin0state == 0) then
mc.mcSignalSetState(output6, 0)
end
end,
-
I think this should do what you want.
[mc.ISIG_INPUT3] = function (state)
local output6 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT6)
local spin0 = mc.mcSignalGetHandle(inst, mc.ISIG_SPINDLE_AT_ZERO);
local spin0state = mc.mcSignalGetState(spin0)
if(state == 1) and (spin0state == 1) then
mc.mcSignalSetState(output6, 1)
else
mc.mcSignalSetState(output6, 0)
end
end,
-
Thanks Graham!