12-13-2013 02:26 AM - edited 12-13-2013 02:26 AM
I have to program DAQ engine, which has the following requirements:
As you can think, I played days along with the DAQmx Read Property node. But if I set this:
Then I have to define an absolute offset, i.e. -200000. Then I can't read until my buffer is full. If I attempt to read before, I get an error -200277. It is fully plausible, but let's say, I wait 20 seconds to fill the buffer...
...once the buffer is full, and attempt to read all available samples (-1 input on the DAQmx Read VI), the buffer will be not empty after read. This setting only means, that there are always 200.000 samples available.
I haven't found any example under the esamples, and no solution in the forum.
regards
Madottati
Solved! Go to Solution.
12-13-2013 06:17 AM
@Madottati wrote:
I have to program DAQ engine, which has the following requirements:
- sample rate = 10kS/s
- buffer size = 200.000 Samples
- ... if 1 second of data is available, then read the last 10000 samples
- ... if I don't read a minute long, I want to be able to read the most recent 200.000 samples
- ... after a read, the buffer has to be empty, so that the next read returns only the new data - which haven't been read yet.
If you set your buffer size to 200, then you can't read 10000 samples. The buffer is overwritten when it gets full. And when you read everything in the buffer (DAQmx Read with count set to -1), the buffer is empty.
I think what you really want is to just leave the buffer size as the default and read everything when you do read. If you just want the last 200 samples, then use Array Subset to just get the last 200 samples.
12-13-2013 07:43 AM
I have written 200.000 (twohundred thousand) samples -> to hold 20 seconds of data.
I have tried the following scenarios, but none of them matches my requirements (in all cases I want to read all available samples, regardless of the number of available samples):
1.) This works only as long as the buffer is not full. This reads always the current number of samples acquired, i.e. 85235 samples, then the buffer will be empty. BUT if attempt to read read data after 20 seconds, I run into an error -200279 = "Attempted to read samples that are no longer available".
2.) This reads always the last recent 200000 samples. But there are two things:
a.) I can't read until at least 200000 smples are acquired.
b.) after reading the buffer is not empty. It is a "moving 200000 samples long window"
12-16-2013 04:53 PM - edited 12-16-2013 05:04 PM
You can modify those read properites while the task is running. Something like this should work:
You have to add a little extra time to your buffer (I went with 1 second)--if you try to read a sample that has been overwritten you'll get an error. If the amount of data you want is exactly the same as the buffer size it's almost certain that this will happen.
@Madottati wrote:
I have written 200.000 (twohundred thousand) samples -> to hold 20 seconds of data.
You probably already know this, but in many countries a period is used to denote a decimal point. Putting periods/commas in numbers other than to show a decimal can result in confusion on forums such as this.
Best Regards,
12-16-2013 05:00 PM - edited 12-16-2013 05:01 PM
12-17-2013 02:46 AM
Hi John,
thanks for your reply!
If I start the task with those settings according to your screenshot, I will get an error on the DAQmx Read.vi, if I don't call it 20 seconds long = when the buffer is full. In my software it is not determined, when to read. It depends on several events, when the read VI is called.
Madottati
12-17-2013 09:20 AM
It works for me, are you sure you are running the code exactly as written above? Allocating a bit of extra buffer space is necessary.
Best Regards,
12-18-2013 01:39 AM
No, I didn't run exactly the same code. But now I did it, and it is really working.
John, you are the champion! Thank you very much!