LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to count number true in last minute?

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:

check.png

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?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 11 of 14
(1,038 Views)

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".aaa.JPG

 

0 Kudos
Message 12 of 14
(1,029 Views)

the following image explain more, one from Elapsed time function and another from iteration_number/sampling_rate for sampling rate = 1000.aaa.JPG

0 Kudos
Message 13 of 14
(1,027 Views)

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)…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 14 of 14
(1,017 Views)