Adding of Data Blocks and Function Block

<< Click to Display Table of Contents >>

Navigation:  Multi-Protocol MasterOPC Server > Plugin Siemens Profinet > Manual Adding of Tags >

Adding of Data Blocks and Function Block

Data Block is a structure of different variables a user configures. In the development system, Data Block is added to a project root or to a nested group.

Function Block - is a variable structure as well as SCL (ST) code.

The following is an example of how to create and configure a new block using the Data Block example. Function Block is created and configured similarly.

siemens_img8

You should define a block type, a block name and a method of block numeration (a block number must be then specified in Multi-Protocol MasterOPC Server in the Region textbox):

siemens_img9

Using the Properties command from the context menu of the data block, open the respective tab and set off the Optimized block access flag (otherwise Multi-Protocol MasterOPC Server will not interrogate PLC):

siemens_img10

After that, variables of types required are added to a Data Block table. A PLC program will operate with such variables, and Multi-Protocol MasterOPC Server will be able to interrogate them.

As an example, let’s view getting data from the block Data_block_1 (block number is 1):

siemens_img11

The data block has the following table of variables:

siemens_img12

A data type and a byte address of variables can be known from that table (from the columns Data type and Offset respectively)

Add the first variable (Static_1) to Multi-Protocol MasterOPC Server. Add a tag and configure its properties according the table (region – DB, block number – 1, data type – Word, byte address – 0):

siemens_img13

Add the next variable (Static_2). A region, a data type and a block number are the same as for Static_1, and a byte number is 2:

siemens_img14

Add Static_3 (block number – 1, data type – bool, byte address – 4, bit number – 0 (because of we retrieve one bit)):

siemens_img15

Static_4 has the same parameters, but a bit number is 1.

Add Static_5 (region – DB, data type – Word, block number – 1). The byte 4 is already occupied by two logical variables, and the address 5 cannot be used (variables of 2 bytes and more must be stored in even addresses), therefore set the next even address – 6:

siemens_img16

If variables are added to a structure (a variable of the Struct type), the Offset column contains a variable address with respect to an initial address of the structure. Therefore, a variable address equals a sum of the offset and the initial structure address. For instance, the address of Static_5 equals 8 (6 is the initial address of the StaticGroup2 structure, and 2 is the variable address in the structure):

siemens_img17

The table below shows data types Multi-Protocol MasterOPC Server supports, and their dimensions.

 

Data type

Dimension

bool

1 bit

byte

1 byte

char

1 byte

wchar

2 bytes

sint

1 byte

usint

1 byte

word

2 bytes

int

2 bytes

uint

2 bytes

dword

4 bytes

dint

4 bytes

udint

4 bytes

real

4 bytes

lreal

8 bytes

string

256 bytes

wstring

512 bytes

Date

2 bytes

TOD

4 bytes

Time

4 bytes

DT

8 bytes

S5Time

2 bytes