LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Elapse time to string vi – Display Hours-Hours-Hours instead of Days – Hours - Hours

Solved!
Go to solution

Hi folks,

i'm a little stumped with my 'Simple Elapsed Timer'.

The timer rolls over at 23:59:59 but what I need is to roll over at 999:59:59 (hhh:mm:ss).

I appreciate I can use %D for days but the graphical data needs to be presented as 100's hours v process variable.

Can anybody offer any suggestions

 

Regards and tia

%H:%M:%S%1u

Download All
0 Kudos
Message 1 of 7
(3,698 Views)

Hi Simon,

 

I guess you know about this simple math:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(3,691 Views)
Solution
Accepted by topic author Simon-lee

You can try something like this.

 custom elapsed time.png

Note that there will be a roll over after 999 hrs.

 

Ben64

Message 3 of 7
(3,687 Views)

Simon,

 

It may be instructive here to discuss the concepts within LabVIEW of absolute time (when did this happen?) versus relative time (for how long did this happen?).  The LabVIEW timestamp datatype always represents an absolute point in time in the LabVIEW epoch, unambiguously referenced to UTC.  Arithmetic operations with timestamps are properly limited to addition (adding a relative offset to a timestamp) and subtraction (how much relative time passed between two timestamps).  Relative time is generally stored in a floating-point double.

 

But you should know that historically, before the timestamp datatype was added to LV, the double (and even the 32-bit INT) could be used to represent absolute times too, though with far less precision than the timestamp.

 

With all that in mind, please note that the Format Date/Time String primitive you were using really only formats absolute times.  It will accept your floating-point double wire (which carries an elapsed time - you did a subtraction of two timestamps, after all), but it will interpret it absolutely - as so many seconds past the dawn of LabVIEW time - and since you asked for a format string of just H:M:S and fractional seconds, you'll always get a clock time - it'll roll over on time greater than 24 hours.  (EDIT: is there no way to avoid the emoji reformatting?  Arrgh! H colon M colon S)

 

Really, you should use the Format Into String primitive, and give it the "relative time" format specifier, which is %t, and which can be tweaked ad nauseum with the %<>t syntax.  See the snippet I attached.  No need to do the modulo math, it's all handled for you.

 

Hope this helps,

Dave

time formats snippet.png

 

David Boyd
Sr. Test Engineer
Abbott Labs
(lapsed) Certified LabVIEW Developer
Message 4 of 7
(3,631 Views)

Thanks for that, I must admit I've never come across this way of solving the problem. 

0 Kudos
Message 5 of 7
(3,611 Views)

Thanks Ben64, that's a very neat solution. I'm somewhat confused by the format specifiers but  I will use your example to educate myself and its always easier to learn from a working solution.

 

0 Kudos
Message 6 of 7
(3,608 Views)

Thanks to all, I now have three working solutions but it does highlight that I need to work on understanding both string format syntax and time.

If anyone can recommend some background reading I have some studying to do.

 

Regards

 

As wise man one said " This must be Thursday, I never could get the hang of Thursdays" (Douglas Adams)  

0 Kudos
Message 7 of 7
(3,603 Views)