data block for s5-95u


Thread Starter


i just want to know how to utilized the data blocks in s5-95u. where can i use it. can you give me some example. thank you.

Michael Griffin

You can have up to 254 data blocks to play with (DB0 and DB1 are special and are used by the PLC for its own purposes).
Before you can use a data block, you have to create one in your programming software (read your Step-5 manual on how to do this). It would get down loaded to the PLC, just like a PB or FB would be.

Your program can use one data block at a time. If you need to use more than one in the same program (and you would normally use a number of them) You have to close the one you were using, and select a different one. You do this with the "call" instruction. For example, "C DB100" would close the current data block and open DB100. Technically it doesn't really 'close' the old data block, but that is a good way for you to think of it, as the old one is no longer available to you while you are using DB100. You can consult the manual for more details later if you are interested in seeing exactly what really happens.

Now you can "load" and "transfer" just like you would for a flag word. For example, "L DW10" would load data word 10 into accumulator 1. "T DW11" would transfer the contents of accumulator 1 into data word 11.
C DB100
L DW10
T DW11
This effectively transfers the contents of data block 100, data word 10 to data block 100, data word 11. Notice there is a difference between using data words and flag words though. Data word 10 does not overlap with data word 11 as would be the case with flag words. If you want to use the lower byte of DW10, then you would address it as DR10 (data right 10). The upper byte is DL10 (data left 10). You can address single bits by the format "D10.0", which in this example addresses bit 0 of data word 10. This bit format is very seldom used however. Most people just use data words as entire words, and use flags when they want bits.

A data block can contain up to 256 words (DW0 to DW255). It is actually possible to make data blocks which are bigger than this, but you can't address them with conventional load/transfer instructions.

Michael Griffin
London, Ont. Canada

Hakan Ozevin

That's a wonderful explanation of DB's in S5.

I want to to add something exceptional. In some cases, you may need to generate a new data block. You can do this by the G DB nn command
which generates the data block nn with the length of the value of ACCU1. So for example:
L KF +100
G DB 20
generates DB20 with 100 word length (full of zeroes of course).
We usually need this in CPU 941 and 942 of S5-115U where EPROM is used to extend the memory and DB's should reside in the RAM. You will not
probably need this in S5-95U, where EPROM and RAM contents are the same.
Our example:-
There are seven line speeds, data blocks are used to store and retrieve counter, timer and analog out presets for the different line speeds.
I.E 7 data blocks for storage when speed selected data block data is loaded into working data block for operation and SCADA display and
alteration if required.