03-12-2009 05:12 PM
This seems like a very basic problem that should have a very simple common solution.
Thanks,
Joel03-12-2009 09:18 PM
The error is caused because you are overwritting your buffer during your acquisition (possibly because of the time it's taking for you to write the data into a file). During a continuous, buffered acquisition, the buffer should be monitored to ensure the data is not overwritten. In DAQmx, a DAQmx Read Property Node must be used to obtain the amount of data remaining in the buffer. Use the property Status » Available Samples Per Channel to monitor this. If the value continuously increases during the acquisition, decrease the sampling rate, increase the buffer size, or increase the number of samples per channel to read.
In LabVIEW, we usually place the acquired data in a queue in one thread and have another thread that reads data from the queue and writes it into the file. You could possibly implement this Producer/Consumer architecture in your application.
03-13-2009 11:21 AM
Where in the program would I do a DAQmx Read Property Node to see whats remaining in the buffer?
03-19-2009 10:25 AM
Hi Jgolden,
Adnan is right in saying that you are probably overwriting your buffer. To utilize that DAQmx Read Property Node, you would want to place the DAQmxGetReadAvailSampPerChan function right before your DAQmReadAnalogF64 to see what's remaining in the buffer. Let me know if this works for you or if you have more questions!
03-20-2009 10:34 AM
I have a couple things I can try now, but it sure would go faster if there were an example somewhere.
Does anyone know of a sample program that shows how to acquire and save data? This seems like a very routine program that everyone (but me) knows how to do, so there should be something somewhere. It should be part of the NI sample programs. I've seen the programs that acquire and display, and I think there are a couple that show how to save a file, but I couldnt find any that do both at the same time. I'm curious to see how the program is set up, and if it can acquire greater than 60kHz on 4 channels without an error, which is my problem.
Joel
03-23-2009 05:13 PM
Hi Jgolden,
I noticed that this thread is the same as THIS one- lets try to keep this on one thread from now on (you can choose which one). The information that CharlesD gave you is really good- and he's right about those examples. You'll want to go to the CVI Example Finder and go to Optimizing Applications»Multithreading. It sounds like you're going to need a producer/consumer type of settup because if you're trying to save to a file as you are reading data in, your processing is going to limit your input rate. As Charles said as well, you're card is spec'd to do 1MS/s for your channels (cummulative), so I don't think that you're going to have a problem doing 60kHz. I would take a look at the example BuffNoDataLoss.cws- which demonstrates using queues. Though this example doesn't do the saving as well, you should be able to combine it with one of the other examples that saves data (simply save the data that is being read from the queue to a file).
Another example that you might find helpful is found in the Example Finder under Fundamentals»File Input and Output »arrayfile.cws . That example generates a waveform and saves it to file- which could be closer to what you're looking for.
Because it doesn't look like there's an example that going to do exactly what you want, I would recommend posting your code to NI Community when you're done, so that users who come across this in the future have a helpful resource!