Good morning. We are setting up a small manufacturing cell using 3 different Tormach mills. I would like to use the M66 P0 L3 command to wait for the start cycle command from the PLC. Do I have to enter a “Q” number or can I omit that to allow it to wait for the signal indefinitely?
Thanks
According to the official documentation, the Q value is necessary and must be non-zero unless the L value is zero. I checked the linuxcnc documentation as well and there is nothing there about an indefinite wait period either. Neither source mentions anything about code execution after a timeout event so it’s possible the machine simply starts executing the next line of code, or it may throw an error and stop the program entirely.
However, the linuxcnc doc’s also state that if the timeout period is exceeded, variable #5399 will store a value of -1. Assuming the timeout does not throw an error, you could could use a while loop around the M66 to check that variable and only proceed when it no longer equals -1. I’ve not done this myself so do NOT trust this code without testing it but it ought to look something like this:
#5399 = -1
o100 while [#5399 NE -1]
M66 P0 L3 Q(whatever timeout value you want)
o100 endwhile
If I wrote that right, it will preset the variable to the timeout value, enter the loop, check the input, and hold in the loop until the value is something other than -1 (meaning the input was activated).
Be aware this loop has no other way out other than the variable changing from -1 to something else. Neither doc source indicates that 5399 will change away from -1 if the input is activated, only that it becomes -1 after the M66 command times out (unless the input is analog which your’s isn’t since you’re using a P word). I don’t have any experience with the IO board so the code is all speculative. Please test it before loading a tool or material and be prepared to manually stop the program if the loop fails to exit once the input state changes.
Thank you for the response. We will give that a try.