03-17-2010 02:09 PM
I am wanting to build a 1D array where two values are assigned to each dimension. For example:
Index 0 would have a 1 and 4 assigned to it
Index 1 would have a 2 and 3 assigned to it
Index 2 would have a 0 and 1 assigned to it.
Then I can unbundle this arrayand grab the two values for index 0, index 1, etc.... I want to put this array inside a typedef control. Is this possible?
Solved! Go to Solution.
03-17-2010 02:11 PM
Use an array of clusters. In other words, the element of the array is a cluster, and that cluster contains two numeric controls. Think of the cluster as a "shell" for the numbers.
To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.
03-17-2010 02:13 PM
I don't understand your terminology of 2 values assigned to 1 dimension.
Since you also talk about unbundle, I guess you know something about clusters.
It sounds like you have want to have a 1-D array of clusters, and each cluster consists of two numeric values.
The other possibility is that you really want a 2-D array.
You can put pretty much anything in a typedef control.
Since I'm not really sure what you are asking for or what it is you want to do, it would be best if you posted a VI that has this data structure in it that you want.
03-17-2010 02:49 PM
Thanks for the replies. I considered using a cluster and had the typedef control modified to include the cluster. I may just go back to this method if this is the simplest for the code I am modifiing.
A 2D array assigns two values i.e. row and column to one number. I need it the other way around.
Here is what I am trying to do. I need to control a rotary valve. I am using compact filedpoint to control the rotary valve. The valve requires a pulse (1 then 0) for the rotary valve to move 1 position. If the valve is on channel 1 of the fieldpoint module and I want it to turn to position 2, the I send two pulses to channel 1.
My thinking is I will have two values associated per rotary valve... a channel and a pulse value. So for example, valve 0 has a Boolean and a numeric value assigned to it in an array. Although, it doesn't have to be a boolean and a numeric. it could be 2 numeric values for simplicity.
I hope this makes sense because without knowing this posting a VI or image is useless. Its the chicken before the egg thing. 🙂
03-17-2010 04:43 PM
What is the meaning of index 0 vs. 1, vs. 2? What is the meaning of the 1 and 4 for index 0? Of 2 and 3 for index 1? ....
It could certainly be a 2-D array. The row index would be equivalent of your current 0, 1, 2 indices. The column index would be the equivalent of whether you want 1 or 4, or 2 vs. 3.
It is all just a matter of how you want to extract your data out of the data structure and pass it to your other functions, whether it is Fieldpoint, DAQmx, a front panel, a text file, .... If it is a 2-d Array, you can use index array, to get a row, a column, or a specific element at a row and column. If it is a cluster, you can use index array to get your row, and unbundle to the the first or second item out of the cluster element.
Which data structure is the best to use really depends on what you are trying to do with the data. Do you want two numbers? Do you want a boolean and a number? You'll have to figure out which is the best for your application.