LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Buffering Errors with Express VI

Hi all,

 

I'm having an issue that deals with error code 200279 in LabVIEW 2014.  I am using a cDAQ Ethernet chassis to gather strain and displacement (voltage) data, via the DAQ Assistant Express VI. My goal is to be able to collect and write data to a file over the course of multiple hours.
 
My current code seems to do what I want, but when logging data for extended periods of time, I start to see a lag in my data displayed to the front panel, followed by the 200279 error ("Attempted to read samples that are no longer available").
 
I am fairly sure that this must be an issue with buffer size/sampling rate, or with computation speeds and loop timing etc. However, I have tried a number of different recommended fixes, such as adjusting the sample rate and buffer size, and none seem to alleviate my problem.  I am curious if using the DAQ Assistant Express VI is hampering my ability to tweak the code.  I have also noticed that the error arises in my Express VI that collects Voltage data.  This VI feeds into a For Loop, could this for loop be slowing me down to the point the code crashes?
 
What I need to be able to do, is sample data and then write that data to a file at anywhere between 2 and 10 Hz. I currently only control this rate by adjusting the "Buffer Size" and "Collection Rate"  input values on my code (attached).  I have only been able to manipulate the values by setting the Number of Samples ("Buffer Size") to a certain percentage of my Sample Rate ("Collection Rate") -- for example, 250 buffer size with a sampling rate of 1000 gives me a 4 Hz upload rate.
 
If I increase either value, I must adjust the next to keep my upload rates (rate at which I display on the front panel/write to file) the same, this is the issue I am having that seems to get in the way of fixing the 200279 Error. I am not sure if the Express VI is the culprit.  For logging data, I used to write to Excel via the "Write to Measurement File" Express VI, but this caused the same problem.  By switching to TDMS, I alleviated this a little bit, but still, after 45 minutes or so, the 200279 error arises.
 
Any help would be much appreciated!  I have attached my current code, as well as the image below.
 
 
 
Illustration.JPG
 
 

 

0 Kudos
Message 1 of 4
(2,952 Views)

I'll be honest:  once I see you have code going from right to left, I stop looking too seriously at the code itself.  This is a habit you want to break, now.  It makes your code harder to read.  It also will hinder you as you get used to the idea of data flow.

 

Your general question is "are my loops taking too much time"?  The short answer is yes.  The error you're getting means the buffer has been overwritten.  This means you're not processing the data fast enough.

 

You could try to fix this by leaving the world of the Express VI and use actual DAQmx code.  But, I challenge you to open a new VI by going to File -> New ((NOT New VI)).  There's a template for Producer/Consumer.  Look over that code and try to understand it.

 

You'll see two loops.  The top loop is a producer loop.  In your application, you'll want this to be your DAQ Assistant.  You'll read data and immediately enqueue it.  By doing this, you'll avoid the issue you're having where you're overwriting the buffer on your cDAQ.

 

The bottom loop is a consumer loop.  The dequeue call has three different states that cause it to act differently:

1)  The queue exists, but there isn't any data.  In this state, it sits and waits for something to be in the queue. 

2)  The queue exists and has data.  In this state, the dequeue immediately pulls the data out and sends it as an output to wherever you wire it.

3)  The queue doesn't exist.  It outputs an error.

 

You can use knowing how those states work to put all of your processing into the lower loop.  If you handle everything well, you won't run into the same issues you're seeing now.

 

And again, stop going right to left.  Your code should ONLY go left to right.  If you're feeling the code is expanding too far to make the code messy with scrolling, then you should be looking at subVIs.  You shouldn't be making things worse by breaking other style rules while still requiring a scroll.

0 Kudos
Message 2 of 4
(2,918 Views)

Thanks for such a thorough response!  The concept seems simple enough, adjusting the code from what I have to the new outline will be the funky part.  Do you expect that I should be able to more or less reallocate my existing code between the two new loops?

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

hatchling,

 

As natasftw mentioned, you really should leave the world of express VIs and use actual DAQmx code.  There are several examples available in the LabVIEW example finder that are a great place to get started.  To answer your question, it looks like you could keep the bulk of your code the same and still impliment a producer and consumer loop.  I can't see all of your code, but what I see could be put into this style. You should keep in mind that the producer loop should be strictly obtaining data via the DAQ Assistant, while the consumer loop does all of the calculations.  In terms of the block diagram, this means that your consumer loop will look much larger than your producer loop.

 

Here is a document that should help you get started:

 

https://decibel.ni.com/content/docs/DOC-2431

 

0 Kudos
Message 4 of 4
(2,853 Views)