04-10-2018 01:53 PM
Hi Gazing,
But sometimes it collects more than one sample in the said range, which increment the counter multiple times and unexpected.
You are counting the times when a sample is within your range: this may happen more than once when the voltage is crossing your range!
You need to count only once the voltage is getting into the range:
Use BooleanCrossing to detect such digital edges…
So that I would be able to convert the iteration number to time (seconds) by multiplying with sample rate.
Don't use a timed while loop here!
The loop timing is only determined by your sample rate and so depends on the accuracy of the hardware timing unit - which is way more accurate than your Windows computer!
The TWL makes it even worse because you can only set iteration rates of full (integer) miiliseconds: What happens when you set the sample rate to e.g. 750Hz?
04-10-2018 02:56 PM
I couldn't get exact time (in seconds) for high sampling rate (for example 1000 Hz), no matter whichever loop I use, "simple while" or "timed loop".
04-10-2018 03:07 PM
the following image explain more, one from Elapsed time function and another from iteration_number/sampling_rate for sampling rate = 1000.
04-11-2018 12:35 AM - edited 04-11-2018 12:38 AM
Hi Gazing,
the following image explain more
That image explains nothing as you show two indicators not present in your previous code!
How should we know what these numbers represent?
As usual: when you have problems with your code you should attach your code - not just images of small parts of the UI!
I couldn't get exact time (in seconds) for high sampling rate (for example 1000 Hz)
That's usual: you are reading just one sample per DAQmxRead call/iteration!
Using DAQmx this way does introduce a lot of overhead and limits your loop rate and (loop) timing accuracy!
Using "1 Sample" modes is only recommended for low sampling rates (like <=100Hz)…