Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Attempted to read samples that are no longer available

Hi,
 
I am using NI-6251  on Windows 7.
 
I use the DAQ Assistant to sample three channels at 200KHz rate and "continously" mode. The "Samples to read" is 60KHz..
 
After runing 60 seconds, I got the following error message: "Attempted to read samples that are no longer available. The requested sample was previously available, but has since been overwritten."
 
Even I increase the "Samples to read" to 150KHz, it shows the same error also. 
 
What I need to do to make this work at 300k sampling rate?
 
My Vi is attached
 
 
0 Kudos
Message 1 of 15
(5,617 Views)

Jaseon,

 

I think you forgot to attach your VI. There is some documentation on the issue in this knowledgebase but the general issue is that you need to read samples faster than you currently are. If you post your VI we can look at it and make suggestions.

 

You might also consider using an example program (Help » Find Examples) in LabVIEW. There are good example programs there of continuous acquisition.

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 2 of 15
(5,613 Views)

It is attached.

0 Kudos
Message 3 of 15
(5,610 Views)

Basically what is happening is that the loop rate can't keep up with your acquisition rate. I'm guessing the program runs for a short duration and then will eventually throw the error. The problem is that you can't write samples to disk at the same rate that you are acquiring samples. This eventually overflows the buffer that DAQmx is writing samples to.

 

There are ways around this. You should look at implementing a producer / consumer architecture in your code such that you acquire data continuously in one loop and then feed that data into a queue and then in anther loop you pull data out of the queue and write it to disk.

 

There is an example of streaming to disk that you can also reference.

 

I think a large part of the issue is that you are writing to two separate files and this takes time.

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 4 of 15
(5,599 Views)

Your problem is the writing to disk is slowing down your loop.  Look into the Producer/Consumer.  What this will do is put your DAQ and File I/O into two different loops.  You use a queue to pass the DAQ data from the DAQ loop (producer) to the File I/O loop (consumer).


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
0 Kudos
Message 5 of 15
(5,598 Views)

Thank you.

 

But the queue only works for 1-dimentional array. How could it works for n-dimentional array?

0 Kudos
Message 6 of 15
(5,532 Views)

Your queue is whatever data type you wire into the Obtain Queue VI as the Element Data Type.

2 dimension queue.png

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 7 of 15
(5,519 Views)

I used your method, but it did not work. The data I collected is not the input data.

 

My Vi is attached.

0 Kudos
Message 8 of 15
(5,516 Views)

You have 2D array going into your Obtain Queue, but it was the wrong data type, it was I32 instead of Double, I changed it, but you could do the same by clicking on the 2D array constand and selecting Representation and then selecting Double.

 

change representation.png

 

For some reason I can't attach the VI right now, but just make the change as I described and you should have a 2D array of Double values as your queue elements.

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 9 of 15
(5,512 Views)

Thank you. Your method works good. But the sampling rate is fixed at 10Hz, while I set a 20kHz sampling rate in the DAQmx.

 

What's wrong with that?

Download All
0 Kudos
Message 10 of 15
(5,507 Views)