LinuxCNC M66 Wait on Input

M66 pauses program execution until a selected digital or analog input reaches a specified state, or until a programmed timeout expires. The input is chosen with a P- word (digital) or an E- word (analog), the wait condition with an L- word, and the timeout in seconds with a Q- word. The input value read is stored in parameter #5399, which holds -1 if the timeout is exceeded.

Source checked11/11 values · 2026-10-26

Specification

1 source
Languagegcode
CodeM66
GroupM-Codes
SyntaxM66 P- | E- <L->
DialectLinuxCNC

Parameters

NameDescription
P-Digital input number from 0 to 3 (adjustable with the motmod num dio argument).
E-Analog input number from 0 to 3 (adjustable with the motmod num aio argument).
L-Wait mode type: 0 IMMEDIATE, 1 RISE, 2 FALL, 3 HIGH, 4 LOW.
Q-Timeout in seconds for waiting; if exceeded, #5399 holds -1. Ignored when L is 0; a Q value of zero is an error when L is non-zero.

Study notes

  • Wait modes: 0 IMMEDIATE (no waiting, returns immediately), 1 RISE, 2 FALL, 3 HIGH, 4 LOW.
  • The current value of the input is stored in parameter #5399 in mode 0; on timeout #5399 holds -1.
  • Mode 0 is the only wait mode permitted for an analog input.
  • Programming M66 with both a P- word and an E- word (selecting both a digital and an analog input) is an error.
  • The number of I/O can be increased with the num_dio or num_aio parameter when loading the motion controller.
  • Example given: M66 P0 L3 Q5 waits up to 5 seconds for digital input 0 to turn on.
  • M66 stops further execution of the program until the selected event or the programmed timeout occurs.

Safety

  • In LinuxCNC these inputs are not monitored in real time and thus should not be used for timing-critical applications.
  • M66 will not function unless the appropriate motion.digital-in-nn pins or motion.analog-in-nn pins are connected in the HAL file to an input.
↑↓ navigate↵ openesc close