From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why sample rate is different than I set up?

Hi all,

I have set up an easy VI for understanding how nidaq-mx works. In the attachment you can find the VI. In particular the sample rate is set to 1Hz and I read 4 samples in 4 loops. So the acquisition should take 4 secs, isn't it? So why does it take just 0.03secs?

 

Thank you

 

 

0 Kudos
Message 1 of 24
(2,681 Views)

Although your sample rate on your DAQ-MX may be set up to sample at 1 Hz, your loop can run much much faster. I would try adding the wait function into your loop to assure that the loop takes at least 1 second if that is your desire.

 

Hope this helps.

 

-Franklin

0 Kudos
Message 2 of 24
(2,669 Views)

pierluk wrote:

I have set up an easy VI for understanding how nidaq-mx works. In the attachment you can find the VI. In particular the sample rate is set to 1Hz and I read 4 samples in 4 loops. So the acquisition should take 4 secs, isn't it? So why does it take just 0.03secs?


It does not! I am currently on a laptop using a simulated device, but the VI takes over 4 seconds to complete. I suspect that you create an error in your initial DAQ setup, causing all IO to instantly error out and complete.

 

There are quite a few things a bit strange with your VI:

  • If you only want to read one sample, why not use 1Chan1Samp?
  • This will also eliminate the reshaping.
  • The Graph 2 only shows the last point, replace it with a chart instead if you want real-time updates.

 

0 Kudos
Message 3 of 24
(2,663 Views)

@CTSFranklin wrote:

Although your sample rate on your DAQ-MX may be set up to sample at 1 Hz, your loop can run much much faster. I would try adding the wait function into your loop to assure that the loop takes at least 1 second if that is your desire.


This is incorrect. The read timeout is 10 seconds by default, meaning it will wait 10 seconds if no sample is available. This is sufficient to never timeout with a 1Hz sampling rate and the sampling rate will primarily determine the loop rate as it should be.

 

Adding an additional delay introduces a second timing dependency, possibly causing problems in the long run.

0 Kudos
Message 4 of 24
(2,660 Views)

Tanks for your reply. In the beginning I set up the NI-DAQMX Read in reading 10 samples, but the VI runs really fast. So I just tried to read only one sample for each iteration, but nothing changes. When I execute the VI I don't get any error and the right amount of samples. When in the waveform properties I get the dt is 1 for any sample rate I set up. I don't understand what's wrong on my VI

0 Kudos
Message 5 of 24
(2,625 Views)

Post your new VI. In your original, you don't have a waveform data type anywhere at all and any dt that you write to the file is garbage/default value since you are not passing any dt value to the Write to Measurement File function.

0 Kudos
Message 6 of 24
(2,613 Views)

Thanks again for your reply, this is the new VI.

0 Kudos
Message 7 of 24
(2,585 Views)

I never use dynamic data or the write to measurement file but your Convert to Dynamic Data looks wrong. You have a conversion dot on the input. Why did you select the input type as 1D Array of Scalars (which has no timestamp) instead of Single Waveform?

0 Kudos
Message 8 of 24
(2,578 Views)

Dennis Knutson ha scritto:

I never use dynamic data or the write to measurement file but your Convert to Dynamic Data looks wrong. You have a conversion dot on the input. Why did you select the input type as 1D Array of Scalars (which has no timestamp) instead of Single Waveform?


I already did it, but it doens't change anything. I don't understand what's wrong with that VI.

0 Kudos
Message 9 of 24
(2,571 Views)

Another strange thing I noticed is your sample rate. You have it set to .5S/sec. With it set to something reasonable (i.e. 500 or 1000) and the correct Convert to Dynamic Data, the dt in the file is correct.

0 Kudos
Message 10 of 24
(2,563 Views)