07-12-2021 11:18 AM
I was wondering exactly how the minimum record length and the sample rate are related in terms of aquired samples. Right now I'm sampling at 100Msamples/sec and have a minimum record length of 1Msamples/sec. In a while loop where I fetch the samples, it supposedly fetches 1Msamples every millisecond. But I'm also saving the data to a tdms file which takes extra time. So when it finished saving and fetches the next set of samples, where in time do those samples come from? Since the next acquisition isn't immediate (after saving the data), did it skip over some samples?
07-12-2021 11:55 AM
A couple of things to note:
At your sample rate of 100MSamples/s, collecting 1 MSamples will take 10ms, ( 1MS/ (100MS/s)) = 0.01s = 10ms. So, no, you aren't fetching 1Msamples every millisecond.
If I knew which NI-SCOPE device you were using the next question would be easier to answer, but an oscilloscope does not sample continuously. Instead, there are windows of time where samples are acquired into the oscope's memory, then the triggers are reset and sampling happens again. This is often called the waveform update rate by many oscilloscope manufacturers. So there will be some gap of time between acquiring the last set of 1MSamples and acquiring the next set of 1MSamples. Without knowing the specifications of your NI-SCOPE module, I couldn't tell you what that gap of time is.
The relationship between record length (number of samples) and the sample rate is simple. The record length is simply the number of samples to acquire during an acquisition. A sample rate of 1,000 samples per seconds will take 1 second to acquire 1,000 samples. A sample rate of 1Msamples/second will take 1ms to acquire 1,000 samples. So sampling time = record length / sample rate with some allowance for the processing time between acquisitions.
07-12-2021 01:39 PM - edited 07-12-2021 01:40 PM
I see, I have a PXIe-5122 scope. What I'm wondering is if I'm samping at 1Msamples/sec with only a record length of 1000 per acquisition, am I losing the rest of the 1M samples taken due to the time it takes to save the data? Basically, I would like to save all 1M of those samples taken every second.
07-13-2021 08:50 AM
@Trekkie123 wrote:
I see, I have a PXIe-5122 scope. What I'm wondering is if I'm samping at 1Msamples/sec with only a record length of 1000 per acquisition, am I losing the rest of the 1M samples taken due to the time it takes to save the data? Basically, I would like to save all 1M of those samples taken every second.
To answer the question, technically, no, you are not losing the rest of the 1MSamples/sec because of the time it takes to save the data. You are losing the rest of the signal data because the record length is only 1,000 samples. The oscope only acquired 1,000 samples then stopped capturing.
If you want to capture a million samples per second, then you need to:
1) Set the sample rate to 1MSamples/second,
2) Set the record length to 1MSamples or greater.
You will need to take into account how much memory your oscilloscope has. If your oscilloscope has 8MB of memory then you could, at most, capture about 8 million samples at a time. There are ways to read samples out of the oscilloscope as they are being acquired so you don't run out of memory but I've never done that and don't know much about it.
07-13-2021 10:45 AM - edited 07-13-2021 10:53 AM
Here's what I figured out using NI-Scope...
My application also included a basic set of scope controls so the end user could change a few of the standard oscilloscope settings like Time/Div, Sample rate, etc.
Minimum Record Length = Time/Div * Sample Rate / number of display Divisions
Also remember that an Oscilloscope is not the same as a DAQ. (I know they basically are a DAQ but a NI-Scope is limited in functionality because they are sold as a "Scope") A DAQ can constantly acquire data and stream it to disk or whatever. A oscilloscope only acquires data one sweep at a time when triggered and transfers it then either stops or waits for another trigger.
There are ways to kind of simulate a streaming DAQ with NI-Scope but that requires some advanced low level programming to handle the buffer as not to overwrite.
07-13-2021 10:46 AM
I see, but when I sample at 10Msamp/sec for example and have a record size of 10Msamp/sec, it works but it seems to lag behind as after 30 seconds, only 25 or so records have been recorded.
07-13-2021 11:07 AM
Can you post your LabVIEW code?