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.
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.
for creating shared data blocks go to menu insert > s7blocks > data blocks "as shown in the figure below".
or you can insert data blocks by select cpu and right click on it and select insert new object > data blocks
a dilog box open enter the name of data block and press ok.
when you open data blocks, you can see some column so here is description of the column
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.
insert variable and save the data block.
now open symbol editor and declare your data block and save.
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.
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
here is simple example of data block in ladder logic in
image 1: complete data block declaration
image 2: use of data block in program
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.