I have a working m6 macro for an ATC on a self built 6 axis router (5A with twin Y tables).
I have a moving rack on slides run by an air cylinder to move the rack into and out of the tool change area. I use a repeat-until loop after turning on the output to wait until the sensor at the end of cylinder stroke goes on. what I want to do is add some kind of timer to the loop so if the rack gets jammed it won't sit there forever waiting for the sensor to go on. I can't figure out the lua timer function. I added a counter to the loop, but trying to figure out the count value that works is tough to do, and I have 6 or so of these loops all needing different time values, would be better if I could use a timer. Maybe there is another structure I could use instead of repeat-until. Not really a programmer, just good enough to fumble through examples to figure out how to get it to work.
here is what lua script looks like with the counter:
local OUT1 = mc.mcSignalGetHandle(inst, OSIG_OUTPUT1)
local IN7 = mc.mcSignalGetHandle(inst, ISIG_INPUT7)
local a=0
mc.mcSignalSetState(OUT1,1)
repeat
local mc.mcSignalGetState(IN7)
a=a+1
until IN7 == 1 or a==100000000
if a==100000000 then
mc.mcCntlEStop(inst)
mc.mcSetLastError(inst, "toolrack jammed")
end