Shifting an array (Ratcheting?)

HoldenC

Member
Join Date
Sep 2012
Location
Cumberland, KY
Posts
220
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 the way to Array[11].

I found a post by Ron Beaufort explaining how to accomplish this, but I cant seem to make it work. When i run the logic, all of the data turns to zero.
1709143204155.png

The tag "Press_Downtime" is an UDT, and has an array size of 11 (0-10).
The tag "Press_Downtime_Temp" is the same UDT with an array size of 11 (0-10).
The tag "Press_Downtime_Empty" is a single instance of the UDT that has all zeros in the data.

Would anyone be able to tell me where my mistake lies ?

Thanks.
 
What triggers the COPies? If it is unconditional, you're going to shift shift the data through in 10 scans, clearing it out. You should probably use a oneshot to trigger that rung so it only happens one scan.
 
I use a tag that identifies when the machine is down to trigger that rung. I was thinking the COP instructions would only execute 1 time.

Adding the ONS fixed it.

Thanks.
 
Could that be shortened if you first shifted 10 to 11, then 9 to 10 then 8 to 9, and ripple it up the numbers. that would eliminate the 'temp' step.
Nah never mind, you got this right.
 
If it's ok to reverse the order of the array (newest data in element 9 instead of 0) you can use a single COP instruction:
Source Press_Downtime[1]
Destination Press_Downtime[0]
Length 11
Then store the new data in Press_Downtime[10]
 
If it's ok to reverse the order of the array (newest data in element 9 instead of 0) you can use a single COP instruction:
Source Press_Downtime[1]
Destination Press_Downtime[0]
Length 11
Then store the new data in Press_Downtime[10]
I was just thinking about that. if a COP copies one element at a time (i.e. 0 to1 then 1 to 2) then the value at element 0 will just ripple through all of the elements. I don't think COP was intended to use the same element in both operands. It's easy enough to verify. I'll have to try that.
 
It makes sense that would behave that way, but you go to agree that's a little less intuitive. You would have to remember to add new values at the bottom element each time purely because of how the instruction functions.

Need a FILO instruction here. Or poke and pop :)
 
Agreed. It's not the best in every situation but I encountered a time or 2 with certain HMIs that it made more sense.

Edit:
I don't remember the reason as it's been a while, but it seemed like a good one at the time...
 

Similar Topics

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,054
Hey guys, What do you suggest for doing a shift of dints within an array like this? Thanks, Kevin
Replies
12
Views
2,592
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,941
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