LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Notifiers/Queue to Start Parallel Loop

Hi all! 

 

I am developing a program that will read data from a cDAQ-9172 (8 thermocouples and 4 analog inputs (pressure transducers)).  After my original question on this forum I went with a producer/consumer architecture.  The attached program covers the producer and one of four consumers (there are 4 separate "tables" that the data is being read from, all will be identical setup, for simplicity I am just trying to get one functioning first).  Ideally this is what I am aiming for:

 

- Producer is constantly aquiring data at 1Hz for all lines.

- The data for each table is put into one of four queues (in the attached example I only did the one table, therefore one queue)

- The queue for each table (in the attached example only one) is sent to that tables case structure/while loop

- The producer loop also contains a switch for each table that is intended to activate it

- If the switch for a table is turned on, this "true" will be transported, via queue, to the case structure for that table

- the "true" signal activates the case structure, which activates the while loop contained within, which starts the acquisition process, some data manipulation, and finally, when the original "on" switch is turned off, and the "stop" button is pressed, the data is written to a file, and the case structure shuts down, awaiting the next time it gets the "on" signal.

 

My problem is with the activation of the case structures.  I cannot get the on/off queue to function properly.  If the switch is on when I run the program, the case structure activates, and if it is off, it does not.  No matter what I do once running, I cannot change the true/false value of the queue.

 

If you can have a look at that specific part of my program (the case structure activation), and let me know where I am erroring, that would be most appreciated!  I had tried using notifiers as well, with similar (failed) results.

 

Thanks all!

Brad

0 Kudos
Message 1 of 3
(2,819 Views)

You have a bit of a misunderstanding about how queues work and your general program structure.  You should not have the big while loop surrounding your two smaller loops; that's one part of the problem.  Your acquisition while loop never terminates because you have a constant wired to the stop condition, so the big overall loop only executes once (because it won't loop until all the inner loops finish, and that never happens).  As a result you only dequeue one element, and since you enqueue an element on every single iteration of the acquisition loop, only the first element gets dequeued, which is the initial state of your button.  If you run your code with execution highlighting turned on this will probably become a lot more clear.  You need to get rid of the outer while loop, move the dequeue and case structure into a while loop, and use a notifier rather than a queue if you're going to write to it every iteration.  Once you get that worked out you will still have some issues with the way you're passing data, since you'll continue to enqueue data even when your acquisition switch is off.  That data will slowly fill up memory, and then as soon as you turn the acquisition switch back on, you'll be reading old data (from the beginning of the queue) rather than the current data, which may not be what you want.

Message Edited by nathand on 04-01-2009 10:27 AM
Message 2 of 3
(2,810 Views)

Thanks very much for your reply.  I see exactly what you're saying about both the large while loop, as well as my use of queues.  I have now removed the while loop, put the case structure in a loop, and everything works to initiate.  However, as you predicted, I now have problems with shutting off the loop, as it is reading all that backed up data saying true. 

 

I think I might have some ideas on solving that one, so I will implement them and see what kind of success I have.  Best way to learn.  However, I may need some further assistance if I do not succeed.

 

Thanks for the help so far!

Brad

0 Kudos
Message 3 of 3
(2,794 Views)