LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

queue vs notifer what approach to use

Hello All

I am new and learning about labview and am trying to put together a simple datalogger which scales the collected data and displays on the  screen several different averages based on different time periods (i.e 10 sec, 20 sec, 30 sec avgs) of the channels being sampled.
I attached something that does the trick but I have no clue if I have followed any best practices or if I am setting myself up for a problem later on.
Any comments or suggestions would be much appreciated.

Marco

0 Kudos
Message 1 of 8
(3,514 Views)

I cannot look at your code at this time because I do not have LabVIEW installed on this PC.

However, if you are using a Producer / Consumer with Data architecture, then you should use a Queue to pass data from your producer loop to your consumer loop.  Otherwise, you (may) will look data if you consumer loop is not able to process your data faster than the producer can obtain it.

I can look at the code later today or during the weekend, but I'm sure many will have a look at it as well.

R

0 Kudos
Message 2 of 8
(3,507 Views)
The general comment above is correct for a producer-consumer loop. You have this, but I would suggest considering a slightly different architecture to take advantage of your operation. Your individual while loops that are displaying the 10, 20, 30, and 40 second averages are all the same exact code. This screams being a subVI. If you make this subVI reentrant, then you can instantiate it multiple times in your main loop and get the same thing you're doing now. This would eliminate the need for a notifier or a queue.

Also, you should have a STOP button on the front panel to stop the loop. You are currently relying on the Abort button in the toolbar to stop the VI. Doing so never gets you to closing the DAQmx task.
Message 3 of 8
(3,489 Views)

Just looked at the code.  I totally agree with smercurio. 

The first place to start is to convert those loops into a single sub-vi (1 of the loops).  Make the sub-vi re-entrant.

R

Message 4 of 8
(3,482 Views)
smercurio

Thankyou for your response. I know I have duplicate code, but I do not know how to create sub-vi which are re-entrant.  Also I do not understand (grasp) yet how the wiring diagram would look like without the notifiers. I would hazard to guess notifiers are resource expensive so avoiding them would be cool. Would it be possible to provide an example based on my code?

Marco
0 Kudos
Message 5 of 8
(3,475 Views)

Have a look at the attached sub-vi.  It is unmodified from your current code and should be an easy replacement.

It is called "sub-vi.vi", so change it to an appropriate name.

It is set as re-entrant.

R

 

0 Kudos
Message 6 of 8
(3,460 Views)
I had a look at the sub-vi and see some of what is needed, but it still uses notifiers and it was mentioned that it could be done without notifiers or queues. Would it be possible to have an explanation on how that could be done or is a notifier the best way to do this?

Thanks in advance

Marco
0 Kudos
Message 7 of 8
(3,455 Views)

You asked for an example of a sub-vi that was based on your code, which is what I did.  

Now, you would like to change the code (and sub-vi) to implement what smercurio suggested...  It would be better if you attempted the change and learned from doing so.. 

Let us know if you are having trouble... but at least try to do the implementation..   It is a good learning exercise 🙂

R

0 Kudos
Message 8 of 8
(3,435 Views)