S7 instance DBs gets reset to "initial val" upon cold restart.

JesperMP

Lifetime Supporting Member + Moderator
Join Date
Feb 2003
Location
ᚴᚬᛒᛅᚾᚼᚬᚠᚾ
Posts
16,239
Greetings all,

I have a general problem when using instance DBs with FBs in S7.

Upon a cold restart, the values in the instance DBs gets reset to the "initial values" defined in the calling FB.

But I would rather keep the "actual values". The initial values gives a good starting point, but during commisioning, some of the settings that are stored in the instance DBs will be changed to some other value. My point is that various DBs can have different values, so I cant just change the initial value, as this will change ALL DBs.

Is there a way of storing/retrieving selected instance DB values in a separate DB file so that the "actual values" can be reused.

I guess that I am not the first one who has this problem, so I hope someone has come up with a great little subroutine allready :rolleyes:
 
You could make the DBs retentive in HW config-CPU Properties-Retentive memory. There it's possible to set 8 DBs retentive.
There is some limitations for how much data you can set retentive depending on the CPU type.

If you need more then you should write some code. For example you can make one big DB where you copy the values from the DBs you want to save and make that DB retentive. Then in case of cold restart you should write the values back to original DBs.

TS
 
Thanks for your suggestion,
but the retentive DBs are only possible on a S7-300 with MMC card. I am using S7-400.
Also, there are so many DBs (hundreds of them) that it isn't enough with only 8.

I guess I will have to make a kind of look-up table in a DB.
Then, using the look-up table, locate the DB values I want to save and copy the values into a retentive Merker area.
To retrieve the values, the proces must be reversed.

A problem with the above approach is that saving of the data can only be done while online with "write to memory card".
I am therefore considering writing to a DB on the memory card with the function SFC 84 "WRITE_DBL". The operator then has to select one of several functions, like "save all current settings to memory card" or "retrieve saved settings from memory card".

But I cant help thinking that someone else must have gone through all this trouble before me.
 
Aha ! It can be done easily.

It appears that the STEP7 function "PLC > Copy RAM to ROM" can be used to save the "actual values" in the instance DBs to the "initial values".

I have just found this info on Simens' support site:
Entry ID: 14493983:
"In the SIMATIC Manager you can write a data block from the main memory into the load memory using the function "PLC > Copy RAM to ROM". In this way, parameters changed in this data block are available again, e.g. even after power OFF/ON.
For transferring parameters from a DB without PC/PG with STEP 7, for example through OP operation, into the load memory, you can use the system function SFC 84 "WRIT_DBL" in CPUs with Micro Memory Card (MMC) etc..."

STEP7 online help says basically nothing about what "PLC > Copy RAM to ROM" does:
"This menu command copies the contents of the RAM of the active module to the ROM area (only modules which support this function)"

I hope I have understood this correct.
But I still have a couple of questions:

Question 1: Does this work with all types of memory cards (not just MMC cards) ?

Question 2. Does the function SFC 84 "WRIT_DBL" only work with MMC cards ?
The technote seems to indicate MMC only, whereas STEP7 online help seems to indicate any memory card.
 
Hello !
I'm not sure about your 1. question but you can copy RAM-ROM if you have a eg. flash memory card.(don't think it works with RAM-card)
You use this function R-R like in the old S5 where you had to burn an Eeprom to get the program stored.
I always use this function after you have tested the program and adjusted all the values after that you do the R-R transfer and your program is safe even if the battery fails.

When you do this thing the PLC will stop !
 
S7 actual to initial

Do I correct understand, that I must apply command "PLC->RAM to ROM" for saving actual values of DB to initial value of DB? Can I copy only Data Block that I want copy?
 
COPY RAM TO ROM only works with MMC cards.

It will copy the "actual" vals into "initial" vals for ALL DBs.
You cannot choose which DBs. Its all or nothing.
 
*sigh*

OK, there is no easy solution to this problem. I guess that it is an oversight by Siemens.
I use an approach like the one mentioned by nif. But it is much more involved (because of the initial/actual feature that S5 doesnt have).

Here goes:

1. In STEP7 drag the online DB and drop it into the offline project.

2. In STEP7 generate the source file for the DB.

3. In Excel:
- Open the DB source file as a delimited file. Specify TAB and SPACE as delimiters.
- Locate the INITAL values between the rows STRUCT and END_STRUCT.
- Locate the ACTUAL values between the rows BEGIN and END_DATA_BLOCK.
- Copy all the fields that contain ACTUAL into the fields that contain INITIAL (this may require some care to put the values into the right place, also it is possible that the INITIAL fields have to be created first).
Save the file with "Save As", accept the format "Tab delimited .txt". Close the file and choose "No" when prompted to save with special formatting.

4. Open the DB source file in STEP7. Choose "compile". Check that no errors are reported by the compiler.

5. Open the DB blocks file in STEP7.
Check that everything looks OK.

viola - the DBs initial values have now been put to the actual values :geek:

IF ANYBODY HAS AN EASIER WAY TO DO THIS, PLEASE LET ME KNOW :confused:
 
Going a little sideways on this topic,

but recently talking to Siemens support they informed me that the initial values are as useful as an elevator in an outhouse. They are only used once the first time they are downloaded, they discussed the copy ram-rom feature with me, but did explain that it was not very useful in this context as it wasn't that straightforward. Best to utilise Retentive features in HWConfig and write to DB.

Cheers

Mylo
 
It "only" happens when a program update is sent on a flashcard or when a defective CPU is replaced (using the existing flashcard in the new CPU), or when the battery isnt replaced in time, or in many other situations where you would like to keep the "good" values from commisioning, not the values you were dreaming up while programming offline.
 
Copy online values to Step 7 initial values

With S7XP you copy online values to Step 7 initial values in 7 steps. Check te webpage and the demo video files. Very easy to use, no difficulty with source compiling and replacing variables.
 

Similar Topics

This may seem like a basic question, but for some reason I have having real trouble deciphering the built in help content, as well as navigating...
Replies
3
Views
5,318
Hi Does the instance data block get updated as the FB is being processed, or does the FB use the local data then update the instance DB at the end...
Replies
2
Views
3,845
Exposing shades of “newbie”…. I haven’t used arrays much, and I think using one for multi-zone temperature control is probably the solution I...
Replies
12
Views
770
Hello, PLCS.net guys. I'm learning about MSG for TCP communication recently. I'm trying to use CIP Generic. And the main flow is like the one...
Replies
6
Views
1,144
Is there any way to use a tag value in the Instance Name field? I would like to have an array of strings with my module names that I can loop...
Replies
2
Views
908
Back
Top Bottom