LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I pass miliseconds to hours,minutes and seconds?

Hi,
 
I have a real number and I want to pass it to hours, minutes and seconds. How can I do it? What is the best efficient method?
 
Thanks,
 
ToNi.
0 Kudos
Message 1 of 9
(5,879 Views)
You could just do a series of successive Quotient&Remaider operations in a loop.
 
Attached VI (LabVIEW 7.1) shows two possibilities for the output (array of numers or string).
0 Kudos
Message 2 of 9
(5,877 Views)
Hi,

Thanks I finally did a series of successive Quotient&remainder combinated with the operations round and truncate to -infinite. Later I attach you my example here.

Could you attach here your vi in LV7 Express format please? I couldn't open it.

ToNi.


0 Kudos
Message 3 of 9
(5,855 Views)
Here's a 7.0 version of the above.
 
 
The array output generates array elements corresponding to ms, S, M, H.
The string output generates a string formatted as ...HHHHHH:MM:SS.mmm

Modify as needed.

(The last element of the array constant just needs to be big). You can easily expand it by one element so it also displays days above 24 hours. 🙂

Message Edited by altenbach on 10-26-2005 09:25 AM

Download All
Message 4 of 9
(5,836 Views)
Here it is in LV7:
 
 
Altenbach had one slight mistake that I corrected.  The top element in the string constant array was listed as %04d.  This cause the millisecond field in the time string to have an extra 0 in front of the millisecond number.  When milliseconds were 890, the time string was hh:mm:ss.0890.  I replaced %04d with %d.  This gives the correct time string no matter how many characters are in the milliseconds field.  Like hh:mm:ss.1 or hh:mm:ss.11 or hh:mm:ss.111
- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 9
(5,829 Views)
Thanks tbob, I just caught that one too ;).
0 Kudos
Message 6 of 9
(5,822 Views)
David Boyd just showed me how to do this using the Format option. It does it automagically.
Yours Sincerely
John
John Brohan         National Instruments LabVIEW expert in Montreal
Traders Micro         "We connect all sorts of things to computers"
Open LV Lib  index is at   http://bloghan.gotdns.org/OpenLVLibs/


Message 7 of 9
(5,776 Views)

Thanks!

 

0 Kudos
Message 8 of 9
(3,195 Views)

t.png

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