LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stop value not enqueued before exiting while loop

Hi, i am relatively new to Labview and encountered behavior in my first project that i don't quite understand. 

 

I have two loop that sort of act like "producer" and "consumer". As long as i connect a measuring device everything works as expected.

If no device is connected however, the second loop doesn't properly exit, because the boolean value generated by the "Stop" button doesn't seem to be enqueued.

If anyone has any insight i would be gratefull as i can't seem to find the cause through normal debugging means.

 

mschmelz_1-1756373885431.png

 

 

0 Kudos
Message 1 of 4
(97 Views)

What debugging did you do? Did you use execution highlighting? Do that and you will find the error.

 

 

Spoiler
Create Task or Start Task return an error. Then the enqueue after that does not happen. The lower loop only stops when the boolean is false. It will always "dequeue" a default value, which means false for booleans.

 

Why do you need two loops? The lower loop can just be incorporated into the upper one.

There is no need to pass the whole cluster back and forth between the loops. Currently, the loops operate in lockstep and there is no parallel execution (mostly, one loop could potentially execute multiple times).

 

If you want to keep two loops, get rid of the queue and create a new one with a boolean and a double. Enqueue in the producer, dequeue in the consumer. Build the array any way you like: shift register or auto-indexing loop tunnel.

 

Some more suggestions:

- leave unchanged cluster elements unwired

- use DAQmx logging

- wait until next ms multiple is not necessary, the loop execution is controlled by DAQmx and dequeue (although it mitigates the race condition in this case)

 

 

Message 2 of 4
(77 Views)

Your Enqueue value will get an Error In from the DAQ function and not execute.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 4
(61 Views)

I completely agree that the second loop is unnecessary. I would go so far as to say most of this code is unnecessary.

1. Instead of having waits in your code, use the hardware timing of the DAQ. This will be a lot more consistent sampling and allow you to grab a lot more samples at once.

2. You can use the DAQmx Configure Logging function to log the data for you.

 

Those two alone eliminate 95% of the right side of your diagram. I highly recommend you go into the Example Finder (Help->Find Examples) and look for the Voltage - Continuous Input.vi. Leave the triggering as "No Trigger" and everything else will do exactly what you are trying to do.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 4
(54 Views)