Welcome to the exciting world of CNC programming!
If you’re curious about the O CNC code and want to learn how to use it, you’ve come to the right place.
In this easy-to-follow guide, we’ll teach you everything you need to know. Don’t worry if you’re new to this, because the O code is super easy to learn.
So, let’s jump in to discover the O CNC code together!
What does the O code do?
The O code lists the CNC program number.
It is found on the first line of a CNC program.
Example program numbers
Important: The O code identifies the program number
What range of numbers can you use with the O code?
Most controllers allow the use of program numbers O0001 through O9999.
Some newer machines allow a larger range of program numbers, but they would rarely be used or needed.
O code program example
|(Program number: O0001)
|(Absolute positioning mode, cancel canned cycles)
|G54 G0 X0 Y0
|(Select coordinate system G54, rapid move to X0 Y0)
|(Start spindle clockwise at 1000 RPM)
|G43 H1 Z0.1
|(Tool length compensation active, move Z to 0.1)
|G1 Z-0.5 F100
|(Linear move to Z-0.5 at a feed rate of 100)
|(Linear move to X1 Y1)
|(Linear move back to X0 Y0)
|(Rapid move to Z1, retracting the tool)
|(End of program and rewind)
Learn CNC Programming – It’s Easier Than You Think!
Learning G Code doesn’t have to be difficult…
If you know what to focus on.
Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.
Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!Make Learning G Code Easy
Using the O code when running subprograms with M97 and M98
Subprograms are reusable pieces of code that are often used for repetitive tasks such as drilling holes or changing a tool.
There are two codes used to call subprograms; M97 & M98.
For example, M98 P5678 will tell the CNC to run subprogram O5678.
M98 calls a separate program.
The M97 code calls a subprogram by line number in the current program.
Important: M97 and M98 call subprograms differently. M97 jumps to another line in the current program. M98 moves to a completely separate program.
An example of this is M97 P500 will tell the machine to jump to line number 500 in the current program. The N code notes the line number.