Clearing Array of UDTs

JankyPLC

Member
Join Date
Sep 2016
Location
WI
Posts
46
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 who's data type are a UDT I created which contains Strings, Dints, and Bools.
I'd like to clear all of the data in this array, but every example I can find online is to populate a value through an array, not a UDT to an array of UDTs.

Obviously the tried and true index loop with a Null Ary CPS is on the table, but is there a cleaner way of accomplishing this?

Thanks in advance!
 
The FLL instruction?


Hopes UDTs are treated the same a (control?) structures.


Took me about five tries to get the forum software to put that in caps.
 
Last edited:
Create a tag similar to your udt with empty data (same structure), and copy it 100 times to your array.
You can also zero the first manually, then copy to the remaining elements. This is my preferred way since there's no guarantee (without checking) that the 'zero' UDT is in the initial state.
 
Last edited:
alawys Leave UDTTagname(0) empty then you can just mov UDTTagName[0] to UDTTagname[#]. write a little increment logic to increase the # every scan cycle and have it just self clear. 100 element array will take 99 cycles.
 
Create a tag similar to your udt with empty data (same structure), and copy it 100 times to your array.
This is my preferred method. Then just one CPS/COP to clear the whole 100 elements of the original array.
 
alawys Leave UDTTagname(0) empty then you can just mov UDTTagName[0] to UDTTagname[#]. write a little increment logic to increase the # every scan cycle and have it just self clear. 100 element array will take 99 cycles.

You cannot use MOV with structured tags, you can only use MOV with SINT INT DINT or REAL sources and destinations. Data conversion from one type to another happens automatically.
 
This is my preferred method. Then just one CPS/COP to clear the whole 100 elements of the original array.

I would always use CPS over COP if the data is shared with another device, like an HMI or SCADA system, or even another controller as a produced tag.

COP can be interrupted, mid-processing, by the System Overhead Time Slice, or any other task which has higher priority, this means that your "data-set" can become fragmented, half old, half new, data. CPS overcomes that potential problem.
 

Similar Topics

Hello all, I'm working on my first project with an Allen Bradley Micro 810 using the connected components workbench. Everything is going well so...
Replies
2
Views
3,132
I have a bit array about 1000 in length. Now I need to clear about 100 in the middle of it. The FLL instruction doesn't work with bits and I'm not...
Replies
6
Views
2,568
Good morning, quick question, is there a simple way of clearing an entire Boolean Array in RSLogix 5000, short of unlatching each element...
Replies
3
Views
2,209
I have a udt made up of a few dint and stings. I built an array using this udt and I'm looking to figure out how to set all the dints in the array...
Replies
9
Views
2,816
Is there's an easy way to clear an array of bits without having to use indirect addressing/looping of some sort. My ControlLogix tag is...
Replies
2
Views
2,581
Back
Top Bottom