LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sample rate and number of samples

Hello!

I'm having a doubt about sampling rate and number of samples to acquire using DAQmx hardware.

I'm using the attached .vi and I read in the forum that:

"Sample/Sampling rate (scan rate)
The rate at which one sample per channel is acquired; the rate at which the sample (scan) clock is set. Note that the maximum sampling rate specification for our E Series data acquisition boards refers to the maximum rate at which a single channel can be acquired. For example, the PCI-6071E is capable of a 1.25 MS/s sampling rate. This may consist of 1.25 MS/s on one channel or 250 kS/s on five channels.
"

so my question arises and it's the following:
If sampling rate is the rate at which one sample per channel is acquired, why do I have to specify the number of samples to acquire?

If I specify a sampling rate of 10kHZ, for each sampling wave cycle it should acquire a sampling resulting in a total of 10000 samples after a second. I know I'm wrong, otherwise there would not exist the number of samples input to the DAQmx timing.vi

Imagine that I want to acquire a sine wave at 5kHZ, I know (by the Nyquist theorem) that at least the sampling rate should be 10kHz in order to avoid aliasing. If  I specify a sampling rate of 40khz (more than enough), and number of samples for 100 and for 1000 what are the main differences?
I already made these and several other tests and can't discover the "right combination" of both.

What I see is that using, for example, sampling rate = 10000Hz and number of samples = 100 is the same as using
sampling rate = 20000Hz and number of samples = 200.
Another case is that If I use
sampling rate = 10000Hz and number of samples = 100 and after that I change sampling rate = 10000Hz and number of samples = 200 (in order to describe the same acquired wave with more points) I get more wave cycles instead of the same number of wave cycles with more (200) points describing it.

I hope I'm not confusing you, if that's the case tell me and then I'll try to explain in a simpler way...

Any help would be greatly appreciated!

Thanks in advance!

Best regards!

0 Kudos
Message 1 of 10
(15,359 Views)
The importance of the sampling rate and the number of points are dependent on what you are trying to do.

One situation where the number of points can be significant is when you want to perform a Fourier Transform on the acquired data.  The longer the acquisition time (i.e. the more points you acquire), the better your frequency resolution will be.  If you acquire data for Time = T, then your frequency step in the frequency domain with = 1/T.  In a case where you would want to distinguish a signal at 100 Hz from a signal at 101 Hz, you would have to acquire at least 1 second of data to get a 1 Hz resolution.

If in the example you provided, if you just want a average value of a waveform, sometimes a single cycle of the waveform will be all you need to get an accurate result, so you wouldn't need to acquire very many points.
Randall Pursley
Message 2 of 10
(15,348 Views)

Goju-Ryu,

Sampling rate is sampling rate.  It is the frequency of the data collection of that task- no matter how many channels or number of samples you grab.

The number of samples is how many samples the program returns from the DAQ buffer upon query.  The query is how often does the samples get read.  The query rate = sampling rate/# of samples (Hz).

This means if you have a task in a while loop, the while loop must iterate at a frequency greater or equal to query rate. If it does not, then the DaQ buffer fills up. Every time the while loop iterates the specified number of sample is returned.  This also means that all of the code inside the while loop must be done before the next query.

I hope I have explained it enough.

Chris Co

 

Sorry you beat me- i'm slow typer

Message Edited by Chris Co on 01-25-2007 01:13 PM

0 Kudos
Message 3 of 10
(15,345 Views)
hey there...i was trying this sampling thing too...i have an NI card that samples inputs from a signal generator...now what i want to is display this on a screen using LabWindows/CVI.


the x axis should show seconds and the y axis should show magnitude...any idea what function i need to use...i'm trying to modify some old code and they've used DAQmxReadAnalogF64 ...so this displays the samples along the x axis...i want to display seconds instead...a simple conversion...but what specific function do i need to use? any ideas?
0 Kudos
Message 4 of 10
(15,284 Views)
Hi All,
 
I have installed a NI PCI-6221, M Series DAQ (16 Analog Inputs, 24 Digital I/O, 2 Analog Outputs) with NI-DAQmx driver software for continuous recording of Current and Voltages in all the 3 phases of an AC source supplying power to an induction motor. Our supply frequency is 50Hz and I use the following myprogram.vi for acquiring realtime data. While executing it is creating problems. Infact, what should be the appropriate sampling rate and also the number of samples to read?
 
Please advice.
 
 
0 Kudos
Message 5 of 10
(15,161 Views)
What exactly do you mean by problems. I don't have the hardware and can only run in simulation mode but it seems to work with the sample rate and number of samples you have specified. It generated an error for the Write to Spreadsheet File because you didn't specify a file name. I used a feedback node like you did for the other file write functions and the error went away.
0 Kudos
Message 6 of 10
(15,155 Views)

Hi,

I tried with a sampling rate of 5kHz and no. of samples to read 1000. For a 10 minutes recording it created a 500Mb file out. Also, there has been breaks in recording data as seen by broken time stamps with a gap of 3 to 4 minutes with the header getting written again each time when there is a break. Is it the problem with sampling rate/no. of samples to read? Also, the output file created issues, it cannot be fully opened by excel program due to limitaion on no. of rows ; should not be greater than 65500 rows or so.

 

 

0 Kudos
Message 7 of 10
(15,150 Views)
A 5kHz sample rate seems excessive for a 50 hz signal. Nyquist says you only need twice the frequency of the signal you want to sample. Try going down to a 500 Hz sample rate.
 
I suspect that the gaps in the recorded files are because of the functions you are using. They open and close the file each time they are called. This takes some amount of time though 3 to 4 minutes seems high. With lower sample rates and lower number of samples recorded, this may improve. For best file performance, you want to open the files once. This would be done outside the while loop. Then inside the loop, you would just call a write file. You'll also get better performance if you use a binary file write. If the data is still too large for Excel, you can always use LabVIEW to read and analyze the data. I've been told that the newest version of Excel has a higher limit than 65k for the number of rows but, imho, Excel is a lousy tool for analyzing engineering data anyway.
0 Kudos
Message 8 of 10
(15,141 Views)

Hi all

I request the forum to download and see the myprogram.vi file and freely do modifications  which you think is correct for the proper functioning of it. Also, please post back the fine tuned program.

With regards,

Ruwan

0 Kudos
Message 9 of 10
(15,043 Views)

Hello,

 

I have this program, which reads in three line current and three line voltages in a 50Hz three phase power supply. I used a PCI 6221 DAQ. When I give a sampling rate of 11KHz, the recored signals shows discontinuity as evident from the time stamping. What could be the reason? Please advice. I am attaching the program and also the recorded output, alternate columns in it starting from column A are time stamps and the remaining are current and voltage data.

 

UnniVat

0 Kudos
Message 10 of 10
(14,535 Views)