LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Loop resetting and losing data

I'm using a USB-6218 and Labview version 10.0.1 to monitor data from 3 pressure sensors. The VI is designed to send a couple of analog output signals to trigger events when I push a button and also start recording data to a file. I'm recording at 25 kHz.

 

Issue 1: Everything is working great EXCEPT that the loop appears to reset or maybe reinitiallize every 26 seconds. Honestly, I'm not even certain how to say this.

 

This isn't actually a problem most of the time, I generally only record data for about 3 seconds (it's an explosion). The problem arises when I start recording near the 26 second reset event. If I happen to record over that loop I lose portions (or all) of my actual data. When I do capture this event while recording the timer goes negative and the data stays approximately constant (attached Wackydata). You can see at 2 seconds (line ~50K) the time suddenly shifts to -17 seconds. Again, as long as I don't start recording near the 26 second reset this doesn't happen.

 

For what it's worth the graphs aren't terribly important. I use those as a visual aid to verify that things are happening. I do all the post processing of the data in another program, I just need to record the numbers consistently.

 

Issue 2: While I'm here... the timing also seems to be a little wonky when I hit record. Sometimes when I record the data I hear the explosion and see the instrument response almost simultaneously. Sometimes it takes over a second, I hear it, wait a second (or more) and then see the response on the graph. Why would that be?

 

Labview code attached.

Download All
0 Kudos
Message 1 of 2
(2,249 Views)

I'd recommend you move your File Writing off to a separate parallel loop  You pass the data by way of a queue in what is known as a producer/consumer architecture.  It may be a situation that the writing to the file has slowed down the loop.  You haven't lost data because it is still in the DAQmx buffer, but perhaps it takes a second to get the data out of the buffer and displayed due to delays in the file writing.

 

Are you sure you aren't getting any errors?  Why don't you have Automatic Error handling enabled in the Execution properties of the VI?  Enable automatic error handling, and/or put an error indicator on your Express VI's.  I wouldn't be surprised if you are getting a buffer overflow.  If it takes too long for your data to be written to the file for the loop to iterate again to service the DAQmx buffer, you may be filling up the buffer.  But you don't know it because you aren't doing anything to display errors.  Maybe the -17 second timestamp is a symptom of bad data in the buffer.  I think you've definitely lost data because the timestamp doesn't return until about line 52524.  That is 2500 lines later, or 0.1 seconds worth of data, one iteration of your while loop.  But when the timestamp appears good again, 4+ seconds have passed by.

 

Producer/Consumer!  Don't do file writing in you DAQ loop.

0 Kudos
Message 2 of 2
(2,239 Views)