Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: McRoth on April 21, 2025, 10:16:26 PM
-
I got my M19 macro working but I found that Reset and even Disabling the control don't turn off the output. How would I go about having Reset shut it off? I think I found how to shut it off when Disabling the control. I haven't been able to find much info on Reset, like adding this to it.
Thx.
Mike
-
Does this look correct? I can't test it until tonight.
[mc.OSIG_OB1HOME] = function (state) --disable spindle orient if machine disabled or reset pressed
local machineenabled = mc.mcSignalGetHandle(inst, mc.OSIG_MACHINE_ENABLED)
if (machineenabled == 1) and (state == 1) then
mc.mcSignalSetState(mc.OSIG_OB1HOME, 0)
end
if (btnReset == 1) then
mc.mcSignalSetState(mc.OSIG_OB1HOME, 0)
end
end,
Thanks,
Mike
-
Had to add the following code to the disable and reset button scripts instead.
local inst, hSig, rc
inst = mc.mcGetInstance()
hSig, rc = mc.mcSignalGetHandle(inst, mc.OSIG_OB1HOME) -- Get handle for output 1
if (rc~= 0) then --Check our return call
mc.mcCntlSetLastError(inst, "There was an error")
end
rc = mc.mcSignalSetState(hSig, 0) --turn on output 1
return msg, rc
-
I make a reset function inside the screen load script.
From there I call reset from the button on the screen and a physical button I put on our machines.
I handle all the functions reset takes care of inside the function and also any other things I want turned off when you hit reset...
coolant, spindle, e stop or alarms (if possible), spindle orient, misc relays, etc.
You can call the reset function for a button press by putting it in the siglib assigned to an input. In buttons on the screen, just run a "clicked script" and have the reset function,
for me it is always "reset()".
Furthermore, I do the same with E Stop. I don't remember exactly how I handle this in the screenload script right off, it's been a while since I've written that code, maybe I put it in the siglib with the estop input, but I turn off everything I want turned off with the estop.... so coolant and spindle mainly, but sometimes I make sure I turn off certain solenoids on machines that may crash otherwise.
Just food for thought.