LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Producer/consumer or master/slave with multiple data sources?

Solved!
Go to solution

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!

 

0 Kudos
Message 1 of 7
(1,761 Views)

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.

0 Kudos
Message 2 of 7
(1,758 Views)

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.

0 Kudos
Message 3 of 7
(1,739 Views)

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.

0 Kudos
Message 4 of 7
(1,737 Views)

@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.

0 Kudos
Message 5 of 7
(1,726 Views)

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.

1.png

 

If i use bundle by name&unbundle by name, there is no name for me to choose 

2.png

 

what should I do next?

 

 

0 Kudos
Message 6 of 7
(1,682 Views)
Solution
Accepted by topic author hiphip

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.

 

0 Kudos
Message 7 of 7
(1,670 Views)