A quick explanation of how to use M98 and G65 codes to call CNC subprograms within a G-code program.
When programming in G-code, it is not uncommon to reuse the same blocks of code across multiple programs. These snippets of code, the subprograms, are often stored in the machine tool memory, allowing CNC programmers to quickly "call" them when they need to run that specific task within the main program.
There are two ways to call subprograms within a CNC program: M98 and G65.
The M-code M98 is used to call a subprogram followed by the program number and the number of times that we wish to repeat running that subprogram.
A typical M98 block may look like this :
M98 P0002 L5;
M98 calls the subprogram and the P-value will call the program number O0002 stored in the memory of the machine. The L-value will then tell the machine how many times to run the subprogram before going back to the main program.
At the end of the subprogram, the M-Code M99 is used to return to the previous program.
The G-code G65 is typically used to call and pass information in variables down to a subprogram.
A typical G65 block may look like this :
G65 P8001 A100.0 B0,5;
In this case, G65 calls the subprogram, and P8001 indicates the program number. Each of the following letters corresponds to a variable number, so in this case, A100 will pass the value 100 into variable 1 and B0.5 will pass the value 0.5 into variable 2 within the subprograms.
To learn more about subprograms, visit Gcodetutor.com (https://rb.gy/7yzqfn).
Stay tuned for more machining videos!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Recommended CNC programming books:
Fanuc CNC Custom Macros - https://amzn.to/370yX0P
CNC Programming Handbook - https://amzn.to/2MPxT9g
CNC Programming Techniques - https://amzn.to/3aTS4el
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Practical Machinist is the largest and most engaged metalworking community across the web. With more than 160,000 registered members and 300,000+ social media followers, Practical Machinist is the easiest way to learn new techniques, get answers quickly, and discuss common challenges with your peers. Visit Practical Machinist today to join the community and start connecting with your peers.
Become a Practical Machinist member (https://www.practicalmachinist.com/)
Like us on Facebook ( / practicalmachinist )
Follow us on Instagram ( / practicalmachinist )
Follow us on Twitter ( / prac_machinist )
Connect with us on LinkedIn ( / practical-machinist )
#subprograms #Gcode #CNCprogramming