FANUC codes
FANUCProgram/G-codeIntermediate15-30 minutes

037

Fanuc Alarm 037 - Too Many Subprogram Calls

Subprogram Nesting Error

Fanuc program alarm 037: Subprogram Nesting Error. The part program contains an error or illegal condition that the Fanuc control cannot execute. Correct the program to clear this alarm.

Root Cause Summary

Fanuc Alarm 037 occurs when the CNC detects excessive subprogram nesting depth, typically exceeding 4 levels on older controls (0i/16i/18i) or 5-8 levels on newer systems (30i/31i/32i). This is caused by M98/M99 subprogram calls that recurse too deeply, creating a stack overflow condition in the program execution buffer. The alarm protects the control from memory corruption during program execution.

Safety

  • Program structure too complex

Causes and Fixes

  1. 1

    Press RESET to clear the alarm. Access the program via EDIT mode and identify all M98 subprogram calls in the currently executing program and trace the call chain depth.

  2. 2

    Check parameter 3107#0 (maximum subprogram nesting) on 30i/31i/32i series to verify the configured nesting limit. On 0i/16i/18i series, the limit is typically hardcoded to 4 levels and cannot be changed.

  3. 3

    Review the subprogram structure and reduce nesting levels by consolidating subprograms or restructuring the program logic to use fewer nested M98 calls. Map out O-numbers being called: Main > O1001 > O1002 > O1003 > O1004 etc.

  4. 4

    Verify all M99 subprogram return commands are properly paired with M98 calls and are not missing, which can cause incorrect nesting level tracking by the control.

    Missing M99 commands will cause the control to lose track of nesting depth and may trigger alarm 037 prematurely.

DIY Feasiblehigh confidence

Call a technician if:

  • ·Parameter modifications required beyond standard programming
  • ·Persistent alarms after program corrections
  • ·Custom macro interference with compensation

Prevention

  • Always cancel compensation (G40) before changing planes
  • Establish plane selection early in program setup blocks
  • Use consistent plane selection throughout related subprograms
  • Document compensation handoff procedures in program headers

Common Mistakes

  • Assuming compensation automatically adapts to plane changes
  • Forgetting G40 before subprogram calls
  • Mixing 2D and 3D compensation strategies
  • Not verifying parameter 5004 settings on turning centers

Related Alarms

Seeing Multiple Alarms?

Seeing another alarm with this one? Enter the code.

Get machine-aware diagnosis

AxisMD logs alarms against your actual machines, tracks patterns, and gives AI context your manual doesn't have.

Start free

Was this guide helpful?

Always verify with your machine manual or a certified technician before performing service procedures.