Analysis of each type of OB block and how to use it: We should pay attention to the following issues when using the corresponding OB. Due to communication, the module does not exist or is faulty. If the I/O access error occurs when the process image table is refreshed, the priority error interrupt (OB85) will be called. For simple programs, only digital logic control is involved. Only OB1 can be used. For complex programs, DP communication is used, etc., and some organization blocks of corresponding functions are needed to ensure that the PLC runs normally. The organization block is the interface between the operating system and the user program, which can be understood from the following aspects: #p#åˆ†é¡µæ ‡é¢˜#e#
We design, engineer and fabricate mold tooling, both standard and
custom. We continuously design custom tooling to satisfy our customer
needs. These tools are built for
machines such as Newbury, Autojector, Ameriplas, Multiplas, etc. Our
Solidworks 3D design capabilities represent the leading edge in the
industry.
We
provide training and know-how to our customers. We offer this unique
advantage to companies interested
in On-site training to assist in the development of in-house
capabilities. Our company can become your "over
-mold engineering department" and can provide quick turn-around, high
quality for customers' the complete cable set with wire harness, plastic, silizone o-ring, metal terminal, or plate, etc. Try to give you the whole supporting service.
Molded Plastic Products,Waterproofing Plastic Box,Plastic Connectors,Plastic Cap,Plastic Bushing ETOP WIREHARNESS LIMITED , https://www.wireharnessetop.com
1, free loop organization block OB1
After the S7 CPU is booted, the operating system cyclically executes OB1. After OB1 is executed, the operating system starts OB1 again. In OB1, user programs such as FB, SFB, FC, and SFC can be called to execute cyclically. With the exception of OB90, OB1 has the lowest priority and can be interrupted by other OBs. OB1 default scan monitoring time is 150ms (settable), scan timeout, CPU automatically calls) B80 reports an error. If OB80 is not established in the program, the CPU enters stop mode.
2, date interrupt organization block OB10 ~ OB17
In the CPU properties, you can set the date and execution mode triggered by the date interrupt organization block OB10~OB17 (after reaching the set trigger date, the OB is executed only once or every minute, hourly, weekly, monthly cycle), etc. Parameter, when the date value of the CPU is greater than the set date value, the corresponding OB is triggered and executed according to the set mode. In the user program, you can also set the parameters of the CPU date interrupt by calling the SFC28 system function, and call the SFC30 activation date interrupt to put into operation. Compared with the settings in the CPU properties, the user program can be flexibly modified during CPU operation. The parameters can be arbitrarily selected in two ways, or one OB can be set at the same time.
3. Time delay interrupt organization block OB20~OB23
The priority of the time delay interrupt organization block OB20~OB23 and the parameters of the update process image area need to be set in the CPU attribute. The system function SFC32 is used to trigger the execution. The OB number and delay time are set in the SFC32 parameter, and the delay time is 1~. 60000ms, much better than the timer accuracy.
4, the loop interrupt organization block OB30 ~ OB38
The cyclic interrupt organization block OB30~OB38 is cyclically executed at the set time interval. The interval time of the cyclic interrupt is set in the CPU attribute. The default time interval of each OB is different. For example, the default interval of B35 is 100ms, in OB35. The program will be called every 100ms, the time interval can be freely set, and the minimum time interval cannot be less than 55ms. The execution time of the user program in the OB must be less than the set time interval. If the interval time is short, it is called again because the cyclic interrupt OB has not completed the program scan, resulting in a CPU failure, triggering OB80 to report an error. If OB80 is not created in the program, The CPU enters the stop mode. The call of the cyclic interrupt can be disabled, delayed, and enabled by calling the SFC39~SFC42 system function. The cyclic interrupt organization block typically handles user programs that require a fixed scan cycle. For example, a PID function block typically needs to be called in a loop interrupt to handle the calculation of the integration time.
5, hardware interrupt organization block OB40 ~ OB47
A hardware interrupt, also called a process interrupt, is generated by an external device, such as a function module FM, a communication processor CP, and a digital input and output module. The digital input module with hardware interrupt is usually used to trigger the interrupt response, and then the corresponding interrupt OB is configured for each module (one module can only have one interrupt OB, and the S7-300 series plc CPU can only trigger the hardware interrupt OB40). In the configuration, the rising edge, falling edge or all of the input point can be selected as the event that triggers the interrupt OB. The interrupt event in the configuration appears, interrupts the main program, executes the user program in the interrupt OB for one cycle, and then jumps back to the interrupt to continue executing the main program. The use of interrupts has no main program scan and process image area update time compared to normal input signals, making it suitable for applications that require fast response.
If a channel in the input module triggers a hardware interrupt, the operating system recognizes the slot number of the module and triggers the corresponding OB, and sends an acknowledgement associated with the channel after the interrupt OB is executed. During the identification and confirmation process, the interrupt event triggered by the channel will be lost; if the other channel of the module triggers the interrupt event, the interrupt will not be lost, and will be triggered after the currently running interrupt acknowledgement; if it is an interrupt event triggered by a different module, The interrupt request is logged and the interrupt OB is triggered when it is idle (no interrupt request from other channels of the module). The call of the hardware interrupt can be disabled, delayed, and enabled by calling the SFC39~SFC42 system function.
6, DPV1 interrupt organization block OB55~OB57
The CPU responds to the interrupt information triggered by the PROFIBUS-DP V1 slave.
7, multi-processor interrupt organization block OB60
For the S7-400 series PLC multi-CPU (up to 4 CPUs in a rack to complete the same complex task) processing function, by calling SFC35, OB60 can be triggered to execute simultaneously in multiple CPUs.
8, clock synchronization interrupt organization block OB61 ~ OB64
It is used to process clock synchronization such as PROFIBUS-DP V1. From the input of each slave station to the logic result output, it needs to pass the slave input signal sampling loop (signal conversion) and the slave backplane bus loop (the converted signal is transmitted from the module to the module). Slave interface), PROFIBUS-DP bus cycle (signal from slave station to master), program execution cycle (program processing of signals), PROFIBUS-DP bus cycle (signal from master station to slave), slave backplane Bus cycle (signal from slave interface to output cabinet) and module output loop (signal conversion) 7 cycles, clock synchronization interrupt synchronizes 7 cycles, optimizes data transfer and guarantees PROFIBUS-DP slave data processing Synchronization. The PROFIBUS clock synchronization interrupt can only be used with S7-400 series PLC CPUs (with DP V2 function).
9, process synchronization processing interrupt organization block OB65
Synchronous processing of the technology block for the T-CPU (CPU with motion control) and the start program.
10, redundant fault interrupt organization block OB70, OB72
For S7-400H redundant systems, when an I/O redundancy fault, such as a redundant PROFIBUS-DP slave, fails, the OB70 call is triggered. When a CPU redundancy fault occurs, such as a CPU switch or a synchronous fault, OB72 is triggered. Call. If I/O redundancy or CPU redundancy fails and OB70, OB72 are not created in the CPU, the CPU does not enter the stop mode.
11, asynchronous fault interrupt organization block OB80 ~ OB87
Asynchronous fault interrupts are used to handle various fault events.
OB80: Processing time failure, re-run after CIR (Configuration In Run), etc., for example, OB1 or OB35 runs timeout, the CPU automatically calls OB80 to report an error. If OB80 is not created in the program, the CPU enters stop mode.
OB81: Handles various information related to the power supply (S7-400 series PLC CPU is called only when the battery is faulty). If a fault occurs, the CPU automatically calls OB81 to report an error. If OB81 is not created in the program, the CPU will not enter the stop mode.
OB82: Diagnostic interrupt. If a diagnostic function with diagnostic interrupt module is enabled (eg disconnection, sensor power loss), OB82 is called in the event of a fault. If OB82 is not created in the program, the CPU enters stop mode. Diagnostic interrupts also respond to all internal and external CPU faults, including module front connector pullout, hardware interrupt loss, and so on.
OB83: Interrupt processing for module insertion and removal events. When an event occurs, the CPU automatically calls OB83 alarm. If OB83 is not created in the program, the CPU enters stop mode.
OB84: Used to handle events such as memory and redundant connection performance of two CPUs in a redundant system.
OB85: Used to handle operating system access module failures, I/O access failures when updating the process image area, event triggering, but the corresponding OB is not downloaded to the CPU, etc. The event occurs, the CPU automatically calls OB85 to report an error, if OB85 is not created in the program. The CPU enters the stop mode.
OB86: For handling events such as expansion racks (not for S7-300 series), PROFIBUS-DP master stations, PROFIBUS-DP or PROFINET I/O distributed I/O systems, events occur, the CPU automatically calls OB86 Report an error, if the program is not created, the CPU enters stop mode.
OB87: It is used to process MPI GD communication and clock synchronization faults. When an event occurs, the CPU automatically calls OB87 to report an error. If it is not created in the program, the CPU will not enter the stop mode.
12, processing interrupt organization block OB88
It is used to process program nesting, area data allocation fault, fault occurs, CPU automatically calls OB88 error, if the program is not created, the CPU enters stop mode.
13, background loop interrupt organization block OB90
The lowest priority, to ensure the shortest scan time of the CPU, to avoid the process image area update too frequently. The download of the program and the deletion of the program in the CPU trigger the call of OB90. Can only be used with S7-400 series PLC CPUs.
14, start interrupt organization block OB100~OB102
For handling CPU startup events, warm start CPU calls OB100, hot start CPU calls OB101 (not suitable for S7-300 series PLC and S7-400H), cold start CPU calls OB102, the lower the temperature, the memory area is cleared when the CPU starts up. The more types you have.
15, synchronization error interrupt organization block OB121, OB122
OB121 handles events related to programming faults, such as the function being called is not downloaded to the CPU, BCD code error, etc. OB122 handles events related to I/O address access failures, such as read failures when accessing an I/O module. . If the above fault occurs, OB121 and OB122 are not created in the program and the CP enters the stop mode.
Note: Not all OBs can be used in the S7 CPU. For example, only the warm start OB100 in the S7-300 series PLC PU, the operating system cannot call OB101, OB102. For the OBs that can be used in the CPU, please refer to the CPU selection manual.
The priority of the organization block in the S7-300 series PLC is fixed and cannot be modified. The priority of the following organization blocks in the S7-400 series PLC can be modified:
OB10~OB47: The priority modification range is 2~23.
OB70~OB72: The priority modification range is 2~38.
OB81~OB87: The priority modification range is 2~26, and the priority 24~26 ensures that the asynchronous fault interrupt is not interrupted by other events.
Several organization blocks can have the same priority. When events occur simultaneously, the organization blocks are triggered in the order in which they occur. If more than 12 OBs of the same priority are triggered in the same way, the interrupt may be lost.
1. OB only responds to the fault in time, but does not solve the fault. The OB allows the CPU to run with faults.
2. Diagnostic OB, such as OB82/86/122, reflects the hardware failure, which cannot be solved by software. The function of the software is to point to the fault point as soon as possible, and the hardware problem is still solved by hardware.
3. The generation of diagnostic OB will affect the execution speed of the entire program of the CPU, which will affect the control quality of the system, especially some high-speed production lines with process interruption, large amount of calculation and motion control.
4. Unconditional OB to cover up the fault is a very dangerous thing, there should be countermeasures to get the system into a controllable security state as soon as possible.
You can set three ways to call OB85 in the CPU Properties dialog box. The default mode of the S7-300 is not to call OB85. The default mode of the S7-400 is to call once every scan cycle, and it can also be set to be called once when the fault occurs and disappears.
When a faulty I/O module or DP slave is accessed using the PI/PQ address area, the I/O access error interrupt (OB122) is called and is called once per scan cycle.
1 OB100 starts the organization block, that is, the PLC first processes the block after the first scan cycle of power-on, and does not scan later, so the initialization pulse can be done in this block to reset some data.
2 OB122 I/O access error organization block,
3 OB121 programming error organization block, this block is more important, once encountered a German imported feeder, the CPU can not run after a period of use, the program is using STL programming, using a lot of indirect addressing, it is difficult to find the problem, After selecting this organization block, the CPU running device will work normally.
4 OB82 diagnostic interrupt organization block, this need to use this block for projects using more analog modules, otherwise CPU failure is a big deal when there is a problem with the analog signal.
5 OB80 Time error organization block, including: Exceeding cycle time, acknowledgment error when executing OB, advance time of OB is skipped, and RUN mode is restored after CiR.
6 OB86 rack failure organization block, which is required for distributed I/O using DP communication. To find the faulty substation in the first time, you need to use OB86 as the DP fault diagnosis. You need to program the OB86 variables and use the touch screen or other host computer to display the alarm content.
7 OB87 communication error organization block.
1. The organization block is not called by the user program, but is called by the operating system. There are only temporary variables in its variable declaration table.
2. Organization blocks are divided into three categories:
Start the organization block for system initialization;
The main program OB1 is executed cyclically;
When an interrupt event occurs, the operating system stops executing the current task and calls an organization block assigned to the event.
3. In addition to the automatically generated OB1, other organizational blocks require user generation, and the programs in the organization block are written by the user.
4. Each organization block has a 20-byte local variable containing the startup information of the OB. This information is provided by the operating system when the OB is started, including startup events, start date and time, errors, and diagnostic events.
5. The priority of the interrupt is also the priority of the organization block. If an interrupt request is detected while executing the interrupt program (organization block), the CPU compares the interrupt priorities of the two interrupt sources. If the priorities are the same, they are processed in the order in which the interrupt requests are generated. If the latter has a higher priority than the OB being executed, the OB currently being processed will be aborted and the higher priority OB will be executed instead.
The following is the order of priority (later precedence over the previous one): background loop, main program scan loop, time interrupt, time delay interrupt, loop interrupt, hardware interrupt, multiprocessor interrupt, I/O redundancy error, asynchronous Fault (OB80~87), startup and CPU redundancy, the background loop has the lowest priority. You can use STEP 7 to modify the priority of certain organization blocks of the S7-400 CPU.
6. Time Interrupts and Time-Delay Interrupts have dedicated system functions that allow interrupts to be processed (or activate, enable interrupts) and disable interrupts.
Other organization blocks can use SFC 39 "DIS_INT" to disable certain interrupts and SFC 40 "EN_INT" to activate (enable) disabled interrupts.
SFC 41 "DIS_AIRT" is used to delay processing interrupts of a higher priority than the current priority until SFC 42 "EN_AIRT" is used to allow immediate processing of interrupts temporarily disabled by SFC 41.
Ob1: Loop scan ob, it has no time interval. After ob1 is executed, it will execute ob1 again from the beginning, so the externally input analog data is converted into engineering quantity and executed in ob1, so that the data can be updated in time.
Ob10~ob23: It is rarely used.
Ob30~ob38: ob33 and ob35 are commonly used, time-related programs are generally placed in these ob, such as the block controlled by pid, requires not very strict time processing function, when the timer is not enough A timer-like block written by myself.
Ob100~ob102: These obs are only started once in the different startup mode of the cpu. All the initialized programs can be written in these obs.
Other obs are not commonly used.