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: 

Control Sampling Period instead of Number of Samples in Sample Clock

Hi all,

I'm trying to add a control to my front panel so I can change the sampling period of my DAQ system instead of number of samples (it should get the sampling rate and the desired period from the user, multiply these two numbers and set it as the number of samples in the sample clock.). 

I tried to do this with both desired and actual sampling rate (the actual sample rate would be more desirable), but none of them worked. Is that even possible? if yes, what's the right way?

Any help or comments would be appreciated.

 

Thanks

0 Kudos
Message 1 of 3
(1,518 Views)

Don’t have LabVIEW at the moment, but this is what I do:

  1. look in the example finder for continuous acquisition using events.
  2. you are already using the property node to get the sample clock rate and max sampling rate, which is great start.
  3. if you have a SAR device then your allowed sample rates are going to be integer divisors of the sample clock rate up to max sampling rate. If you have a DSA device you allowed sample rates will be the max value divided by integers 1 to 31, or something like that, look in the manual.
  4. Out of the possible sample rates, i only allow sample rates divisible by 10.
  5. with the restriction above, I set my DAQ event to acquire data every 100 ms, thus I can make any time period that is a multiple of 100 ms, you just need store the data.

typing on mobile, sorry can’t be clearer.

 

mcduff

0 Kudos
Message 2 of 3
(1,503 Views)

The "# of samples" inputs for DAQmx Timing and DAQmx Read have been misleading people for years.   Like many before you, you've wired the same value to both.  However, that's not necessary and is frequently not even a particularly good idea.

 

I couldn't open your LV2019 code, but the screenshots showed me enough.  The one you labeled "1" is the best place to start.

 

1. First, decide how many samples you want to read per iteration and wire that value into DAQmx Read.  I'd simply divide the sample rate by 10, giving me about 1/10th second of data per iteration.

 

2. Use a shift register or feedback node so you can add each iteration's # of samples to a cumulative total.  Compare the cumulative total to your target total # to acquire.  Once you reach or exceed the target, end the loop and stop & clear the task.

 

3. If it matters in your app that your last iteration ends exactly *at* the target # samples, it'll just take some simple math & conditional logic to fine tune things at the end.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 3 of 3
(1,438 Views)