I have my output from my VFD set to trigger when it is at zero. I have this connected to the Spindle at zero input. When I check with a meter this is going low. It takes 10 seconds for my spindle to stop.
So I added some script to make sure my spindle is stopped when doing a tool change.
------ Make sure the spindle is stopped ------
mc.mcCntlGcodeExecuteWait(inst, "M5\n")
local SpindleAtZero = mc.mcSignalGetHandle(inst, mc.ISIG_SPINDLE_AT_ZERO)
--local ret2 = mc.mcSignalGetState(mc.ISIG_SPINDLE_AT_ZERO)
local ret = mc.mcSignalWait(inst, SpindleAtZero, mc.WAIT_MODE_LOW, 10.0)
The first line appears to work and tells the spindle to stop.
The second line returns a number
The third line (Commented out) crashes Mach 4?


? So I have no way of telling what mach reads this as.
The 4th line always returns -2, and the is immediately skipped over even if the spindle is still rotating.
What am I doing wrong? I thought this line would make the machine stop and wait until it had stopped rotating, or the timeout expired. It's doing neither.
How do I wait for spindle at zero?