Haas Stop Execution with M109 G-Code

Haas M109 G-Code: How to stop execution on the Haas control and ask the operator to answer a simple question before continuing to run the remainder of the program.

Haas M109 G-Code on Haas Controller

In the world of Computer Numerical Control (CNC) milling and turning, machinists use programming codes such as G- and M-codes to tell the machine what to do to ensure that exact shapes and dimensions will be manufactured to their specifications. These codes instruct the machine to perform all kinds of functions during the manufacture of a part. The G-code, otherwise known as the Geometric code, instructs the movement of the machine – where to move, what path to take and how fast to move. The M-code, aka the Miscellaneous code, controls the machine’s actions such as start and stop. These two codes work in tandem in the production of parts. So basically,  G-codes describe the machine’s positions, and M-codes control the machine’s actions. 

As you’ve experienced, there seems to be an infinity of G-codes available. Of course, some are more useful than others, and that includes the Haas M109 G-Code. While G- and M-codes are used on all CNC controlled machines, these codes can vary from machine to machine.  So the Haas M109 G-Code, may have a different meaning on a different machine.

Haas M109 G-Code Controller Closeup The following commands would be applied where parametric or macro programs are used for a family of parts, and/or if you want/need operator input anywhere throughout the NC program. Before you begin, the Macro option needs to be active to use Haas M109 G-Code.

M109 is 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 Haas M109 G-Code 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)
N20 (An N was entered)
G04 P1. (Do nothing for 1 second)
N30 (Stop)

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)
N20 (A 2 was entered)
G04 P5. (Do nothing for 5 seconds)
N30 (A 3 was entered)

Haas Programmer at Controller

For a list of Haas programming codes, choose your type of machine below.

For more information on this feature, please us at bfreitag@productivity.com or at 763.742.1225.

Originally published 05/26/2015 | Updated 05/23/2022


Online Ordering