Tia Portal – OB30 Cyclic Interrupt Organization Block

In previous articles, we discussed different types of organization blocks, like the main OB1 which is the main cyclic program block, in this article we will take about another cyclic organization block. The OB30 or cyclic interrupt OB.


  • What is cyclic interrupt OB30?
  • What is the main OB1 cycle?
  • Why do I need OB30?
  • How to configure cyclic interrupts?
  • What if I have more than one cyclic Interrupt?
  • Conclusion.

What is Cyclic Interrupt OB30?

A cyclic interrupt OB30 is an organization block that gets called and executed at specified and exact time intervals, unlike the main cyclic OB1 which is continuously called and executed the cyclic interrupt will be called at time intervals which you should configure when creating a cyclic interrupt OB.

For example, if I created an OB30 with a time interval _also called cycle time_ of 20ms, that means the operating system will interrupt the main cycle OB1 and calls the OB30 each 20ms.

You have to make sure that the runtime of a cyclic interrupt OB must be smaller than its time interval. Otherwise, it could still happen that the next call of the OB30 will arrive while this call of the OB30 is still being executed. In this case, the operating system generates a time error that might lead to PLC going to STOP mode.

What is the Main Cycle OB1?

The main cyclic OB1 is the organization block which is responsible for cyclically executing your logic by the PLC. Whenever you create a new project and add a PLC, the Main OB1 will be automatically created by the software.

The essential basis of your PLC code is the cyclic behavior, meaning you need your code to be executed continuously. When the processing of your logic has been completed, the operating system starts processing it again. That is done through the use of the main OB1, you put and call all of your logic and code inside this OB1 and the operating system will make sure to continuously execute it.

Main OB1 cycle time refers to the runtime of the cyclic program, including the runtime of all nested program parts like FCs, FBs, and higher-priority OBs. If you have created several program cycle OBs, each program cycle OB contributes to the cycle time.

The operating system monitors whether the cycle time remains smaller than the configured maximum cycle time. If it exceeds the maximum cycle time, PLC will either go to STOP mode or call OB80 depending on your programming.

Why do I need OB30?

Someone could argue that I can put whatever functionality inside the OB30 in the main OB1 and try to get away with it depending on the very fast performance of most PLCs nowadays. This can be OK sometimes, but not every time.

Depending on the performance of your PLC, the main cycle time could be something between 1 to 150ms; it can be different but this is the standard configuration, this cycle time depends on so many factors, like the size of your PLC program, and interrupts inside your logic and other factors that will most likely make the run time of your cycle not stable.

Now, if you need to do certain functionality exactly each 10ms, not 9ms and not 11ms. Now you can’t depend on the main OB1, as the result might not be as desired. In this case, you use the cyclic interrupt OB30, you configure it to the 10ms you want and the operating system will make sure to call and execute this function every 10ms exactly. That is why it is called interrupt; because it will interrupt the execution of the main OB1 to call and execute your OB30.

Examples of Functionality that Needs OB30

  • PID controller processing.
  • Safety circuits monitoring.
  • Monitoring communication between machines.

All previous examples have the need to continuously monitor and check your parameters at certain times, as they relate to real physical quantities or to machine safety. The execution of such functions shouldn’t be delayed as they affect the safety and continuity of your process.

 How to Configure Cyclic Interrupts?

When you create a cyclic interrupt, there are some parameters you need to configure. See picture 1 for adding a new OB30.

Cyclic Interrupt Organization Block
Picture 1 – Add new cyclic interrupt OB30

When creating a cyclic interrupt, you can find many parameters you can set in the properties of the block see picture 2.

OB30 Cyclic interrupt
Picture 2 – Properties of OB30

The most important parameters that you need to consider are as follows:

  • Cycle time

Use the parameter “Cycle time” to set the period of time between two calls of the cyclic interrupt OB. It is an integer multiple of 1 µs.

  • Phase offset

Here, you set the time period by which the start times are shifted as compared to the multiple of the cycle time.

See picture 3 for cycle time and phase offset configuration.

Organization Block for Cyclic Program Processing
Picture 3 – Setting the cycle time and offset of OB30
  • Priority of the cyclic interrupt OB

This is another important parameter you have to consider when configuring a cyclic interrupt, as you might have more than one cyclic block, if in case two different OBs need to be called at the same time, the operating system will call and execute the block with a higher priority number.

You should know that the PLC main program cycle OB1 has priority number 1 which is the lowest priority level a block can have. That is why OB1 can be interrupted by any other block call. See picture 4.

PLC interrupt organization blocks
Picture 4 – Setting the priority of OB30

What if I have more than one Cyclic Interrupt?

It is not uncommon that you would have more than one cyclic interrupt in your logic. If you have two PID controllers in your PLC logic then you might need two cyclic interrupts to handle each PID. In that case, you need to make sure that the calling and execution of different cyclic interrupts will not be overlapped.

For example, if you have OB30 with an interval cycle time of 5ms and OB31 with a cycle interval of 10ms, that means the second call of the OB30 will also be the time for calling OB31. This might lead to logic errors, even if you set the priority of one of them to be higher than the other, it will mess up your cycle time for the lower priority block. See picture 5.

Siemens Organization Blocks Operating system
Picture 5 – Overlapping of calling different cyclic interrupts

In that case, a phase offset may be advisable when you are using multiple cyclic interrupt OBs.

If their cycle times have common multiples, you can use a phase offset to prevent simultaneous start times. See picture 6.

Organization block Siemens
Picture 6 – Offset between different OB calls

So, to avoid this overlapping, we will set the offset time of OB31 to be 1 ms.

That means the counting for the OB31 time interval will be offset by 1ms than the starting time of OB30. See picture 7.

Cyclic Interrupt Siemens PLC
Picture 7 – Offset setting of OB31



  • Cyclic interrupts are very useful for time-critical tasks that shouldn’t face any delays.
  • You can have more than one cyclic interrupt in your logic.
  • Use the offset setting of the cyclic interrupts to avoid simultaneous start times.
  • Use priority setting to control the order of executing different cyclic interrupts.

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:

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

Leave a Comment