×

Subscribe to newsletter

subscribe to our weekly newsletter to get notified with latest story and article Subscribe now!




PLC BLOG | Siemens Data Blocks (DB)
Share on Facebook Share On Twitter Share on LinkedIn Share on Whatsapp


Siemens Data Blocks (DB)

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. user data may be INT, DINT,array,udt, Float, string etc. logical blocks FC, FB and OB is occupy temporary space in the local data area but data blocks occupy space in plc memory area, the data in a DB are not deleted when the DB is closed, in other words, after the corresponding logic block has been executed. in memory of PLC. size of data blocks is depend on plc for size of data blocks read the cpu manual. in data blocks you can create or define any type of data. when you create data blocks it easy to share user data in other function blocks as well as other plc. Generally data blocks are two types
  • Shared Data Blocks (DB) : some time called global data block it can be accessed by all other blocks.
  • instance data blocks : Instance db assigned for particular function block (FB).


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".

how to create shared data blocks

or you can insert data blocks by select cpu and right click on it and select insert new object > data blocks how to create shared data blocks

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

how to create shared data blocks

structure of data block

when you open data blocks, you can see some column so here is description of the column
  • address: address for your variable, address automatically assigns for the variable.
  • name : symbolic name for assigned variable.
  • Type : the data type for your variable. For data type refer to data type page.
  • initial value: The initial value for the variable which you declare.
  • comment: comment for variable.

structure of data block

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.

how to declare variable in Siemens data block

insert variable in data blocks

insert variable and save the data block.

data blocks variable

declaration of data block

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

declare your data block

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.

db call

address of 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
  • X is stand for bool data type for example DB1.DBX256.0, DB1.DBX260.1
  • D is for real, dWORD AND DINT data type for example DB1.DBD258
  • W is for int, word. DB1.DBW258
  • W is for int, word. DB1.DBW258
  • if you declare string than your address is p#db1.dbx76.0 where p stands for pointer.


use of data blocks

here is simple example of data block in ladder logic in

image 1: complete data block declaration
data block example

    all address is assigned automatically, so you can not declare address in data block. you can declare name and data type of the symbol or identifier.

image 2: use of data block in program
data block example

  • network 1 : data block in OB1 by using call instruction.
  • network 2 : all bool data type declare in in block.
  • network 3 : real data type declaration in block.
  • network 4: DINT data type declare block.
  • network 5: string data type is declare with Pointer P#.


how to write value in 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.

how to write value in data block
 
Share on Facebook Share On Twitter Share on LinkedIn Share on Whatsapp


Suggested Post


 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

comment