What are Data Blocks?? How to use them? How they are diffrent from Memory blocks


WHAT ARE DATA BLOCKS???


A data block is an area of memory that can be freely setup for any type of data you like. This can be bits, bytes, words, ints, reals or even your own data types. Size of the data block depends on the PLC. Consult the manual for that PLC. Generally, 1024 bytes is safe for all S7 300 and 400. Most are capable of more.
Function of the data block is to allow you to setup the memory area in a convenient manner for your program. As a secondary function, it allows you to set aside memory for the FB type of function. This type of function retains its memory between calls, therefore needs a place to store the "instance" of the function block.
You can save your data into markers (example MW20) but they are very limited in numbers so with them you can not work with a lot of data.

A function block (FB) is automatically assigned with a data block (DB). In this DB the status of the FB his 'in', 'out', 'in/out', and 'stat' variables are saved or given a default value. The default value is the 'initia'l value what you gave them when you created that variable inside the FB.  

NOTE: A Datablock is not a block for writing code, its a data storage area.

The best use of a Data Block is data organization and transfer. For instance, with a data block you can store all data for a given system in one location. Below: DB1 Pump 1 Data Block Status | BoolRun Command | BoolRun Minutes/Hours | DIntDischarge Pressusre | IntSuction Pressure | IntTemp | IntOnce you have created the Data Block you can easily view all data in one location while online in the PLC. Not to mention if you had to send this data to a SCADA system you could just send DB1 instead of all the individual points. I know Siemens WinCC v7 SCADA package allows you to build faceplates that provide functionality with data blocks for ease of use. For instance you would build one faceplate and insert the data above like I have shown in the data block. Then tell the faceplate to poll DB1. The faceplate will automatically apply offsets as you specify for the data. I.e. Status would be DB1 offset 0.0.Run Command would be DB1 offser 0.1, Run Miuntes would be DB1 offset 1, and so forth. This way you can duplicate faceplates in a minute or two rather than 30 minutes.



Why Should We Use Data Block (DB) Instead of Memory Bit (M) in Siemens PLC-S7 Programming in Industrial Automation?

Data Block has several advantages over Memory Bit including: 

1) Initial Value Allocation: You can define an initial value in DB. 
2) Write Protection: You can define a DB as Read-Only. 
3) Retentively: If you save the DB in Flash Memory Card, data will be saved on power loss. For Memory Bit, you need to manually define them in Retentive Memory region in CPU Properties. 
4) Defining Complex Parameters: You cannot define more than 4 bytes in Memory Bit as MD. If you need Date and Time data, which is more than 4 bytes, the only way is to use DB. For other complex data like Array and Struct, Data Block is the approach to define them. 
5) Assortment and Data Management: It is hard to classify Memory Bit, while you can define an independent DB for each section of a process, like system monitoring or data communications. 
6) Vast Memory Capacity and the Capability to Extend It: Since DBs are in Load Memory, you can extend them with adding memory cards. The only disadvantage of the Data Block over the Memory Bit is the necessity of downloading DB to the processor if you want to call an address relevant to the DB in the program. Otherwise, if there is no OB121, as a Synchronous Error Interrupt, PLC goes to the Stop Mode. This issue does not appear in Memory Bit, since this memory is in the System Memory and there is no need to download to the processor.

Data Blocks (DBs) can be used by your program to save data in the CPU. Your hard disk contains up to 8 Kbytes(8192Bytes) space. There are two types of data blocks. Global DBs, where all OBs, FBs and FCs read all saved data or can even write in the DB and local instance DBs, which are assigned a particular FB. In the DBs, different data types (e.g. BOOL or WORD) can be saved in arbitrary order. This structuring of a DB follows through input in a table with the tool LAD, STL, FBD - S7 Block Programming.
In the program structure from STEP 7, data blocks are found as follows:
Fig-1.


Data blocks are generated and opened like program blocks in the tool LAD, STL, FBD: Programblocks. They serve e.g. for the saving of data and system states.
Before create Data Blocks (DBs), we must understand about addressing Data in Simatic Step7. Figure 2 show the addressing data elements in Simatic Step7. There is 3 elementary data type:
  • Bit data Type (Bool, Byte, Word, DWord, Char)
  • Mathematical data type (Int, Dint, Real)
  • Time types (s5Time, Time, Date, Time_of_Day)
Fig-2.




In the figure 2, 1 box represent 1 Bit memory. 1 Bool have length 1 Bit, and 1 Byte have length 8 Bit. For more detail you can see in table below

Type
Size in Bit
Range and Number Notation
Bool
1
True/False
Byte
8
B#16#0 to B#16#FF
Word
16
W#16#0 to W#16#FFFF
DWord
32
DW#16#0000_0000 to DW#16#FFFF_FFFF
INT
16
-32768 to 32767
DINT
32
-2147483648 to 2147483647
Real
32
Upper Limit +/- 3.402832e+38
Lower Limit +/- 1.175495e-38
S5Time
16
S5T#0H_0M_0S_10MS to
S5T#2H_46M_30S_0MS and
S5T#0H_0M_0S_0MS
Time
32
T#24D_20H_31M_23S_648MS
to
T#24D_20H_31M_23S_647MS
Date
16
D#1990-1-1 to
D#2168-12-31
Time_Of_Day
32
TOD#0:0:0.0 to
TOD#23:59:59.999
Char
8
A, B, etc.
 





  For Video Demonstration on How to use Data Blocks, What are Data Blocks? visit : https://youtu.be/tDa5c3dHkf8 .



Comments

Popular posts from this blog

What are Timers? || How to use Timers || Using Timers in Simatic manager

Basics of Configuring Hardware with Simatic STEP 7 (v5.5 & v5.6)

How to configure Racks in SIEMENS PLC