Q: Did you know that the Haas control can stop execution and ask the operator to answer a simple question before continuing to run the remainder of the program?
M109 Interactive User Input
This M code allows a G-code program to place a short prompt on the screen, get a single-character input from the user and store it in a macro variable. The first 15 characters from the comment following the M109 will be displayed as a prompt in the lower left corner of the screen. A macro variable in the range 500 through 599 must be specified by a P code. Note also that due to the look-ahead feature, it is necessary to include a loop in the program following the M109 to check for a non-zero response before continuing. The program can check for any character that can be entered from the keyboard by comparing with the decimal equivalent of the ASCII character. Here are a few common characters:
Example 1: If you want the machine to stop for one minute.
The following sample program will ask the user a Yes or No question, then wait for either a Y or N to be entered. All other characters will be ignored.
N1 #501= 0. (Clear the variable)
M109 P501 (Sleep 1 min?)
N5 IF [ #501 EQ 0. ] GOTO5 (Wait for a key)
IF [ #501 EQ 89. ] GOTO10 (Y)
IF [ #501 EQ 78. ] GOTO20 (N)
GOTO1 (Keep checking)
N10 (A Y was entered)
M95 (00:01)
GOTO30
N20 (An N was entered)
G04 P1. (Do nothing for 1 second)
N30 (Stop)
M30
Example 2: If you want the machine to stop intermittently.
The following sample program will ask the user to select a number, and then wait for a 1, 2 or a 3 to be entered. All other characters will be ignored.
O00234 (Sample program)
N1 #501= 0. (Clear the variable)
M109 P501 (Pick 1, 2 or 3:)
N5 IF [ #501 EQ 0. ] GOTO5 (Wait for a key)
IF [ #501 EQ 49. ] GOTO10 (1)
IF [ #501 EQ 50. ] GOTO20 (2)
IF [ #501 EQ 51. ] GOTO30 (3)
GOTO1 (Keep checking)
N10 (A 1 was entered)
M95 (00:01)
GOTO30
N20 (A 2 was entered)
G04 P5. (Do nothing for 5 seconds)
N30 (A 3 was entered)
M30
To download a PDF of this tip, click here.
For more information on this feature, please us at bfreitag@productivity.com or at 763.742.1225.