FANUC M98 / M99 Subprogram Calls: P Numbers, Nesting Limits and How to Troubleshoot Alarms 076 / 077 / 078

M98/M99 is the most basic program-reuse mechanism on a FANUC control, yet when an alarm fires many people only memorise "076 means missing P, 078 means number not found" and cannot explain P-number rules, real nesting depth, or the difference between M99 inside a subprogram and in the main program. This guide covers the call rules, P formats, nesting limits and the troubleshooting path for the three P/S alarms. The 077 nesting limit is reported as 3, 5 or 8 levels by different sources – they conflict, so check your own machine manual; this article gives no single number.

Sister article: FANUC M98 / M99 subprogram calls and 076/077/078 troubleshooting – the Chinese guide; related: Fanuc Macro B guide, Fanuc PMC functional instruction (SUB) quick reference, Fanuc tool setter / probe calibration. The Chinese guide on this site also covers the O9001 tool-change macro and the Macro B tutorial.

18.1 M98 / M99 in one sentence

M98 M99 division of labour
  • M98 Pxxxx: the main program calls a subprogram. P carries the called program (or sequence) number.
  • M99: at the end of a subprogram it returns to the block after the call; written alone in the main program it loops back to the start.
广告

Table 1. M98 / M99 roles (behaviour follows your manual)

18.2 P-number formats: four common forms

Four P-number forms
FormMeaningTypical use
M98 P1000Call subprogram O1000 onceMost common
M98 P1000 L5Call O1000 five timesRepeating a fixed action
M98 P51000On some systems, leading digits are the repeat count and the last four are the program numberLegacy format, ⚠️ varies by system
M98 P1000 with M99 P100Return to sequence N100 in the main programConditional jump return

Table 2. P formats (⚠️ combined forms vary by generation; check your manual)

P-number discipline: P must point to a program or sequence number that actually exists; O numbers are normally in the 1-9999 range; a missing target raises 078. Re-check every P reference after editing a program.

18.3 Two separate layers: NC M98/M99 versus PMC SUB

One layer is the NC program M98/M99 subprogram call (this guide); the other is the PMC ladder SUB function instruction (subprogram call / jump). They only share a name – address systems, call methods and troubleshooting entry points are completely different. For the PMC side see the functional instruction SUB reference and the ladder diagram beginner tutorial.

18.4 Nesting limit: ⚠️ three sources, three numbers

Nesting limit conflict
  • One P/S alarm table: 077 = subprogram nesting exceeds three levels;
  • Another English source: reports 3 or 5 levels and explicitly says “the source gives two limits without stating which controller they apply to – verify on your control”;
  • A further source says usually 8 levels.

Conclusion: the nesting limit varies by machine and options, so this article gives no single value. When 077 appears, check the “subprogram nesting” entry in your own manual. Common root causes are subprograms calling each other in a loop, or using M98 recursion to implement a loop.

Table 3. Three reported nesting limits (follow your manual)

18.5 Troubleshooting path for the three P/S alarms

076 077 078 troubleshooting
AlarmOfficial meaningFirst check
076ADDRESS P NOT DEFINED – P address invalid or missing in an M98 / G65 / G66 blockP omitted, written P0, or not on the same line as the G code
077SUB PROGRAM NESTING ERROR – nesting limit exceededSubprograms calling in a loop; limit per your manual
078NUMBER NOT FOUND – program or sequence specified with M98/M99/G65/G66/GOTO not foundDoes the O/N number behind P exist? Was the program edited?

Table 4. Alarm reverse lookup (verify exact wording in your manual)

Order of investigation: program text first (P number, same line, target exists) -> nesting structure (draw the call tree) -> only then suspect the control. 076 and 078 are almost always program-writing issues, not parameter issues.

18.6 Three uses of M99 and their traps

  1. M99 at the end of a subprogram -> return to the block after the call;
  2. M99 P100 inside a subprogram -> return to sequence N100 in the main program (the sequence must exist or 078);
  3. M99 at the end of the main program -> loop to the beginning (used for continuous production – make sure an exit condition exists).
广告

Traps: forgetting M99 at the end of a subprogram makes execution fall through into the next block; an M99 P number pointing to a nonexistent sequence raises 078.

18.7 Where M98/M99 ends and G65/G66 begins

M98 calls a plain subprogram (Oxxxx); G65/G66 call a macro program and can pass arguments (A, B, C…). Alarms 076/078 apply to both. Macro variable partitions and G65/G66/G67 usage are covered in the Macro B guide.

18.8 M98/M99 in the tool-changer macro O9001

Builder tool-change macros often use M98 to call a change subprogram and M99 to return, with parameters 6071/6080 and PMC signals (G54.x). In these programs P numbers are tightly bound to signal timing – back up the original program before editing. The Chinese guide on this site covers the O9001 tool-change macro in detail.

18.9 Commissioning and verification

  • Single-block through the call chain and watch M98 -> subprogram -> M99;
  • Draw a call tree (main -> sub 1 -> sub 2…) and check its depth;
  • Re-verify every P reference after program edits;
  • Validate the path in dry run / graphic simulation before cutting.

18.10 Related but separate: PMC SUB instructions

Once more: the SUB function instructions in PMC ladder (e.g. SUB1 subprogram call, SUB2 return) are a different system, and the troubleshooting entry point is online ladder monitoring, not the NC program. See the PMC SUB quick reference.

Frequently Asked Questions

How do I write the P number for a FANUC M98 subprogram call, and what does M98 P1000 L5 mean?

P carries the called program number: P1000 calls O1000 once; L5 repeats the call five times. Some older controls use a combined form where leading digits are the count and the last four are the program number (e.g. P51000), but that varies by generation – check your manual. P must point to an existing program or 078 is raised.

What is the FANUC 077 subprogram nesting limit?

Sources disagree: three levels, 3 or 5 levels, and usually 8 levels all appear. The limit depends on the control model and options, so use the “subprogram nesting” entry in your own manual. When 077 fires, draw the call tree first and look for subprograms calling each other in a loop instead of rewriting blindly.

What is the difference between alarm 076 and 078? Should I check the program or parameters?

076 means the P address in an M98/G65/G66 block is invalid or missing (omitted, P0, not on the same line as G). 078 means the program or sequence number behind P cannot be found. Both are nearly always program-writing problems – check the program text and whether the P target exists, then draw the nesting tree, and only then suspect the control. Parameters normally need no change.

Last updated: 2026-11-19

Where to go next

Read the guide, get the right instrument, or walk the diagnosis through with someone — pick whichever you need.

Also available in Chinese: FANUC M98 / M99 子程序怎么调用?P 号规则、嵌套上限与 076 / 077 / 078 三个报警怎么查
The original Chinese version — same procedure, with the full field notes.
© 版权声明
THE END
喜欢就支持一下吧
点赞14赞赏 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容

CNC电气调试问题解答 | 数控机床电气工程师资料共享屋
CNC电气调试问题解答 | 数控机床电气工程师资料共享屋
CNC电气调试问题解答 | 数控机床电气工程师资料共享屋
CNC电气调试问题解答 | 数控机床电气工程师资料共享屋
CNC电气调试问题解答 | 数控机床电气工程师资料共享屋
CNC电气调试问题解答 | 数控机床电气工程师资料共享屋
图片-CNCShare | 数控电气技术中心
图片-CNCShare | 数控电气技术中心
图片-CNCShare | 数控电气技术中心
图片-CNCShare | 数控电气技术中心
图片-CNCShare | 数控电气技术中心
图片-CNCShare | 数控电气技术中心
SINUMERIK Servo Alarms 25000, 25010 and 25201: Which Layer to Troubleshoot First-CNCShare | 数控电气技术中心
828D / 840D sl 伺服报警 25000 / 25010 / 25201 怎么分层?先看 NC 报警还是 F 码-CNCShare | 数控电气技术中心
Mitsubishi MT Works2 / MR Configurator2: Official Download Path, Modules and Servo Parameters-CNCShare | 数控电气技术中心
三菱 MT Works2 / MR Configurator2 哪里下载?伺服调参上位机三大模块、怎么连 MR-J4/J5、能改哪些参数与三大下载坑-CNCShare | 数控电气技术中心
SINUMERIK 828D Tool Management NC-PLC Interface Explained: DB4300, Three Tables and the Drum-Magazine Wrong-Tool Case-CNCShare | 数控电气技术中心
SINUMERIK 828D 刀具管理 NC-PLC 接口详解:DB4300 任务/应答 + 三张表 + 换刀步骤与圆盘刀库取错刀号复盘-CNCShare | 数控电气技术中心
SINUMERIK 828D / 840D sl Tool Management DB Quick Reference: DB4300 Bits, DB9900/9901/9902 Tables and Transfer/Ack Steps-CNCShare | 数控电气技术中心
SINUMERIK 828D / 840D sl 刀具管理 DB 接口速查表:DB4300 位域 × DB9900/9901/9902 三表 × 传输/应答步骤号-CNCShare | 数控电气技术中心
FANUC M98 / M99 Subprogram Calls: P Numbers, Nesting Limits and How to Troubleshoot Alarms 076 / 077 / 078-CNCShare | 数控电气技术中心
FANUC M98 / M99 子程序怎么调用?P 号规则、嵌套上限与 076 / 077 / 078 三个报警怎么查-CNCShare | 数控电气技术中心
Inductive Proximity Switches for CNC Machines: NPN vs PNP vs NAMUR and Their Roles as Hard Limits, Reference Switches and Tool Presence Sensors-CNCShare | 数控电气技术中心
接近开关 NPN / PNP / NAMUR 到底怎么选怎么接?机床三大角色(硬限位 / 原点 / 刀位检测)的不同选法 + 常闭优先的失效安全 + 误动作四查-CNCShare | 数控电气技术中心
文章精选
专心做好一件事
打造更优雅的WordPress主题-CNCShare | 数控电气技术中心
专心做好一件事
打造更优雅的WordPress主题