Quick Guide to the O CNC Code [Program Number]

a graphic of a cnc machine with text that says learn g code today o program number

The O code is used to list the program number. This is found in the first line of a CNC program.

O1234 signifies that this is program 1234.

Most controllers allow the use of program numbers O0001 to O9999.

Some newer machines may allow a larger range of program numbers, but they would rarely if ever be needed.

Want to learn more about CNC G Code?

Where will you find the O code in a CNC program?

The O code is found at the beginning of the CNC program to identify the program number.

P vs O when using subprograms

When calling a subprogram using the M98 code, the P code is used to choose the subprogram to be run.

For example, M98 P1234 will tell the CNC to run subprogram O1234.

Take note however that there are two ways to call a subprogram.

M98 calls a separate program and the M97 code calls a subprogram by line number in the current program.

For example, M97 P1234 will tell the machine to jump to line number 1234 in the current program. 

Want to learn more about CNC G Code?

Leave a Comment