02-19-2021 08:54 AM
Hi all!
I'm trying to implement something with the following functions:
1. getting data from a ni usb device.(one channel at this time, but potentially more channels in the future)
2. getting data from a usb i2c device.
3. have both of the data(from daq and from i2c) go through low-pass filter, take average of them once every second, do some calculations with the 2 averaged number (between the 2 averaged number i get and with some other constants)
4. store and display everything on my computer.(2 averaged number, results from calculations)
5. using one of the results from step 4 to control my daq device to generate a voltage.
I'm constantly getting data from both devices and only calculating the average every second. The Queue Multiplexer example in this thread https://forums.ni.com/t5/LabVIEW/Multiple-producer-one-consumer/td-p/1385640 solves the multiple data sources problem. But it doesn't look possible to de-multiplex the data and process them in the data retrieval loop?
Any help is much appreciated! Thanks!
Solved! Go to Solution.
02-19-2021 09:02 AM - edited 02-19-2021 09:03 AM
Let your queue be a cluster with 2 elements. One element would be a string, or number, or something that is an identifier as to where the data is coming from. The other element is the actual data (whether a number or array, or whatever).
Bundle up the identifier with the data before putting into the queue. The consumer then dequeues, unbundles the identifier and the data and uses the identifier to determine how to process the data.
EDIT: Reading that linked thread further, I see Johnsold said exactly that in message #6.
02-19-2021 09:17 AM
In order for me to do that, what should I wire to the element data type node of the obtain queue block? Since I didn't find a cluster constant like a string or a number.
02-19-2021 09:18 AM
In order for me to do that, what should I wire to the element data type node of the obtain queue block? Since I didn't find a cluster constant like a string or a number.
02-19-2021 09:35 AM
@hiphip wrote:
In order for me to do that, what should I wire to the element data type node of the obtain queue block? Since I didn't find a cluster constant like a string or a number.
If you need to ask that question, then I suggest going back and redoing the LabVIEW tutorials.
1. Drop an empty cluster constant. (It's under Cluster, Class, & Variant)
2. Drop a numeric. I'd make it an integer. Drag it into the cluster constant. (If you want a text identifier, then use a string constant.)
3. Drop a numeric for your data. Drag it into the cluster constant.
4. Wire it to Obtain Queue.
02-19-2021 09:05 PM
I should have looked more carefully. Now that I have done that part, but if I just use the bundle&unbundle block, I can't tell between the three data sources. The unbundle block still plots 3 lines together.
If i use bundle by name&unbundle by name, there is no name for me to choose
what should I do next?
02-20-2021 08:02 AM - edited 02-20-2021 08:08 AM
That second image looks absolutely nothing like what I described to you!
Where is your identifier in the cluster?
The first image is closer, but I bet you failed to label the constants in the cluster you used to define type of data at Obtain Queue. (That part is cut off.)
Bundle and Unbundle by Name only work when you name the elements in your cluster.
Please reread what I said, and when you are done you'll have something that looks like this.