This page is for examples of using M words.
1. M66 Digital Input Control
- M66 is described [here]
- What M66 does is allow you to pause your g code and wait for a digital or analog input. This is useful for plasma tables to wait for the arc stable signal for example. The docs are kinda sparse and if you don't all ready know you might have a hard time figuring it out.
- E words are for analog input signals:
- E0 is for pin motion.analog-in-00
- E1 is for pin motion.analog-in-01
- E2 is for pin motion.analog-in-02
- E3 is for pin motion.analog-in-03
- P words are digital input signals:
- P0 is for pin motion.digital-in-00
- P1 is for pin motion.digital-in-01
- P2 is for pin motion.digital-in-02
- P3 is for pin motion.digital-in-03
- L words are for the type of wait:
- L0 WAIT_MODE_IMMEDIATE - no waiting, returns immediately. The current value of the input is stored in parameter #5399
- L1 WAIT_MODE_RISE - waits for the selected input to perform a rise event.
- L2 WAIT_MODE_FALL - waits for the selected input to perform a fall event.
- L3 WAIT_MODE_HIGH - waits for the selected input to go to the HIGH state.
- L4 WAIT_MODE_LOW - waits for the selected input to go to the LOW state.
- Q word specifies the timeout for the waiting.
- Qnn where nn is seconds Q5 is five seconds wait.
- If the timeout is exceeded, the wait is interrupt, and the variable #5399 will be holding the value -1.
- When this happens the g code will continue to run at the next line unless you take precautions to prevent that.
- How the heck do you use it?
- First pick an input (we will use the parport) and in your standard_pinout.hal file (or other .hal as needed) add:
- net my-motion-input motion.digital-in-00 <= parport.0.pin-10-in
- This line links the parport input 10 to the motion digital in 00 pin.
- Next in your G code put a M66 P0 L3 Q10 and it will wait at this line for 10 seconds for input 10 on the parport to go high.
- If you don't use the Oword if block to take an action on success or failure the next line of code will be executed.
- Example Code
(your code here)
M66 P0 L3 Q10
o100 if [#5399 EQ -1]
(MSG, Arc Timeout)
G0 Z0.5
X0 Y0
M2 (stop processing here)
o100
(processing continues here if variable 5399 is not equal to minus 1)
right, you need another M65 to write the command
M66 is only for reading
M66 will get the current value
it works like this: interp starts reading a new program, and sending commands to task
which starts executing them (actually sending them to motion and io)
after a while interp will be quite far ahead than the current execution..
when interp finds an M66 it stops interpreting the program, and waits for the execution to reach M66
once it reached, the M66 command is sent to task, which sends it to motion, etc
and you'll get the "current" value of the HAL pin