08-28-2025 04:46 AM
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.
08-28-2025 05:42 AM
What debugging did you do? Did you use execution highlighting? Do that and you will find the error.
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)
08-28-2025 06:04 AM
Your Enqueue value will get an Error In from the DAQ function and not execute.
08-28-2025 06:23 AM
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.