Step7 - Is there an easy way to create large DBs?

RMA

Member
Join Date
Sep 2004
Location
North of Hamburg, Germany
Posts
2,052
I need to derive the concentration of a caustic soda solution. This is done using a rather complicated polynomial calculation using input and output temperature of the distillation towers. From a cycle time point of view, as well as the fact that I don't have SCL available, I decided the easiest way to handle this would be to use a look-up table using S7Guy's version of FC103 (Search for "CDT FC103" to find the relevant Thread).

The only problem is that to get the required accuracy, I need 500 entries in the table. In itself that's not too much of a problem, I've already worked out the values in Excel, so once I've created the DB, I can export it to Excel and then paste in the values - but how do I create the DB in the first place? I don't fancy creating it a line at a time 500 times!

Does anybody know if there's an easy way to create such large DBs?
 
You can generate the DB in the program. I should have an example of this a bit later, bit pushed for time at the mo.

I'll add that later if no-one else has come in before hand.

Edit, just read you post again.

Do it by using UDT's, build 1 UDT which can be a mixture of other UDT's if you like splitting it down into sections, then in your DB create an array of 500 of your main UDT type.
 
Last edited:
Thanks Peter, I'ld completely forgotten that you can create DBs on the fly. Still leaves the question of how to populate it though. I sippose if the worst comes to the worst I let the program run once to create the DBs and then poulate them off-line.

Cheers

Roy
 
In our current project we have DB's upto 60K long, the only problem you have is that you cannot open this DB and look at all the on-line data, it only allows about 40K I think.


To see data you would have to play with VAT tables or perhaps set up a second DB with just one of the UDT's and have a little program to populate it with one of the data from the main DB, that way you can look at data out of the normal range.
 
Roy

Are all the data-types identical? If so, would a single-dimension ARRAY[1..500] OF REAL array be the quickest? Create the DB in that fashion, then generate a source from it. I'm nowhere near a STEP7 PC at present, but I seem to think a created source from a DB includes not just the declarations, but also an assignment section where each element is set to the default for that data type. Or am I imagining something else? Anyway, you could then hack that with a text editor or Excel to create alternative names or values and then re-compile.

(All the usual disclaimers about not knowing what I'm talking about etc... apply)

Ken
 
Since the table is based on the input and output temperature of the distillation towers, could a two dimensional array do the trick?

In the declaration this only takes two lines:
Array_declaration_view.jpg


Switching to dataview gives you the means to enter all individual values:
Array_data_view.jpg


Kind regards,
 
Yes, all the values are of the same type and I had actually thought of using/creating an array, but for some reason I thought the maximum length of an array was 255 and wasn't sure what would happen if I stuck two arrays one behind another.

Must go and check what the maximum length is - if I can define 500 entries then the problem is solved.

Thanks a lot guys!
 
You can use an array

A good idea is to use an array. Say you have 500 INTs you want to save, then you use "ARRAY[0..500]" and INT in the next line. If you have more than one value for each record you can use an array with a UDT.
In your program you can build up a pointer that increments each scan, and with offset to the first record in the DB etc...
Use this to point to the correct byte in the DB.


edit: Sorry, you were too quick for me...
 
Last edited:
If you're using Excel then why not just create the source code for the DB in Excel, save it as text and then import the text to a source code file and then compile it in Step 7 and hey presto a DB generated with values from the spreadsheet.

Just another note, you could populate the look-up table using the polynomial in OB100 as this OB can take as long as it likes to run.
What does the polynomial look like ?
 
Last edited:
If you're using Excel then why not just create the source code for the DB in Excel, save it as text and then import the text to a source code file and then compile it in Step 7 and hey presto a DB generated with values from the spreadsheet.
Effectively that's exactly what I want to do, but since I don't like working with text sources (I'm not enough of a programmer for that) I prefer to generate the DB first and then let Step7 create the source code for me to export to Excel.

Now that I've got everything already existing in Excel, there's not really a lot of point in going back and running the polynomial in OB100, although that would certainly be a possibility, since the DB only needs to be created once.
 
Just another thought, I'm using OB35 to run my controllers every 100 ms. Am I right in thinking that the interrupt can occur in the middle of an executing FC? I assume it must, otherwise the 100 ms timing would not be accurate enough if it waited until a big FB or FC had finished executing. Does this mean I need to save AR1 and AR2 at the start of OB35 and restore them at the end of it, or does the Step7 operating system look after this OK?
 
RMA said:
Just another thought, I'm using OB35 to run my controllers every 100 ms. Am I right in thinking that the interrupt can occur in the middle of an executing FC? I assume it must, otherwise the 100 ms timing would not be accurate enough if it waited until a big FB or FC had finished executing. Does this mean I need to save AR1 and AR2 at the start of OB35 and restore them at the end of it, or does the Step7 operating system look after this OK?


If its the same as S5, it would wait until the end of the current block.

This could still effect AR2 as the block could be a stat in another block.


So its an array then
 

Similar Topics

or should that be how difficult? We've been asked to quote for a small project (control of 3 compressors. There's not a lot of IO and the control...
Replies
12
Views
4,177
This is the first time I am working with Simatic Manager Step7 as I started my siemens journey with TIA which is pretty easy and do a lot of stuff...
Replies
3
Views
117
When you download a DB, the values get overwritten by what is in the "actual" column in offline DB. Does this happen at the start of the PLC...
Replies
6
Views
139
Hello Inside a FB, I´m trying to transfer a string from a DB to a IN_OUT var that was define as a UDT. The problem is that i can´t determine the...
Replies
4
Views
125
Hi all, I am trying to convert RSLogix 5000 program to Step7. I need to bit shift left my array of double integers for tracking the product on...
Replies
2
Views
519
Back
Top Bottom