05-13-2020 05:32 AM
The sample rate is 1 per sec. ; I need 5 samples ; I hold the acquiring loop for 5 sec. Yet I get two sets of data .. Tried to read Help but could find the reason for this. Even tried to set the loop timing to 1 sec and still I get two set of samples. Why is this ?
Solved! Go to Solution.
05-13-2020 05:41 AM - edited 05-13-2020 05:41 AM
Hi Raghu,
@MogaRaghu wrote:
The sample rate is 1 per sec. ; I need 5 samples ; I hold the acquiring loop for 5 sec. Yet I get two sets of data .. Tried to read Help but could find the reason for this. Even tried to set the loop timing to 1 sec and still I get two set of samples. Why is this ?
Because the loop iterates twice…
THINK DATAFLOW: the ElapsedTime gives FALSE in the first iteration, so the loop repeats…
Why don't you use "Continuous samples" when you need just 5 samples?
Why do you need ElapsedTime (and the loop) at all: DAQmxRead will wait for 5 samples on its own!
05-13-2020 07:04 AM
To learn how DAQmx works, open MAX (the Measurement and Automation Explorer). Find your Device in the Devices list. Open a Test Panel. Find your A/D. Now play with the settings. Notice what the difference is between Finite Samples (where, say, "I want to take 5 samples") and Continuous Samples (where, say, "I want to take 5 samples at a time, over and over"). Learn what "Number of Samples" means.
If you want to take 5 samples and stop, then why do you need a loop?
Understand your Device and understand DAQmx a bit better -- MAX can give you the tools to explore and learn.
Bob Schor
05-13-2020 08:13 AM
This looks extremely similar to a CLAD example exam question. Studying up for a CLAD?
05-13-2020 08:54 AM
A subtler point is that the call to DAQmx Read is probably going to complete in something more like 4 seconds rather than 5.
When the task is started, the 1st sample will be taken almost immediately, near t=0. The 2nd sample will be taken at ~1 second and so on until the 5th sample is taken at ~4 seconds.
-Kevin P
05-16-2020 12:36 AM
@crossrulz
You are spot on.. yes its a lift off from a sample CLAD question bank ! I am not preparing but helping some one else who is. With my age well past 60, even assuming I get the certificate, it will be a personal joy and that's it !!
The sample rate is 1/sec. And the read is set up for 5 samples. And since the loop will anyway iterate once, for the Elapsed Time less than 5 sec, one would expect only to get one set of samples. Why does the second iteration happen in that case ?
05-16-2020 01:15 AM
Just landed on this You tube video which answered my doubt.
Thanks to all those who chipped in !