Operator Checking Questions

Ever thought how useful it would be to have your machine ask the operator a question – maybe to ensure the part has been turned over, or which number is to be engraved or any number of other possibilities?

The Haas control has a function called Interactive User Input which incorporated into vers. 11.20 and released in 2002 provides the programmer with a new M code, M109 that 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:

  • A – 65 a – 97
  • B – 66 b – 98
  • C – 67 c – 99
  • N – 78 n – 110
  • Y – 89 y – 121
  • 0 – 48 + – 43
  • 1 – 49 – 45
  • 2 – 50 * 42
  • 3 – 51 / 47

The following sample program will ask the user a Yes/No question then wait for him to enter either a Y or an N. 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

The following sample program will ask the user to select a number then wait for him to enter a 1, 2 or a 3. 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