Ratcheting String Arrays in RSLogix5K

mrchris76

Lifetime Supporting Member
Join Date
Jun 2014
Location
Lake Oswego, OR
Posts
15
History:
On my production line there is a section that will store the finished product in case the unload section goes down or is unable to keep up. I was tasked with tracking the product throughout the production line and to track the glass that was accumulated in this section I used ratcheting (----COP----COP-----MOV, this is explained on this site in another thread http://www.plctalk.net/qanda/showthread.php?p=360425&postcount=1 ) to fill/empty a group of arrays with the data that I was tracking. This worked fine since I needed a FILO type of system. I used the a GSV to get the time that the product hit the line and used the day, hour, min and sec as the product ID. This all worked fine since I was using DINT's for all of the data I was tracking.

We now want to use a variable to track the month in the product ID.
A=January, B=February, C=March....

Again I was able to track the product through most of the production line by turning the DINT's into a concatenated string. The problem I am having is that I can't use my ratcheting function on the accumulator section of the line since I can't used the COP or MOV function blocks for the STRING data type.

Some ideas I have are to just add another variable on the GUI that will house the month variable and place it in front of the DINT for the rest of the data. This does not seem like an elegant way of accomplishing this. I tried to use the CONCAT function (String 1 concatenated with a blank string that got moved into a another string, pseudo move function for STRING data type) in place of the MOV and COP functions but it didn't work because I could not get the data to ratchet properly. Does anyone have any ideas on how I can accomplish my task?

Thanks in advance,

Chris
 
Define all the information you need to track for a product in a UDT. Keep all the data as standard types within the UDT, no need for tricky concatenations. You can create an array of these easily. A single COPy will move one or a whole group at once.
 
I tried to using the UDT as Bernie suggested and it is not ratcheting the data. I think I am not setting up the COP commands correctly. My UDT has 5 pieces of data and I put it into an array with the dim of 20 (ACCUM_FILO). I am grabbing the initial data from the section before the accumulator (ACCUM_FILO_HOLD) and placing that into my ratcheting arrays. The data will start the ratcheting on the first toggle but on the second toggle the data does not move into the next register. When I set up the length I did not know if I was just supposed to use the length of each UDT in the array(5) or the total length of the array(20) or the product of the dimensions of the array and the UDT (100). I tried each and I could not get it to work. I have attached screenshots of what I had before and what I changed it to. Can you please let me know what I am doing wrong?

Thanks,

Chris

accum_Logic1.jpg accum_logic2.jpg
 
if you use the copy, data must be entered backwards to shift. That is to say if your array is 0-100 then put your new data in 100 and copy array[1] to array[0] for a length of 100. This will copy all data from 1-100 and paste data in 0-99 that way you just shifted your data by 1 position.

if you copy array[0] to array[1] for length 100 you will fill array with data from array[0].
 
if your going to use multiple copies for a length of 1 then you must manually copy in reverse.
copy 99 to 100 then copy 98 to 99 , 97 to 98.

Hard for me to see you image.
 
I always use another array to shift because I've found data can get stepped on.

dim data [100] of myUDT
dim tempdata[100] of myUDT

COP data[0] tempdata[0] 100
COP tempdata[0] data[1] 99
or
COP tempdata[1] data[0] 99
 
I just finished a similar project for an alarm logger. I put a date/time stamp together with the alarm message as a string and then make a 50 alarm rolling history which is displayed on the HMI. This way you don't have to store everything in a temporary array.

As a side note if you go out of bounds on the array reference while doing this the processor will major fault so you want to be careful if it is being tested on a running machine.

This is how I did my ratcheting each time there is a new alarm:

//Index1 = element you are copying from.
//Index2 = element you are copying to.
//Msg_Count = loop count
//Logger = String array where messages are stored.
//move each message down the list to make room for the new one.

for Msg_Count := 0 to 49 by 1 do
Index1:= (49 - Msg_Count);
Index2:= (50 - Msg_Count);
cop (Logger[Index1],Logger[Index2],1);
end_for;
 
History:
We now want to use a variable to track the month in the product ID.
A=January, B=February, C=March....

Why?

Can't you use numeric 1-12 for the month in the product ID...

either way, you've been given two methods for "ratcheting" the data....

1. Use COP to shift the data.... Note that you have to have the data stored "backwards", a COP progressing forwards (element n to element n+1 will fill the array with the contents of element 0), but a COP backwards (eg. n+1 to n) will shift the data successfully, and your new data goes into the highest element location. It's only a different way of looking at it.

2. Use a temporary array... COP out, then COP back into the source data, but shifted one location.

In either case, if your data is being accessed by a HMI, SCADA, or other system, then you should rally use CPS instead of COP, that way you will ensure your data-set is not fragmented when it is accessed externally....
 
@Daba you are correct I can just use the numeric value of the month. I thought that a 10 digit number would fault out my processor but in reality the 2.1 billion max value of the DINT will encompass the 1.2 billion value that my GSV will spit out ie.December 10th at 10:56am and 58 seconds will give me a DINT of 1,210,105,658. I over thought the solution. Probably under thought the solution. Thank you to everyone for your help
 

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
337
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
77
As the title says, I'm using CCW with a PV800 (and Micro850). I've made a scheduler in which a user can choose a month, day (1-31), hour (0-23)...
Replies
15
Views
454
Hello, So i managed to read the string coming from control logix and put a string display in PanelView 800. Now I am struggling to do the other...
Replies
1
Views
115
Does anyone know why my one string is displaying this way? It is causing issues with my HMI displaying it.
Replies
4
Views
241
Back
Top Bottom