Siemens Data Blocks (DB)

Published on Jul17, 2021 | Category: block
Share this article:

data blocks only stored user data,in data blocks you can not write any user program, instructions, logic or statement it only contains user data.data blocks stored any type of defined user data.

Siemens Shared Data Blocks (DB)

shared data blocks are used to store user data and variable that can be accessed by all other blocks like FC, FB, OB etc. Each FB, FC, or OB can read the data from a shared DB or write data to a shared DB. This data remains in the DB after the DB is exited.

how to create shared data blocks

for creating shared data blocks go to menu insert > s7blocks > data blocks "as shown in the figure below".

img/datablocks/howtocreatedatablocks1.webp

or you can insert data blocks by select cpu and right click on it and select insert new object > data blocks img/datablocks/howtocreatedatablocks2.webp

a dilog box open enter the name of data block and press ok.

img/datablocks/datablocksproperty.webp

structure of data block

when you open data blocks, you can see some column so here is description of the column

img/datablocks/datablock.webp

how to declare variable in siemens data block

for declaration of variable write click on any column except type. or select entire row and select declaration before line or declaration after line refer image 1. or go to menu and click insert and select declaration line > before line or after line refer image 2.

img/datablocks/datablockswritevariable.webp

insert variable in data blocks

insert variable and save the data block.

img/datablocks/datablocksvariable.webp

declaration of siemens data block

now open symbol editor and declare your data block and save.

img/datablocks/symboleditor.webp

calling of data block to other blocks(FC/FB/OB/SFC)

open or create your programming blocks ob/fb/fc where you want to use data blocks. for calling of data blocks to other blocks use "db call" instruction and define name of your data block as shown in figure. Go to db call, insert open data block instruction ( -(opn)) and declare name of your data block.

img/datablocks/dbcall.webp

address of siemens data block

for example address of data block is DB1.DBX256.0, where DB1 is data blocks name and DBX256.0 is variable bit address which you declare in data block

use of siemens data blocks

here is simple example of data block in ladder logic in

image 1: complete data block declaration

img/datablocks/datablockdeclaration.webp

image 2: use of data block in program

img/datablocks/datablockexample.webp

how to write value in siemens data block

when you finish your instruction work than save your data block, instrunction and project. Go to simatic manager make all network configuration properly and download complete project to plc , make sure you download your all blocks in plc. now go to online and start monitoring . Change the value in actual value column and download again your data block to plc . Always download your data block when you change data block actual value.