07-16-2014 10:03 AM
I'm using MATLAB to read data from the NI USB-6218. I do know for sure that it is reading data correctly.
I can read 1000 samples of data in 0.22 seconds. It takes 50.32 seconds to read 5000 data points. For 10,000 it's 126.74 seconds. I'm storing all of these data into one matrix.
Is it possible that the device is defective, or is it my code? I also posted a thread on MATLAB's forum asking if it's just the language that's slowing it down.
Here's my code:
ai = analoginput('nidaq','Dev2'); ai0 = addchannel(ai, 0); ai.SampleRate = 1000; start(ai); pause(.2); for i = 0:1:1000 ai_value = getsample(ai) end % Clean up delete(ai);
Again, the code works, and I'm 100% sure it's reading everyting correctly. It just gets slower and slower as more data comes in.
Any idea why this is happening?
Thanks.
07-16-2014 10:20 AM
07-16-2014 12:30 PM
I'm pretty sure. According this this, getsample() returns exactly one value for each channel. I only have one channel, therefore it should only be returning one.
07-16-2014 12:52 PM
07-16-2014 12:53 PM - edited 07-16-2014 12:54 PM
How can I accept multiple samples at a time? I need them in real time, so I don't think that would help me anyway.
How could I make it a hardware timed acquisition though? That seems like a good idea.
07-16-2014 01:03 PM
07-16-2014 01:05 PM
Aren't all OSs real time? You do mean Operating System, right?
What I mean is that I want to gather the samples as fast as possible. Techincally it only needs to be about 200 Hz. But I was a new data point 200 times every second, and I need to process it it at that rate as well. So I can't just accumulate a bunch of data with timestamps.
07-16-2014 01:40 PM
07-16-2014 01:42 PM
Hm... So if I increase the sample rate in relation to the samples desired then it should work?
If it does, great, but it doesn't help me long run. Ideally this thing would need to run for 10+ minutes, and I can't do it based on number of samples, I would really need to do it continuously as long as it's running...
Sorry I'm so confusing.
07-16-2014 01:56 PM