Clearing Large Data Structure

awaege

Member
Join Date
Jun 2019
Location
Appleton WI
Posts
10
I am currently working in RSLogix 5000. I have a large data structure with the following general structure:

UDT[0]
Dataset1​
Min​
Max​
Avg​
Data[90]​
Dataset2​
Min​
Max​
Avg​
Data[90]​
Dataset3​
... etc
UDT[1]
.... etc



Total there are 22 data-sets with the same structure and two UDT instances. One to store incoming data and one to analyze the previous data and store it.

After the data in UDT[0] is passed to UDT[1] I need to completely clear UDT[0] to prevent any lingering data to interfere with the calculations since the Data[90] may not always be completely filled.

I've been debating the best way to go about this. Using FLL instructions seems like it might work but with the current structure I would need many FLL insturctions to do the job.

Does anyone have any advice on how this might be most efficiently accomplished?
 
To pass for UDT[0] to UDT[1] I just use a COP instruction. My hope was to avoid using a blank UDT since this would create a third instance of an already massive structure in an application where I am very tight on memory. That is my backup plan though.
 
If dataset was an array you could create a logic loop with a pointer and loop thru all 22 indexes inside udt[0] to clear with three CLR and 1 FLL using indirect addressing.
If dataset isn't an option to be an array then nevermind ��
 
90 elements is not massive. If you are really so tight that 90 elements makes a difference you might need to re-evaluate the hardware. A loop or FFL is the only other way.
 
Unless you turn your dataset into an array of dataset[22] you can't do didly about iterating it without brute forcing the dataset1, dataset2 etc.
 
Create a new Instance of the Array and set up your new initialization values (0 if that's what you want) then make it constant.

Otherwise you have COP or FLL instructions.


Regards

Daniel.
 
90 elements is not massive. If you are really so tight that 90 elements makes a difference you might need to re-evaluate the hardware. A loop or FFL is the only other way.

No 90 elements is not massive. However the entire structure contains about 500 instances of [90] arrays of 32 bit reals and there are currently three instances of the structure making my current memory use at approximately 500,000 bytes or about 25% of a 1769-L33ER CompactLogix 5370's capacity which is what this will be running on.
 
...in an application where I am very tight on memory. That is my backup plan though.

...my current memory use at approximately 500,000 bytes or about 25% of a 1769-L33ER CompactLogix 5370's capacity which is what this will be running on.

I'm not following, you have plenty of memory, where else are you eating memory? Complex data structures will consume the bulk of a processor's memory. The actual programming logic won't have nearly the impact.

You've hit an area of compromise due to the data structure that is in place. As others have said simply using a COP to copy and empty UDT into the destination UDT is the easiest logic solution. But if you are concerned about memory, then alternating your programming approach is required.

I would consider creating a blank instance of a single dataset structure to minimize the overall hit on memory, then brute force the clearing

Code:
// EmptyDataset as UDT[#].Dataset structure


UDT[0].Dataset1 := EmptyDataset
UDT[0].Dataset2 := EmptyDataset
UDT[0].Dataset3 := EmptyDataset
.
.
.
UDT[0].Dataset22 := EmptyDataset
 
I'm not following, you have plenty of memory, where else are you eating memory? Complex data structures will consume the bulk of a processor's memory. The actual programming logic won't have nearly the impact.

The issue here is that this is being done on a controller that already has about 65-70% of memory used. I argued that it would make much more sense to push everything into a SQL database and not do large data collection and analysis inside a PLC! But the powers that be can't seem to understand that and I am forced to go this route. (n)

I will probably just go with the brute force approach. I don't think anything else is going to work here. Thanks for the input.
 
Another consideration, change the UDT[#].Dataset to an array as well.

UDT[#].Dataset[#] rather than the Dataset1, Dataset2. Gives you more options such as iteration or FLL on UDT[0].Dataset[0]
 
Yes I am going to do that as well. Makes much more sense in retrospect.

One more tag of the UDT set to all zeroes (constant tag so it can't be changed), I don't think is going to break the bank.

Then COP it to the UDT you want to clear. Better still, use CPS.
 
Last edited:
Can be done in one instruction:
FLL 0 UDT[0] 1 will clear whole UDT[0]
FLL 0 UDT[0] 5 will clear UDT[0] to UDT[4] - all in one instruction
COP UDT[1] UDT[2] will copy all members of UDT[1] to UDT[2]
 

Similar Topics

I'm online with a 90-30 using PAC ME 9.8 No one has gotten online with this PLC for many years and the the I/O fault table has a total of 1209...
Replies
6
Views
2,964
Using an L81 - I have the arrangement below that will try the Ethernet Radio first and if that fails use the Cellular Radio. The Failover works...
Replies
16
Views
3,335
Since this is the most helpful place on earth for us programmers, I'm back with another one. Using Logix v32 I've got an array with 100 elements...
Replies
9
Views
2,949
Hey guys, I'm still pretty new to PLC's in general. For a program on RSLogix 500 with a micro1400 and pvp400, we are currently logging data for...
Replies
9
Views
2,801
Say i have an Array[100] and i want to clear words [5]-[60] for example. How can i do that in the PLC without putting in a bunch of CLR commands...
Replies
5
Views
1,564
Back
Top Bottom