Home Technique Background data block

Background data block



Overview

The S7 project is composed of the main loop block OB1, its calling functions, function blocks, and various interrupt organization blocks (OB):

· Organization block (OB)

·Function (FC)

·System function (SFC)

·Function block (FB)

·System Function Block (SFB)

S7 program includes logic block and data block. Compared with FC, FB has a storage area, that is, a local data block is allocated to the FB block. This data block is called an instance data block.

Generate an instance DB

The time stamp of an FB is more recent than its instance DB, that is, before the user generates an instance data block, the corresponding FB must already exist.

There are two ways to generate a background DB10 for an existing FB10:

·If an FB has been created, you can automatically generate a background DB when calling it.

Call FB10,DB10 The system pops up a dialog box "Instance data block DB10 does not exist. Do you want to generate it?" It prompts whether to create its background DB10 for FB10.

·Insert the data block in the block directory, enter DB10 in the "Name and Type" box in the "General-Part 1" tab, and select the "Shared DB", "Instance DB" drop-down list Choose the latter and indicate that the data block belongs to is "FB10".

Background DB structure

There is a local variable table and block parameters in FB. The local variable table includes: IN (input parameter), OUT (output parameter), IN_OUT (input and output parameter), STAT (static parameter), TEMP (temporary data). Among them, IN, IN_OUT, OUT are interface parameters, which will be directly reflected on the left and right sides of the generated FB block in the future, while STAT and TEMP are internal parameters. In addition to TEMP parameters, other types of parameters will be reflected in the background DB, which means that parameters can be passed through the background DB.

The interface parameters defined by FB directly determine the structure of its background DB. The variable data list in the background DB block includes 8 fields including label, address, declaration, name, type, initial value, actual value, and remarks. The address starts from 0.0 and is assigned in turn according to the declaration and type of each variable, first IN, OUT, then IN_OUT, and finally STAT. The variables of the background DB are the mapping of the FB to which it belongs, and are responsible for transferring data. The background DB cannot be referenced by other blocks.

Calling background DB

·FB calls different background DBs

One FB can call different DBs, which is very beneficial for modular programming. Multiple control objects of the same type can generate one type of FB, and different background DBs can be called for different control requirements of each object.

Such as: call FB10,DB10

call FB10,DB11

call FB10,DB12

·Multi-instance DB

The data type of the variable can be defined in the FB as another FB. For example, define Motor1 and Motor2 variables in FB20 as FB10 type, and the instance data block of FB10 is DB10.

This article is from the network, does not represent the position of this station. Please indicate the origin of reprint
TOP