Step 7: Indexing to Specific Word within a DB

Beggar

Member
Join Date
Mar 2005
Location
California
Posts
47
I'm writing a Rate-of-Change routine that uses the WSR function within Step 7 to progressively fill a data block. I then use the two extrema to calculate the rate of change.

My problem is that early in the acquisition cycle, the upper words in the DB are 0, so I don't want to use them in my calculation. I'm using a counter to keep track of where in the DB is the first non-zero data point but I don't know how to grab the value.

Is there a means by which I can use an index (the value from my counter) to grab the value of a specific word within a data block (for example, word #4)?

Once the data block is full, it's not a problem for I just use the first and last words. For the first part of each cycle, though, I need to use only the first word and whichever is the highest populated word.
 
Hello!
There is a thing called indirect accessing in the siemens help files. There you will find an example of what you are looking for.

You must write a pointer to acces the value, was it 20 bit long or longer Hmmm?
 
Thanks, I'll look into that. Does it essentially function as do pointers and indirect addressing in C++?

The data are 16 bit words.

This is running in a 315 CPU
 
Last edited:
Beggar

Don't get too hung up on using pointers. These are for true indirect addressing. If all you want is indexed addressing then you can certainly have an address of the format DB20.DBW[Index]

"Index" should be declared as a double-word variable, then you just load the appropriate value in to it. So let's say you use MD60 as "Index", just stick a value in to MD60 and hey presto, you can either have DBW[MD60] or DBW[Index]. Or of course if you want to reference bytes or reals or other datasizes in the datablock, just use DBB[Index] or DBD[Index] etc.

regards

Ken
 

Similar Topics

Help!! From reading previous threads, I know that the best way to index an array is using SCL. I have the SCL editor, I'm just not sure where to...
Replies
3
Views
4,236
I am having a step7 v5.4 program where the blocks are encrypted and locked. And the manufacturer is stopped the support. Is there any ways to...
Replies
2
Views
170
Good Morning, Hoping someone with some Siemens experience can give me a hand with this one. Customer has a S7-200 cpu, which has a 6GK7...
Replies
0
Views
243
HI! HOW COULD I OBTAIN THE NAMES OF THE STEPS OF A ROUTINE IN SFC LANGUAGE IN STUDIO5000? Or is there a system variable that gives me those...
Replies
0
Views
339
I'm just trying to figure out the right method of adding a DO card to an existing rack. It's not the *next* open slot, but I have to move the AO...
Replies
5
Views
544
Back
Top Bottom