LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Propagate data point to multiple consumers? I'm probably overcomplicating this.

Solved!
Go to solution

Please see the attached screencap.

 

The DAQ assistant in the first case structure is taking a lot of measurements from a local cDAQ chassis.  One of those data points (#15) needs to be extracted (hence the select signals) and then merged with the signals from three remote (ethernet connected) chassis.

 

The issue that I'm having is that the data point, due to the fact that the chassis and consumers aren't running in any specific order or sync, sometimes just isn't there when the consumer loops run and it reads a 0 rather than the value.  This causes the test stand to think it lost hydraulic pressure and call for a shutdown.

 

I'm aware someone will tell me to wire the error from each DAQ assistant to the next, but that creates a massive 6.5 second loop time, which is unacceptable.  The chassis have to remain independent to keep execution time down.

 

I'm looking for a way to 'catch' that #15 data point and hold it for the consumers to use until the next iteration where it is replaced with the new value.  I'm not sure if Collector is what I'm looking for, or some sort of data copy, or a register.  If this was a PLC I'd know what to do with it.

 

Thanks in advance.

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 1 of 13
(4,011 Views)

As I see you are using LV in a wrong way. Why don't you run the DAQ tasks in independent while loops? You could use the same Queue, and you can add time stamps to every data package (or also a label to show the source) created in the several Producer loops. In your single Consumer loop you can just decide what to do with the data depending on the label (save to File,etc...).

 

Other big problem: do not use DAQ Assistant! It is OK for quick testing, but not for real application! These Express VIs initializes and closes your hardware at EVERY while loop iteration.

You should use proper DAQmx VIs: initialize your HW resources BEFORE the while loop, do your DAQ inside the loop, and close HW components when you stop the application.

There are many examples shipped with LabVIEW, have a look how to use DAQmx VIs. Also, this way you avoid the silly dynamic data wires...Much easier to live with Double arrays 🙂

Message 2 of 13
(4,007 Views)

I'm afraid a rewrite isn't possible at this stage of the game.

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 3 of 13
(3,996 Views)
Solution
Accepted by topic author Ralph@NES

You need a shift register around your while loop (right-click the border of the while loop). This provides a way to save a value from one iteration of a loop to the next iteration. When you successfully read a new value, use that; when you don't, use the value from the shift register.

Message 4 of 13
(3,982 Views)

Will the shift register retain it for more than one iteration or no?

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 5 of 13
(3,969 Views)

blokk,

 

I noticed that there's an option if you right click the DAQ assistant to 'generate DAQmx code'.  I made a piece of sample code (Simple 4 channel thermocouple) and invoked that, it created the three key elements in the attached photo: The subVI which has all the channel creation, the DAQmx read, and then the stop task.  I put it in a while loop and it seemed to work.  Is that what you're talking about?

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 6 of 13
(3,963 Views)

Ralph@NES wrote:

Will the shift register retain it for more than one iteration or no?


Please see the help for shift registers. You need a wire connected to the right side of the shift register inside the loop; that same value is then available on the left side of the shift register on the next loop iteration. The value is whatever you wired on the previous iteration (which could be the same value from the iteration before that).

0 Kudos
Message 7 of 13
(3,952 Views)

Ralph@NES wrote:

blokk,

 

 Is that what you're talking about?


Yes. That is what he was talking about. You don't want to initialize and close your hardware every iteration.

Message 8 of 13
(3,944 Views)

I've used the shift registers for single iteration before.  I suppose it's as simple as putting in some logic (maybe a >0 boolean) to either pick the current value or the registered value.  That's a good solution;  I don't know why I was thinking it needed to live longer than one interation.  As I suspected, I was overcomplicating it.

 

Thanks all.  I wish I could spread the solution around since I learned from many of you.

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 9 of 13
(3,938 Views)

I'm working farther into this, trying to convert my DAQ assistants into DAQmx items.

 

The issue I seem to be having is that I don't understand the difference between the data types;  All of my program is configured around dynamic data, and the result from the DAQmx read after I generate the code is 1d array of waveform.  Inserting a converter to turn it back into dynamic doesn't seem to work, and I'm not getting the correct data at the correct indicators anymore.

___________________________________________________________________
Still confused after 8 years.
0 Kudos
Message 10 of 13
(3,906 Views)