Programming options
5.2 Structuring your user program is easy
Easy Book
Manual, 05/2009, A5E02486774-01
53
5.2.1
Use OBs for organizing your user program
Organization blocks provide the structure for your program. They serve as the interface
between the operating system and the user program. OBs are event-driven. An event, such
as a diagnostic interrupt or a time interval, will cause the CPU to execute an OB. Some OBs
have predefined start events and behavior.
The program cycle OB contains your main program. You can include more than one program
cycle OB in your user program. During RUN mode, the program cycle OBs execute at the
lowest priority level and can be interrupted by all other types of program processing. (The
startup OBs do not interrupt the program cycle OBs because the CPU executes the startup
OBs before going to RUN mode.)
After finishing the processing of the program cycle OBs, the CPU immediately executes the
program cycle OB again. This cyclic processing is the "normal" type of processing used for
programmable logic controllers. For many applications, the entire user program is located in
a single cyclic OB (such as the default program cycle OB 1).
You can create other OBs to
perform specific functions, such
as startup tasks, for handling
interrupts and errors, or for
executing specific program code
at specific time intervals.
Use the "Add new block" dialog
to create a new OBs in your user
program.
The CPU determines the order
for handling interrupt events by a
Creating an additional OB within a class of OB: You can create multiple OBs for your user
program, even for the program cycle and startup OB classes. Use the "Add new block"
dialog to create an OB. Enter the name for your OB and provide an OB number of 200 or
greater.
If you create multiple program cycle OBs for your user program, the CPU executes each
program cycle OB in numerical sequence, starting with the main program cycle OB (default:
OB 1). For example, after first program cycle OB (OB 1) finishes, the CPU executes the
second program cycle OB (such as OB 200).