08-08-2017 11:54 AM - edited 08-08-2017 11:57 AM
What is the difference between the following two attached vi's
Integrate_ProducerConsumer.vi and Integrate_ProducerConsumer2.vi
The first one, works fine with DAQ and does not throw the DAQ error 200279. However the second one does.
Both use the same cDAQModuleSetup.vi and other than some extra file operations, I do not see any difference.
Look for the "Producer Loop DAQ"
08-08-2017 01:13 PM
You are working on the very hairy edge and the extra code being implemented in the top loop is causing just enough delay that it forces you to fall behind in the DAQ loop.
1. Remove the delay from the DAQ and the logging loops. They have other things that are limiting the loop rates (the DAQ sampling w/ #3 and the queues having data available).
2. Remove the constant from the DAQmx Timing for the Number of Sample Per Channel. That is just limiting your buffer to 1 sample causing any extra delay in the read process to throw an error.
3. In your DAQ Read loop, set the DAQmx Read to be Multiple Channels, Single Sample, 1D Array DBL. This will eliminate a coercion and essentially sets the loop rate to match your DAQ sample clock (loop will not iterate until a sample is read, assuming you also removed the wait from the loop).
It is also typically a bad idea to have a single loop read multiple queues due to synchronization issues. I would recommend logging based on the DAQ and just use the latest values from the serial port by using a Tag Channel. Channels are an asynchronous wire that can be used to pass data between loops. The tag will allow you to use the latest value. Just look up channels in the LabVIEW help for more details.
08-08-2017 01:39 PM
A few more comments:
You have a boolean control: "LOGGING START" - do you intend for the user to press this button over the course of running the program? Just so you know, the value is read at the beginning and put into an input tunnel of your loop, so it will have that value forever, even if the user changes it later. Maybe this was already your intention, just wanted to let you know in case not.
Why is cDAQModuleSetup reentrant? It looks like you have a hardcoded reference to a specific device, so I'm not sure why you would want to run more than one instance of this VI in parallel - is there something I'm missing?