
axismd.ai
FANUC Controller
Program/G-code · Intermediate · 10-30 minutes
Fanuc Alarm PS126 - Invalid DO Loop Number
PS126 alarm occurs when the CNC detects an invalid DO loop number reference or incorrect nesting structure in a macro program. This is typically caused by mismatched DO-END pairs, exceeding maximum nesting levels (typically 3 levels), or referencing undefined loop numbers in CONTINUE or BREAK statements.
Fanuc Alarm PS126 - Invalid DO Loop Number
ILLEGAL LOOP NUMBER
Fanuc alarm PS126: ILLEGAL LOOP NUMBER. The part program or machine configuration has an error related to this alarm condition. Review the block indicated in the alarm screen and correct the command per the Fanuc programming manual.
Root Cause Summary
PS126 alarm occurs when the CNC detects an invalid DO loop number reference or incorrect nesting structure in a macro program. This is typically caused by mismatched DO-END pairs, exceeding maximum nesting levels (typically 3 levels), or referencing undefined loop numbers in CONTINUE or BREAK statements.
Safety
Causes and Fixes
Press EDIT mode, navigate to the program causing the alarm and display the full macro program on screen. Use the search function to locate all DO statements and their corresponding END statements.
Verify each DO loop has exactly one matching END statement. Count nested levels - DO1/END1, DO2/END2, DO3/END3. Ensure DO numbers increment sequentially for nested loops and each END appears after its corresponding DO.
Check parameter 6010 (Macro Executor) is set correctly (typically bit 0=1 for macro enable). Navigate to SYSTEM > PARAM > search 6010 to verify macro functionality is enabled.
Correct the program structure by adding missing END statements or removing orphaned DO/END statements. Reset the alarm with RESET button and test the corrected program in single block mode.
Ensure machine is in a safe position before testing macro programs as syntax errors may cause unexpected motion.
Seeing Multiple Alarms?
Seeing another alarm with this one? Enter the code.
AxisMD logs alarms against your actual machines, tracks patterns, and gives AI context your manual doesn't have.
Start freeWas this guide helpful?
Always verify with your machine manual or a certified technician before performing service procedures.