LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to continuously assign and compare two time stamps for an indefinite amount of time

Solved!
Go to solution

I am writing a VI that calculates the flow rate, in GPM, of the output of a flow meter. The VI works fine I'm just wondering what is the best method for continuously assigning time stamps for an indefinite amount of time.

 

Currently every time voltage is rising and is greater than 0.02V I am assigning a time stamp to that event, using the Tick Count block, then performing the flow calculation to determine GPM. Essentially I'm using the period of the waveform to determine the flow rate.

 

Since the Tick Count block rolls over after a certain amount of time I'd like to know if there is a better method for assigning a time stamp.The program will run for an unknown amount of time and I'd like to avoid the roll over condition. Thanks.

0 Kudos
Message 1 of 7
(2,507 Views)

How about Get Date/Time In Seconds Function to assign a real timestamp instead?  You can do simple subtraction to get relative time between two events.


Edit:

Ugh, you need better resolution.  Sorry.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 7
(2,494 Views)
Solution
Accepted by topic author Mr_Papagorgio

Instead of "Tick Count (ms)", use "Get Date/Time In Seconds".

I've also put a few other improvements in your code.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 3 of 7
(2,491 Views)

Paul,

 

Thanks for your help. Would the roll over condition now occur as time changes from AM to PM and PM to AM?

0 Kudos
Message 4 of 7
(2,481 Views)

If you store the tick count as a U32 (not coerced to double), you can do a subtraction of the two and not worry about the roll-over condition*. For example if your previous tick value is just before the U32 rollover (say 4294967290) and the following tick value has rolled over (say to 5), then the difference is calculated correctly as 11 ticks:

roll_over.PNG

 

*Of course this won't help in the case where your previous tick is from a previous roll over (ie more than ~50 days ago), but it's probably unlikely you won't have some sort of flow in that time period.

 




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
0 Kudos
Message 5 of 7
(2,450 Views)

Better yet, you've already set up a hardware-clocked task.  You're gonna get much better accuracy and repeatability if you base your delta time calculations on the *that*.

 

You should probably read multiple samples per loop iteration and then keep track of the cumulative sample # index where your criteria are met.  I'd also recommend reading as a waveform so you get the real "dt" value.  Due to quantization, it may be different from the nominal (1 / requested_sample_rate). 

 

The difference in indices from previous to now can be multiplied by the dt to give you a more accurate time interval measurement.  Also, by using the buffering feature of DAQmx, your time measurement accuracy no longer depends on your software loop or Windows.

 

 

-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 6 of 7
(2,421 Views)

@Mr_Papagorgio wrote:

Paul,

 

Thanks for your help. Would the roll over condition now occur as time changes from AM to PM and PM to AM?


There is no rollover on timestamps.  They just keep getting bigger.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 7 of 7
(2,402 Views)