LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

cluster to array question

What is the easiest & most efficient way to take a cluster of U16 numbers and dump

these into an array so that I can perform calculations on each of the elements of the array?

 

Thanks

0 Kudos
Message 1 of 13
(3,900 Views)

Uncluster.png

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 2 of 13
(3,834 Views)

Well, there is the simple "Cluster To Array" function.  Though, I would also question the use of the cluster in the first place based on how you want to use the data in it.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 13
(3,877 Views)

What do you mean by "Perform Calculations"?  If you are going to convert a Cluster to an Array, then all of the elements have to be the same type, say, for the sake of this discussion, Dbl.  Do you want to add a constant to the Array?  You can add a constant to a Cluster.  Do you want to add another array of the same "type" to your array?  You can add another Cluster of the same Type (use a TypeDef to insure this) to your Cluster.

 

It is a little more difficult, but you can even do things based on the position of the Elements in your Cluster and the number of Elements therein.  For example, if you want to use a numeric method to set to 0 the third element in a Cluster of 5 elements, create a Cluster "Constant" all of whose elements except the third is 1, with the third being 0.  Multiplying your Cluster by this "Zero-third-element" Cluster will zero the third element.

 

Arrays need not apply in these cases.  What operation(s) did you have in mind?

 

Bob Schor

Message 4 of 13
(3,866 Views)

You can perform most operations on the cluster directly, no need to convert to an array.  You need to be more specific on what you actually want to do with the data from the cluster.

Message 5 of 13
(3,850 Views)

I am sending commands to a device and reading TCP data.


Without getting into a lot of details, that data is 128 channels that is hexidecimal, little endian two compliment,.
and I want to display all 128 channels of data on the front panel (16 channels per indicator).

 

In my attached VI I am showng the raw data in these indicators but really want to show the calculated values.
I had set the clusters for analog data up for U16 data types but converted these over to I16  data types.

The calculations that I want to perform on each channel of data is to convert to 2's compliment and then multiple
that number by 3.3569335975 (adc bit value) and then subtract a correction factor of 1000.

 

I know that my VI is over complicated and can be done much simpler but with the time crunch that I have, there may not be enough time to rewrite the whole thing.

 

Not sure if I need the CH1 - Ch128 in the Analog data cluster to be data types I16 in order to do 2's compliment (signed data vaues)
but when I converted these over from U16, the following errors occurred but I am not sure why:

 

cluster2array error.jpg

 

 

0 Kudos
Message 6 of 13
(3,767 Views)

All of the data in your cluster must be of the same type.

 

But looking at your code, I don't see a reason for the cluster.  You could just have the TCP Read read X*2 bytes (X being the number of elements in your array) and then use Unflatten From String to straight to your array of I16.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 13
(3,754 Views)

Why are thre so many inner type defs?

0 Kudos
Message 8 of 13
(3,752 Views)

Since all your inner elements are of the same basic type, you could possibly just typecast the cluster to an I16 array. See if that works.

 

Message 9 of 13
(3,745 Views)
Re: cluster to array question
 

Why are thre so many inner type defs?

 

 

 

 

Probably because I don't know what I am doing...

0 Kudos
Message 10 of 13
(3,716 Views)