Shifting an Array Of Dints

FFL and FFU instructions do that.


I don't know if they work with DINTs though.

Okay. I will read through the instruction help to see. The move instruction is nice and simple but Im looking to expand the number of results considerably.
 
If you don't mind going in reverse order I'm pretty sure the COP instruction works

[cop]
[SOURCE: Station30CycleHistory[1] ]
[DEST: Station30CycleHistory[0] ]
[LENGTH: 10 ]
 
This will work
it moves the values up in the array
the problem with file copies is they start a index 0 and copy it to index 1
and 1 is copied to 2
starting at 0 over weighting the data before it's moved
the way I show starts at the top and indexes down
I have tested it with arrays of over 1000 and with used defined data types

File Shift.JPG
 
There is actually 2 different ways to shift DINT in a file.

Input trigger is some pulse.

Shift from Bottom of file to top, only need 1 copy statement
You would mov whatever number into the last word, then as you execute the copy statement, the value would move 1 spot up in file.

Shift from Top of file to bottom, you need 2 copy statement.
Mov a value into first word.

ShiftDint.PNG
 
There is actually 2 different ways to shift DINT in a file.

Input trigger is some pulse.

Shift from Bottom of file to top, only need 1 copy statement
You would mov whatever number into the last word, then as you execute the copy statement, the value would move 1 spot up in file.

Shift from Top of file to bottom, you need 2 copy statement.
Mov a value into first word.

I didn't realize how the copy instruction worked exactly. This makes alot of sense. Thanks for your help.
 
It can also be done with indices and a "circular" DINT array buffer.


The tradeoff is more efficient processing vs. more (and messier) code.


How big is the array?
 
The length of the array is subjective. I am going to start with 100. It is a cycle time history. I think it will be very confusing to our customer if it was backwards. So I will do the array with the two copies. I also changed things a little bit so I could use a SINT instead of a dint.
 

Similar Topics

Greetings, I am trying shift data in an array (such as Array[0] is shifted into Array[1], Array[1] is shifted into Array[2]......all...
Replies
10
Views
365
Hello Guys, I think I need to use SCL for the following task but am very weak using SCL in tia portal. I have results history data block. It is...
Replies
14
Views
3,052
Not sure if this is possible but thought I would put it out there. Using Rockwell Studio 5000, is it possible to shift the address of an array...
Replies
7
Views
2,130
Gents, Trying to shift and average 10 integer array values. First issue is shifting every value in the array forward one spot. 0..8 becomes...
Replies
5
Views
1,940
Hi, I am using RSLogix 5000 V19 and I am trying to figure out how to shift reals in an array. Currently, I setup a flip-flop that increments a...
Replies
19
Views
9,648
Back
Top Bottom