Cyclic interrupt, time interrupt etc

rQx

Lifetime Supporting Member
Join Date
Oct 2010
Location
Trelleborg
Posts
1,051
Hi!

Just a question of curiosity and self education.

I have always wondered, what are these for or why/how do we use them?

Why can't we write the code in the regular block?

I'm using TIA portal, don't know if there are similar functions in diffrent programs.

/Tim
 
The interrupts are coming from the world of micro-controllers and is its most important feature. Basically you can't do any serious programming if you don't have good understanding of interrupts. What they do is to interrupt the main program to run a routine and the return back to normal program flow.
For example instead of polling a hardware pin (input) it's possible to activate a hardware interrupt so when an event occurs it will be serviced by a corresponding subroutine interrupting the main program flow. Interrupts source can be software (for example timer overflow) or hardware (external even is present on a pin).

http://www.engineersgarage.com/tutorials/interrupts-8051-interrupt-programming

In S7-1200 manual Siemens states that communication processing in their controllers occurs periodically throughout the scan, possibly interrupting program execution.
So if you want something to happen always during scan you can use a cycle interrupt.
In PLCs interrupts help you make your program more even-driven and gives you better control over scan time. It's really a very powerful feature.

Excerpt from S7-1200 manual:

4.3.1 Processing the scan cycle in RUN mode
For each scan cycle, the CPU writes the outputs, reads the inputs, executes the user
program, updates communication modules, and responds to user interrupt events and
communication requests. Communication requests are handled periodically throughout the
scan.
These actions (except for user interrupt events) are serviced regularly and in sequential
order. User interrupt events that are enabled are serviced according to priority in the order in
which they occur. For interrupt events, the CPU reads the inputs, executes the OB, and then
writes the outputs, using the associated process image partition (PIP), if applicable.


For example if you have a program with a long scan time, you could use a hardware interrupt to do something immediately as soon as edge event appears on a input without waiting for the whole scan to complete.

For more detailed information check section 4 in S7-1200 Easy book.
https://cache.industry.siemens.com/.../att_5787/v1/s71200_easy_book_en-US_en-US.pdf
 
I have always wondered, what are these for or why/how do we use them?
Program scan time can vary, sometimes quite a bit, especially if subroutines or loops are involved. A timed interrupt establishes a fixed, program-independent interval between instances of a given event - could be input, output, or some important internal processing. Say an input must be sampled at least every 500ms. A timed interrupt can insure this whereas a sample based on logic only cannot (assuming ordinary straightforward programming).


Why can't we write the code in the regular block?
When the processor is 'interrupted' certain registers - like which rung you're on or the state of the sign bit - are stored since any or all may be altered while processing the interrupt. When the interrupt routine is ended (with a special ReTurn from Interrupt instruction) those registers are restored so the processor can pick up where it left off in the main program. If you just put an RTI instruction in the main ladder (assuming your programming software would allow this) and the processor hits it it will pull erroneous info off the stack and bad things will happen.

If you're working on your weekly report and your boss comes in and says he needs a special report on why machine A blew up on Wednesday (this is an event-based interrupt) do you keep on writing on the paper with your weekly or, do you set the weekly aside and start machine A's report on a new sheet and return to the weekly at some later time?
 
In Siemens, the use of cyclic interrupts is especially important when using PID controllers. For these blocks it is important that they are evaluated with a fixed time interval .
 

Similar Topics

Hello to all, I know there are a few people here very experienced with Codesys. I wonder does Codesys have something similar to OB35 in STEP7...
Replies
3
Views
616
Hi, When I use an interrupt OB (let's say OB38 which is processed every 10ms), does it read the state of the inputs at the time it is called, or...
Replies
18
Views
2,364
Hello all, I've decided to have a play with TIA Portal V13. In Step7 you can evaluate the value of the temp variable #OB35_Exec_Freq to...
Replies
3
Views
5,878
Hi I am very new to the field of PLC programming. I am programming an anticollision program on a Siemens SIMATIC ET200S. I have learned that it...
Replies
1
Views
2,355
Is there any kind of system function or something that stops cyclic interrupt during excitation of some other function. So for example inside fc3...
Replies
6
Views
1,996
Back
Top Bottom