M97: Local subprogram / part counter
You can call local subprogram or count pieces according to control/manufacturer.
For reference only: syntax changes with the control, the post-processor and the machine parameters. Check the official manual and run a simulation before cutting. Legal notice.
- Family
- Subprograms
- Machine
- Milling, Turning, Mill-turn
- Risk
- Medium
- Example
- M97 P100
M97 P100Parameters
- P
- Número de bloque N del subprograma local (Haas); en otros controles, contador o función según manual.
- L
- Repeticiones.
Machine: Milling, Turning, Mill-turnRisk: Medium
Haas
M97 P...- In Haas it usually calls a local subroutine by line number.
Fanuc
- On some lathes it may be assigned to a piece counter or another PLC function.
Other codes in Subprograms
See the full list of G and M codesFrequently Asked Questions (FAQ)
What does M97 mean in a CNC program?
You can call local subprogram or count pieces according to control/manufacturer. In the catalogue it appears as "Local subprogram / part counter", within the Subprograms family.
How is M97 written on each control?
Haas: M97 P.... The exact syntax depends on the control version and the machine parameters: always confirm with the manufacturer's manual.
Can you give me an example of M97?
M97 P100 — You can call local subprogram or count pieces according to control/manufacturer.
Which machines use M97?
M97 is used in: Milling, Turning, Mill-turn.
What should you watch out for with M97?
Medium risk: it rarely breaks anything on its own, but a wrong value shows up on the part. Check the block before running the batch.
Related tools
CNC G-code Simulator
CNC IDE: editing with G/M tooltips, line inspector, conversion between controls and 2D/3D toolpath.
CNC Alarms Guide
CNC Alarms and Solutions Guide. Enter the error code or symptom to find the cause and how to repair it at the machine.
Calculate cycle time
Estimate CNC turning and milling cycle time from G-code. Calculate parts per hour with a breakdown of cutting, rapids, canned cycles and tool changes.