LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stopping producer consumer loop at the same time

In my application I am using producer consumer architecture. In the producer loop, I am acquiring data, processing and outputting the result (feedback control system). Also in the same producer loop I am inputting all the data to a queue and then in the consumer loop I am writing data to a file. I have a stop control on the front panel and error from the queue and  error from the data acquisition all wired to OR gate to stop the while loop. ( I attached the picture of the code). Whenever I press stop form the front panel program wont completely stop. I think it is because consumer loop still running. Is there way to stop  the both loops at the same time. I tried creating local variable but it slows the program. Front panel stop control mechanical action is set to switch when released.
0 Kudos
Message 1 of 4
(2,860 Views)

In the consumer loop you should check the error after the Read Queue function.

 

TOn

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 2 of 4
(2,855 Views)
On a completely unrelated note, this is one of those VI's which would be a prime candidate for 8.6's cleanup tool.  Also, I would suggest you invest in some SubVI's, particularly the section that uses about 15 math primitives.

0 Kudos
Message 3 of 4
(2,835 Views)

Hey suni,

 

Your problem has a very simple fix. Basically, your consumer loop is never stopping because you are wiring a non-error to the stop. You should wire the error to the stop AFTER the dequeue elements vi instead of before. The dequeue elements vi will throw an error when you hit stop, which is meant to stop the consumer loop. However, in your vi, you never see that error, as you are probing the wire in the wrong spot. You can cehck the producer/consumer example if this doesn't make sense.

 

Hope this helps!!

Chris Van Horn
Applications Engineer
Message 4 of 4
(2,782 Views)