Siemens Data Block Value

stevenPLC

Member
Join Date
Sep 2004
Posts
27
Hi..

I'm using the Simatic S7 for programming a CPU315-2DP. I found something:

Whenever I re-download a Data Block (DB) into the PLC, overwrting the older one,I found that all the data value will be changed to 0 (zero for Non Boolean Type ; OFF for Boolean Type). I suspect that the actual value were replaced by the initial value of the DB. Am I right?

1) If it's really so, anyway that I can store the current value of the DB and make it as the initial value for my newer DB?

2) By the way, if I'm using Multiple Instance Block, how can I save different Initial Value for the different Instance DB?

Thanks..
 
Copy the global data from from the online folder to the offline folder, make any edits/changes you require, then download the DB.

Concerning instance data, give an example of what you are trying to do.
 
About 1): What Simon is saying is, that it is the Actual values in the Offline DB that must be updated with the Actual values of the Online DB. Simply drag and drop the relevant DB from the online to the offline project.

The Initial values are only important when creating a new DB from a declared FB or UDT.
There are a few other actions in STEP7 that will "initialise" a DB, "reorganising" the project for example
Most of the time, the Initial values are not important.

So if you want to make changes in an Offline DB, and then download the changed DB in order to make the changed values active, then it is the Actual values that must be modified, not the initial values.

About 2): You can change the Actual values of an instance DB (not the initial values).
Open the DB offline, change the actual values, save the DB and use "download parameter set".
However, this way of doing it has the pitfall, that if the DB is recreated (and that can easily happen with instance DBs, and very very easily with multiple instance DBs) then the actual values are set to the initial values again.
Best is to keep settings that can be or needs to be modified outside of the STAT declaration of the FB. These settings should be passed over as Input parameters.
 
After getting bitten a couple of times, I've gone over to initialising the DBs from OB100 on start up. I need to do this in two places:

1) a correction factor to correct the Setpoint sent to the Charger so that the Voltage we measure directly on the Capacitors is correct.

2) the actual total capacity of the 14 capacitors in each module, as opposed to the theoretical capacity which is in the Initial Value, so that the energy calculation is correct.

The only problem I have is that I won't be commissioning the last ten or so modules, so somebody (with minimal PLC experience) is going to have to do this for these modules. I'm not sure I want somebody else mucking about in OB100, when I'm not certain they know what they're doing.

I initially added the facility to the ProTool Module Test picture to enter the corrected capacity, but since that just went into the DB, it still suffered from the Initial Value problem on a restart. Anybody got any ideas how I can let the operator input correction factor/actual capacity values via ProTool.

I toyed with the idea of using SFC22 CREAT_DB and recreating the DB every time a new Module was added (copying the values from the existing DB), but it looks like it would get awfully messy. If anybody can think of an easier way, I'd be glad to hear it!
 
Last edited:
Roy,

are you sure that the DBs get reset to the initial values upon a power cycle ?
I remember that your are using S7-317, so you have an MMC that should keep the actual values - even with a power cycle.

Is the relevant DBs set to retentive (i.e. "non-retain" is NOT set) ?

Are you within the limit of how many DBs can be kept retentive in the S7-317 ?
I remember there is a limitation with the S7-317 (max 256 kB).

I think it is impossible to manipulate the initial values from any HMI software.
 
No - a power cycle's no problem, after reading your post, I realised I've got two problems:

1) On restart as mentioned above (i.e. RUN -> STOP followed by STOP -> RUN) (I very rarely do it myself, but I can't rule out that it might happen on site.)

2) On reorganise - and I do this about once a day! That explains a few mysterious returns to Initial Values that I've experienced without knowing why.
 
1) So your problem is with RUN > STOP > RUN cycle.
I am pussled, because this should not initialise the DBs.
Maybe you are doing something in OB100.

2) Yes, reorganising can do that. I am not sure if STEP7 goes out and updates EVERY DB, or just the ones where the declaration has changed (actually the timestamp has changed).

For your info:
I try to keep settings (that may need changing during runtime) in a shared DB.
Normally it is enough to only manipulate the actual values, but to be damned sure the initial values also has to be updated accordingly.
If there are many values that has to be changed that way, then it can be very tedious indeed, and a source of errors. That is why I toyed with using Excel to copy the Actual values to the Initial values in one go.
 
1) So your problem is with RUN > STOP > RUN cycle.
I am pussled, because this should not initialise the DBs.
Maybe you are doing something in OB100.



Thinking about it a bit more, that may be an assumption, I'm not sure now - I just know for sure that the Initial Values were back when I didn't expect it. It may actually have been the reorganisation - I wasn't aware of that problem, so I guess I just assumed that it was the Restart (following a freeze-up) that caused the problem.
 
I always initialize the DBs on startup as well, mostly because I want my code to work no matter what processor or memory card is being used. And, I can download a new project and restart anytime I want without worrying about values. You can initialize IDBs the same way.

As for retaining the values of a DB, unless I am doing something very wrong, I would lose all of the DB variable symbols if I copied it from the online folder. Instead, if there are values I want to retain for some reason, I make a second copy of the DB (a scratch DB) and copy the original DB to it whenever I want. Then, if I download a new DB (and set all of the values to 0), I just copy the values over from the scratch DB automatically on startup. This is the most graceful solution I've found so far.
 
.. unless I am doing something very wrong, I would lose all of the DB variable symbols if I copied it from the online folder.
When I drag and drop a shared DB from online to offline, then the actual values gets updated and the symbols are retained.
Then again, I dont know what I am doing right.
If you go online with said DB, will STEP7 then display the symbols ? If it wont, then it is an indication that there is a timestamp conflict.
 
Now I remember what I was doing. I didn't want to overwrite the offline block, so I copied the offline block to a new location, deleted the original, and then uploaded the online block, which of course means none of the symbol info will be retained (all I get is "stat" variables, although the data types and structures are retained). I would then export the actual values to a spreadsheet so I could analyze them, put my original block back, and my project remained unchanged. I never thought about uploading a block permanently, but you are absolutely right, it works.

But I'd still be nervous about saving online values to my offline project. Actual values are just a snapshot of the process, and may or may not be "good" values. I'd be careful.
 
JesperMP said:
For your info:
I try to keep settings (that may need changing during runtime) in a shared DB.
Normally it is enough to only manipulate the actual values, but to be damned sure the initial values also has to be updated accordingly.
If there are many values that has to be changed that way, then it can be very tedious indeed, and a source of errors. That is why I toyed with using Excel to copy the Actual values to the Initial values in one go.

May I know how you use Excel to copy the Actual values to the Initial values in one go? As I find that I can't copy or paste when the DB is opened up with "Data block Parameter Assignment.Or what you use to open up the DB and do the copy & paste thing?
 
Jesper posted that in this thread a while back.

If you do a search on "DB initial values" and link to "JesperMP" in the members name box, you'll get a whole row of hits on discussions about and around this subject. Some it you might well find interesting or useful.
 

Similar Topics

Hello all, PLC-programming noob here. I have multiple clients accessing some data on my Siemens S7 1211C PLC; some OPC clients and some direct...
Replies
30
Views
8,286
Hello all, Newbie in Siemens, I want to ask if there will be any issue when I download the instance datablock of a certain Function block? Also...
Replies
6
Views
4,396
Just a quick question I can't find an answer on yet. I have created my own recipe structure using a Global DB and when I came in this morning...
Replies
2
Views
2,015
Hello, I am trying to find an easy way to create data blocks in Step 7 with ~100K tags other than manually defining each tag in the LAD/STL/FDB...
Replies
8
Views
14,158
Hello All, Is there a way in Step 7 5.5 SIMATIC Manager to export a data block so that it can be imported into another project with all...
Replies
11
Views
3,710
Back
Top Bottom