Followers 0

CLX World of Arrays

18 posts in this topic

Using Logix 5000, I've created a couple of experimental arrays, but run into snags with each approach. I need to be able to place a process value (an integer usually <500) into an array and have it correspond to a time-stamp. My time-stamp data is the WallClockTime Day*10000 + the Hour*100 + the Minute (right now is 60823). Twice per minute means 2880 sampes per day. Thirty-one day maximum month means another array dimension is 31. Two corresponding pieces of data in each "pocket" (i.e. Day 6, Sample 960, then the data and time-stamp). I need help understanding how to dimension the array and increment the COP Instruction. I did it with a two-dimensional array, but the whole point of this is to sort the array by the DAILY data values (the process variable taken every 30 seconds), then go to the value in the cell 2823rd in order, and therein will be the 98th percentile of the process value for each day. Using the two-dimensional array, the sort causes me to lose track of when in the day the data was taken (in fact, I lose track of the day, too!). One fix would be a two-dimensional array per day, but that is the easy, inelegant way out. Any help?? Hope everyone has a nice weekend. Bill

Share on other sites
I had a similar problem with sorting arrays. What I ended up doing was creating a compound number. I had a 1 dimensional array of DINTs. The last 16 bits (bits 16-31) hold the number you want to sort by, and the first 16 bits (0-15) hold the data that is associated with the sorting number. Looks like in your case, bits 16-31 will hold your process value, then 0-15 will hold the day. This will allow you to sort the array and keep the relation between the data and the day. To assemble the compound number, take the sorting value, multiply it by 65536, then add it to the day value. Now, to get the values back out, you need to divide by 65536 to get the sorting value, and modulo by 65536 to get the day value. Also, I have a question for you: How well does the PLC handle sorting that 2880 size array? Edited by pandersen

Share on other sites
Wow! I was just sitting here considering the "one-dimension" idea and you lay it in my lap. Thanks! First time I ran the sort it faulted the processor on Watch Dog, which was set at 500ms. I doubled the time and it ran fine. The time is not an issue in this case because this processor is dedicated to collecting and manipulating data for our various reports. Thanks again, I'm going to try the single dimension isea. Bill

Share on other sites
Can you spread the sort across several scans? That will solve the watchdog problem.

Share on other sites
Yes, I can. And I will if my final version results in a huge sort such as that.

Share on other sites
I know you have what you want. But.... Just had to throw this out there. What you are doing would be a very simple task for a data historian and a reporting package. At first glance the historian may seem more expensive, but if you consider all the development time you're investing, it may be cheaper. Just a thought. Ken

Share on other sites
That was our first thought, Ken. Problem is, Scada trends this value WAY more frequently than we need (even twice per minute is overkill), and we wound up manipulating nearly three-fourths of a million samples. That is why we elected to try this approach. Bill

Share on other sites
Can't you set up a slow polling rate? On the historian I use now I have rates of: 1,5,15,& 60 seconds, plus 5,15, & 60 minutes. And even the older historians could go to 60 seconds or more.

Share on other sites
You guys are making this much more difficult than it has to be. I don't see a problem. Use an insertion sort to insert 1 entry every 30 seconds. This should be quick. Use a UDT to define a data type with value and time. Use a one dimensional array of UDTs. I would use a more compact indexing scheme. The one you suggest will use a lot of memory. i:=(((Day*HoursPerDay+Hour)*MinutesPerHour+Minute)*ReadingsPerMinute)+Reading;

Share on other sites
Interesting input, Peter. I'm going to play with that approach a bit. Thanks! Bill

Share on other sites
Not sure what you are doing with the data... but would it be better to use a OPC and log them to an Excel sheet? then you can keep that data off of the PLC I did something similar in a SLC and AD... (keeping the data in the PLC) but it was smaller... I used a timer to run the data, my sample was needed every 2mins, so I ran a timer every 2 min, then use this timer (the ACC) to run my logic, it worked good as I set up a CDM and was able to see the data logged into the array and move down the array... I had math involved so I was able to debug it much easier Just a thought...

Share on other sites
Yep. Just another good reason to finally take some action on my oft-repeated words that "we need to get this data "thing" centralized and streamlined . . .". SQL Server may be in our not-too-distant future. There simply has to be a better way to handle the endlessly increasing volumes of data we must store and manipulate to suit the regulatory agencies. Bill

Share on other sites
I've created a UDT called CFE. Within it are the two pieces of info defined as "Turb" & "Time". I created the array of CFE's, and I've written data to them. So far, so good. Problem appears when I try to sort. Regardless what I put in the "Array" field of the SRT instruction, I get a syntax error. Most popular is "Operand not an array element". This happens even if I drill-down to populate the field. Is there a trick to sorting UDT's? Thanks, Bill

Share on other sites
Use only the value field for comparing but move the whole UDT.

Share on other sites
I am working on this again and continue to have trouble with the sort instruction. Regardless how I try to express the Array, I get the error "Operand 0: Invalid array subscript specifier". Can anyone tell from my screen shot what I should be putting in that field? The intent is to sort on the Turb value. A small section of the array is above the troublesome instruction. Thank you! Bill

Share on other sites
Roger all that, Paul, and thanks. This requirement, as it turns out, has stimulated significant action on the I.T. side of the house. We will soon use an external database solution. My requirement is now, and while I can resort to the two-dimensional array per day, I would REALLY like to know why the array pictured in my most recent post causes the SRT instruction to puke. May have to call Rockwell tomorrow. Bill

Share on other sites
I haven't used this instruction, but it looks like your array, which is one-dimensional, should be addressed as: CFE_One_Day[0]. As far as the dimension, that's either a 0 or 1, not sure how the array is set up, probably the 0 is OK.