Inst ToolsInst ToolsInst Tools
  • Ask
  • Courses
  • Videos
  • Q & A
    • Interview
      • Instrumentation
      • Electronics
      • Electrical
      • Practical Questions
    • MCQ
      • Instrumentation MCQ
      • Electrical MCQ
      • Electronics MCQ
      • Control Systems MCQ
      • Analog Electronics MCQ
      • Digital Electronics MCQ
      • Power Electronics MCQ
      • Microprocessor MCQ
      • Multiple Choice Questions
  • EE
    • Electronics
      • Electronics Q & A
      • Electronic Basics
      • Electronic Devices & Circuits
      • Electronics Animation
      • Digital Electronics
    • Electrical
      • Electrical Basics
      • Electrical Q & A
      • Power Electronics
      • Electrical Machines
      • Electrical Animation
      • Power Systems
      • Switchgear & Protection
      • Transmission & Distribution
  • Measure
    • Control Valves
    • Calibration
    • Temperature
    • Pressure
    • Flow
    • Level
    • Analyzers
    • Switches
    • Vibration
    • Solenoid Valve
  • Control
    • PLC Tutorials
    • Control Systems
    • Safety Instrumented System (SIS)
    • Communication
    • Fire & Gas System
  • More
    • Design
    • Tools
    • Animation
    • Basics
    • Formulas
    • Standards
    • TextBooks
    • Common
    • Software
    • Excel Tools
    • Erection & Commissioning
    • Process Fundamentals
    • Videos
    • Books
Search
All rights reserved. Reproduction in whole or in part without written permission is prohibited.
Reading: Tia Portal – OB121 Programming Errors Interrupt Organization Block
Share
Notification Show More
Font ResizerAa
Inst ToolsInst Tools
Font ResizerAa
  • Courses
  • PLC Tutorials
  • Control Systems
Search
  • Ask
  • Courses
  • Videos
  • Q & A
    • Interview
    • MCQ
  • EE
    • Electronics
    • Electrical
  • Measure
    • Control Valves
    • Calibration
    • Temperature
    • Pressure
    • Flow
    • Level
    • Analyzers
    • Switches
    • Vibration
    • Solenoid Valve
  • Control
    • PLC Tutorials
    • Control Systems
    • Safety Instrumented System (SIS)
    • Communication
    • Fire & Gas System
  • More
    • Design
    • Tools
    • Animation
    • Basics
    • Formulas
    • Standards
    • TextBooks
    • Common
    • Software
    • Excel Tools
    • Erection & Commissioning
    • Process Fundamentals
    • Videos
    • Books
Follow US
All rights reserved. Reproduction in whole or in part without written permission is prohibited.
Inst Tools > Blog > PLC Tutorials > Tia Portal – OB121 Programming Errors Interrupt Organization Block

Tia Portal – OB121 Programming Errors Interrupt Organization Block

OB121 is an organization block that will get called by the PLC's operating system if a programming error occurs while running your logic.

Last updated: March 29, 2023 2:10 pm
Mahmoud Salama
PLC Tutorials
No Comments
Share
11 Min Read
SHARE

In this article, we continue our discussion about different types of organization blocks in Siemens PLC. This time we will take about the OB121 or the programming errors interrupt in the Tia portal.

Contents
What are Programming Errors Interrupt (OB121)?Examples of Programming ErrorsWhat will happen if a Programming Error is Detected? Simulating a programming error in TIA PortalHow can the OB121 be useful against Programming Errors?Determine the Error TypeCatching the ErrorConclusion

Contents:

  • What are programming errors interrupt OB121?
  • Examples of programming errors.
  • What will happen if a programming error is detected?
  • Simulating a programming error in TIA Portal.
  • How can the OB121 be useful against programming errors?
  • Conclusions.

What are Programming Errors Interrupt (OB121)?

OB121 is an organization block that will get called by the PLC’s operating system if a programming error occurs while running your logic. Note that we are not talking about a programming error that will be caught by the compiler when trying to download your logic into your PLC. See picture 1.

OB121 Programming Errors Interrupt Organization Block
Picture 1 – Some programming errors will get caught by the compiler

As you see from the last picture, there is a programming error in my PLC logic; some operands are missing in the input and output of Network 1. But, this error was caught by the compiler before even downloading the logic into the PLC. The error in picture 1 is not the programming error type that can trigger the need to call OB121.

Errors in your PLC program that can’t be found by the compiler, but still can cause troubles in your logic while PLC is running are the programming errors we mean. These errors will trigger a call to the OB121 by the operating system.

Examples of Programming Errors

Here are some examples of mistakes in your PLC logic that can cause programming errors:

  • Maximum nesting depth of block calls exceeded.
  • You have used a NULL pointer to address an operand.
  • Unknown instruction.
  • The addressed string has incorrect length information.
  • Area length error when reading.
  • Area length error when writing.
  • Error in timer no.
  • Access to a DB that is not loaded; the DB number is located in the permitted area.
  • DB does not exist.

These errors and many more can cause programming errors in your PLC. You can check the Help section of the TIA Portal to find out what other reasons can cause PLC programming errors.

What will happen if a Programming Error is Detected?

When your PLC detects a programming error, one of three events can occur.

  1. Your PLC will show an error and go to STOP mode.
  2. Your PLC will show an error but keep running your logic.
  3. Your PLC will show an error then try to solve this error.

These three events will depend basically on your PLC programming. Meaning your code will decide how the operating system will behave when detecting a programming error.

 Simulating a programming error in TIA Portal

To better understand how the PLC will behave, we will create a simple program where we cause a programming error, and then we will see what will happen. See picture 2.

OB121
Picture 2 – Simple program logic

The logic we created is very simple, when the InitiateProgError has been enabled the value of 126 will be moved into DB52.DBW16 area. Note that we haven’t created DB52. so, that will be our programming error. Note that this error will not be caught during compiling or downloading into the PLC. See pictures 3 and 4.

PLC Error not caught by the compiler
Picture 3 – Error not caught by the compiler

See how the block was successfully compiled, while including a programming error.

Block downloaded into PLC
Picture 4 – Block downloaded into PLC

Again, the block was downloaded into PLC with a programming error.

Now, let’s simulate our PLC program and see what will happen. See animation 1 for the simulation of the PLC code.

PLC Programming Error OB121
Animation 1

As you see from the above animation, the PLC ERROR LED will flash red for a few seconds then the PLC will go into STOP mode.

Go to PLC online diagnostics to see what happened. See picture 5.

Online and diagnostics of the PLC
Picture 5 – Online and diagnostics of the PLC

What you saw in the animation is exactly what you see in the previous picture. They can be mentioned into 3 steps:

  1. The PLC detects the programming error which is OB52 not loaded.
  2. The operating system will trigger the call for the OB121, but there is no OB121 created in our logic.
  3. When the PLC finds out that there is no OB121 created in our logic, the operating system will initiate a request STOP. And the PLC will go into STOP mode.

How can the OB121 be useful against Programming Errors?

Let’s add an OB121 to our PLC code and see how things will change. See picture 6.

TIA Portal OB121
Picture 6 – Adding an OB121

After creating and adding the OB121 into our PLC logic, let’s see what will happen in the simulation.

Keep in mind that we haven’t written any PLC logic inside the OB121. See animation 2.

Programming Error Handling in Siemens PLC
Animation 2

As you see from animation 2, when InitiateProgError is triggered, the PLC ERROR led will flash red but the PLC will keep running.

Meaning that the PLC will not go into STOP mode. Let’s check the online diagnostics to see what actually happened. See picture 7.

Siemens PLC Organization Blocks used For Troubleshooting
Picture 7 – Error didn’t cause PLC stop

You see from the picture that the PLC detects the error but doesn’t go into STOP mode. It will skip this error, continue the cycle and start all over again from the beginning.

When it arrives at the error again, it will detect the error again, giving an alarm in the diagnostics. Skip the error and continue. That means the PLC will give the same alarm every scan cycle. And that is why in the picture you see the event keeps triggered and the alarm is repeating each scan cycle.

So, just having an empty OB121 will give you the benefit of keeping the PLC running and y extension, keeping your process running.

But, there is more we can do, we can try to catch this error and eliminate it. Also, we can try to show the type of programming error detected.

Determine the Error Type

The OB121 has an internal fault ID identifier that we can use to show the type of fault, maybe as an alarm on an HMI. Inside the OB121 we will create a simple MOVE instruction, where we will push the Fault_ID input of the OB121 to a defined memory area inside our global DB. See picture 8.

Identifying the error type in PLC
Picture 8 – Identifying the error type

As you see from the previous picture, when the programming error occurs, the Fault_ID will be pushed into the Data.ProgErrorID. See picture 9.

Siemens PLC Programming Error Fault
Picture 9 – Programming Error Fault_ID

You can see the fault ID is 3A. if you check the TIA Portal help you can find the meaning of this fault. 

3A: Access to a DB that is not loaded; the DB number is located in the permitted area.

Catching the Error

This simply means, trying to solve the PLC programming error after you have identified the reason. This will depend mainly on what is the error and how you want to handle it. We will just simulate a solution to the error, to see how the PLC will behave.

The actual solution for the error we created will be to just create the DB52 or use a data block that is already created.

But for the sake of simulation, we will just add a simple contact that will open when the programming error occurs to catch this error. See pictures 10 and 11.

Catching the Siemens PLC error
Picture 10 – Catching the error

Whenever OB121 is called, the CatchError will be set.

Eliminate the PLC error
Picture 11 – Eliminate the error

Whenever OB121 is called, the CatchError will be set, and it will be used to catch the programming error in Network 1. See animation 3 for the PLC simulation.

Siemens PLC organization blocks fault
Animation 3

From the above animation, you can see that when the InitiateProgError is triggered, the PLC will go into error for a moment then the error will be cleared and the PLC is in RUN mode all the time.

Downloads:

  • OB121 Logic PDF Document
  • Programming Errors Interrupt Logic

Conclusion

Just having an empty OB121 in your logic will ensure that your PLC will not go into STOP mode if there was a programming error in your code. You can later use the OB121 to also identify the error and solve it.

If you liked this article, then please subscribe to our YouTube Channel for Instrumentation, Electrical, PLC, and SCADA video tutorials.

You can also follow us on Facebook and Twitter to receive daily updates.

Read Next:

  • Basic PLC Ladder Example
  • HMI and VFD Control System
  • PLC Cold and Hot Standby
  • Normally-Closed Stop Buttons
  • SCADA System Vulnerabilities
Don't Miss Our Updates
Be the first to get exclusive content straight to your email.
We promise not to spam you. You can unsubscribe at any time.
Invalid email address
You've successfully subscribed !
How to use PLC with SQL Database? – Basics & Tutorials
What is a Data Block? Global Data Blocks in PLC
PLC Program for Water Level Control Logic
PLC Program for Blinking Lamp on 5 Seconds Interval
Conveyor Sorting System with Color Detection PLC Logic
Share This Article
Facebook Whatsapp Whatsapp LinkedIn Copy Link
Share
Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Stay Connected

128.3kFollowersLike
69.1kFollowersFollow
208kSubscribersSubscribe
38kFollowersFollow

Categories

Recent Comments

  • Kamli on Top Free PLC Software
  • Guifty Shimica on Top Non-PLC Certification Courses for Automation Professionals
  • Guifty Shimica on Top Non-PLC Certification Courses for Automation Professionals
  • MIHARITSOA Aina Sitraka on Top Non-PLC Certification Courses for Automation Professionals

Related Articles

PLC railway crossing program

Automatic Railway Crossing Gate Control PLC Program

PLC Programming for Automated Curtain Control

Automatic Curtain Control – PLC Programming Solution

Latched and Momentary Operation of Motor PLC Program

Latched and Momentary Operation of Motor PLC Program

4 TO 20 MA ANALOG CURRENT SIGNALS

Basics of 4 to 20 mA analog Signals

Set the S5 timer value by a memory word

Set the S5 Timer Value by a Memory Word

Free Schneider PLC Training - Automation Course

Free Schneider PLC Training – Automation Course

Edge Detection in PLC

Edge Detection in PLC Programming

Perfume filling system PLC program

CX Programmer Example: Perfume Mixing and Filling System

More Articles

Power Triangle

Apparent Power, True Power, Reactive Power & Total Power

Applications of Robots

Applications of Robots in Various Fields

Testing of Pneumatic Systems

Panel and Field Pneumatic Controller’ Bumpless Transfer Issues

Ingress Protection Standard

Ingress Protection Rating

Telemetry Systems Objective Questions

Telemetry Systems Objective Questions

Free Online Control Valves Course

Free Control Valves Course

Valve Technician Interview Questions

Valve Technician Interview Questions

Find the Fault in the Temperature Loop

Fault in the Temperature Loop

Follow US
All rights reserved. Reproduction in whole or in part without written permission is prohibited.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?