From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Compare elements of two or more clusters

Hello,
I am very new to labview and was hoping someone could help me with this. I am taking user input (motor #, size of steps, number of steps and sequence #) and storing all the data (for each motor) in a cluster.

(Now this is where I need help..)
I want to take the 4th element of each cluster (the sequence #) and sort it in order (1,2,3,4...). Based on the sequence number I want to use a flat sequence structure to send the commands to my motor controller in the right order.

Any help in solving this problem would be appreciated,
Regards,
Mridu
0 Kudos
Message 1 of 14
(4,274 Views)

mnanda98 wrote:  Based on the sequence number I want to use a flat sequence structure to send the commands to my motor controller in the right order.

No you don't.  You want to use a FOR loop with autoindexing tunnel.  First of all, you will want your sequence number to be the first item.  Then you have an array of motor clusters.  You can then just use Sort 1D Array to get the order correct.  Then you autoindex on that array with your FOR loop to send the commands.


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 2 of 14
(4,261 Views)
Thank you for your response. I am a little confused what you mean by array of motor clusters?
0 Kudos
Message 3 of 14
(4,253 Views)

Maybe this will clear it up...


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 4 of 14
(4,223 Views)

The reason Crossrulz said to put the Sequence # first in your Cluster is because sorting starts with the first element, then the second, etc.  If, however, you require that the Sequence number be, say, the third element, you can still sort it by using a trick (only do this if the array of clusters isn't huge) -- create a temporary cluster whose first element is the Sequence # and whose remaining element is the entire cluster.  An array of these things will sort on the first element.  Once sorted, take the Cluster apart and return only the second element, your original Cluster, now sorted.  [I hope that was clear ...]

 

Bob Schor

Message 5 of 14
(4,145 Views)

Hello, thank you both for your help - that makes more sense now. Crossrulz, I was trying to replicate your example but was not able to find what you used on your block diagram? How should I proceed from here? Any help would be appreciated, thank you.

0 Kudos
Message 6 of 14
(4,115 Views)

Nevermind - I figured it out! Thank you all for your help

0 Kudos
Message 7 of 14
(4,111 Views)

Hi sorry one more question.. Now I am trying to use my cluster inputs instead of wiring the constants and am very stuck. Here is what I have so far..

0 Kudos
Message 8 of 14
(4,088 Views)

Try posting your VI rather than an image - especially an image of your message.  It is much easier for us to debug a VI than an image.

 

Lynn

0 Kudos
Message 9 of 14
(4,068 Views)

My mistake, I posted it in a hurry.. Here is the attached vi:

0 Kudos
Message 10 of 14
(4,054 Views)