11-30-2012 01:11 PM
I want to create a strategy to sort data into "Buckets'. The immediate need is that I will have a user select a few different analog output channels and I want to sort these out by card. So a list of
Card1_ao1
Card1_ao2
Card3_ao1
Card2_ao5
card1_ao5
card2_ao4
card3_ao4
would become
Card1=ao1,ao2,ao5
Card2=ao4,ao5
Card3=ao1,ao4
Basically I am going through a 2d array and creating a bucket based on the first value, and throwing and sorting out any duplicates into it in the form of a 1D array with a name.
What is the best way to acomplish the task above if the different buckets may be different length arrays? Am I best off using a local variable, a cluster or what? If a cluster is the way to go, does anyone have a good link to a way to programmatically change and bundle by name? I have to think there is a pretty simple way of doing what I want to do. If I were in matlab which is where a mechanical engineer I learned to program I would just declare a variable "Card1" as an array and add to it. If card #2 comes along and I don't have any variable set I would declare a card #2 array and so on. How do I best do this in Labview?
11-30-2012 01:26 PM
A Cluster of 1D arrays is the easiest way to simulate a "Ragged 2D Array" in LabVIEW. See Darrens nugget here
11-30-2012 01:30 PM
I would use an array of clusters. Each cluster would contain a string and an array.
The string would contain the name of a card. The array would contain the names of the channels on that card.
The overall array is so that you can have an unspecified number of cards.
See attached LV12 file.
11-30-2012 01:37 PM
Thanks for the quick replies, I have a meeting shortly but will see if I can either get this to work today or if not on monday. RavensFan, thanks for sending the vi. however is it possible for you to send that in a 2011 version or at least a picture?
Thanks,
Adam
11-30-2012 01:44 PM
in 2011
11-30-2012 01:58 PM
Thanks Jeff,
I don't have much time to play with this one anymore today so will have to get back to it on monday. None the less that looks about what I want the finished display to look like, the challenge now is taking in an array where Collumn #1=card# and Collumn#2=ao# and then turning it into the output that you showed there. I took a look at the Darren's occasional nugget and I think between the two of those I should be able to figure it out, however I am out of time for today. If anyone has any more to add or there is even a piece of out there that I can work off of that would be appreaciated otherwise it looks like you guys gave me a good enough start but I am out of time.
Thanks,
02-26-2013 11:51 AM
HI, i have been following this post and i was wondering if it is possible that once the sorting has been done according to buckets,can a signal be sent to a comm port from labview and also is it possible to make it more interactive. For example, i want to input data and sort it by buckets and then sent a particular signal to a port according to the bucket that has just been selected.
02-26-2013 11:51 AM
HI, i have been following this post and i was wondering if it is possible that once the sorting has been done according to buckets,can a signal be sent to a comm port from labview and also is it possible to make it more interactive. For example, i want to input data and sort it by buckets and then sent a particular signal to a port according to the bucket that has just been selected.
02-26-2013 12:05 PM
Of course you can. You are the programmer so just about anything is possible according to your imagination. You just need to program it to do what you want.
02-26-2013 12:17 PM
how can i achieve? should i simply modify the vi sent previously on the same discussion? btw i am a beginner, ive only started using labview since a week now