S7 Array Question

JIMCON

Member
Join Date
Sep 2005
Location
SWEDEN
Posts
124
moz-screenshot.jpg
I have a question about Arrays in S7.

Issue:

I have an ARRAY[1..10,1..2] of REAL


When MyTRigger = 1 i want to put in a new value in the top of the array and put out an value u the end aof the array. (Overwrite the last value with the second last value)

How do I solve this the smartest way ?
 
Yes I think its two dimensional..
hmmm.. it is two columns of values when i select Data view.

A shift real ? That sound like someting.. how do i do that..
 
The array you have defined will occupy one contiguous block of memory. As far as I can remember the order of elements on this block will be [1,1], [1,2], [2,1], [2,2] ... [10,1], [10,2]. So you will have 20 DBDs (for example) with these indices. If we assume that the array is located in DB1 starting at address DBD24, then you need to output DB1.DBD100, move (DB1.DBD24 thru DB1.DBD96) to (DB1.DBD28 thru DB1.DBD100), and bring the new value in to DB1.DBD24, in that order.

The inputing and outputing should be simple enough (load and transfer) and the move can be done using a BLKMOV. I've a vague memory from somewhere that the 'from' and 'to' areas of a BLKMOV can't overlap, so you may need to do two moves: first out to a temporary area and then back in from there to the array.

The only other alternative is to abandon the array and treat the list of 20 elements as a table. You can then use FC90 to manipulate the contents of the table. Despite its name, Word Shift Register, FC90 can be parameterised to be used with different data types including REALs. Here the whole operation of inputting a new value and shifting the other 19 values up the table by one location is handled in a single FC.

Regards

Ken
 

Similar Topics

Hello, When you want compare values of an array to a range of numbers is it a right way to do that? FUNCTION ADD VAR_IN_OUT A:ARRAY[1..50]...
Replies
5
Views
2,094
Hi all, I'm trying to access a variable address in a shift register. I have used BSL with an array DINT[20]. Now I wan't to access...
Replies
4
Views
1,538
Hi all, I am using RSLogix5000 version 7 to modify a program on a 1756-L1 controller. We have installed 5 more drives on a conveyor system. The...
Replies
2
Views
2,700
** EDIT - UPDATE ** ** After a bit of searching on here I've found an excellent example from LD... so I think I can utilise that to get...
Replies
3
Views
1,733
Hello, I need some ideas on how to sort an array. I have 3 1d arrays in a udt with a length of 101. Lets call them XAxis[0-100],YAxis[0-100],and...
Replies
3
Views
5,232
Back
Top Bottom