Siemens SIMATIC S7-1500 fault OB121: Programming error
The operating system calls OB121 when a programming error occurs while an instruction of the user program executes, provided the block does not use local error handling (GET_ERROR or GET_ERR_ID). If neither OB121 nor local error handling catches the error, the S7-1500 changes from RUN to STOP and writes an entry in the diagnostics buffer. Fault_ID identifies the error, e.g. 16#3A access to a DB that is not loaded, 16#22/16#23 area length errors, 16#75 maximum block nesting depth exceeded.
Diagnose this with AI
Try Free PLC Fault Diagnostic Upload a keypad photo, the fault history or a parameter export from your Siemens SIMATIC S7-1500. InduQT compares the evidence and suggests the next useful checks.
When it happens
- RUN, when the faulty instruction executes
- Often after a download, or when an index or pointer takes a new value
Likely causes and checks
1Access to a DB, FC or FB that is not loaded or does not exist
- Points to it
- Fault_ID 16#3A, 16#3B, 16#3C or 16#3E; follows a partial download or a deleted block.
- Check
- Compare blocks in the CPU with the project (online/offline comparison) and download the missing block.
2Area or length error from an indirect address or array access
- Points to it
- Fault_ID 16#22–16#25; the diagnostics buffer names the block and the access.
- Check
- Read the index or pointer value at the error and compare it with the area it addresses.
3Block call nesting or local data exceeded
- Points to it
- Fault_ID 16#00/16#75 (nesting depth) or 16#76 (local data).
- Check
- Review call depth and recursion in the block named in BlockNr.
Telling it apart
- On the S7-1500 a programming error without OB121 or local error handling stops the CPU; an I/O access error (OB122) does not.
- If the block uses GET_ERROR or GET_ERR_ID, OB121 is not called for errors in that block; the block’s own error handling decides what happens.
- Siemens notes the S7-1200 handles programming and access errors internally and stays in RUN with a diagnostics buffer entry, so the same program can stop an S7-1500 but not an S7-1200.
Evidence to collect
- Diagnostics buffer export showing the STOP cause and the block
- OB121 start information (BlockNr, BlockType, Fault_ID, Area), if logged
- Online/offline comparison of the blocks
- TIA Portal project archive
Work on fuel trains, burners, pressure vessels and electrical equipment must be done by qualified personnel following the manufacturer’s documentation and local codes. Never bypass a safety device or interlock.