LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

date and time vi with milliseconds

I am trying to read the system clock with milliseconds. Does anybody
know how to do it in Labview?

Thanks,

Kimberly


Sent via Deja.com http://www.deja.com/
Before you buy.
0 Kudos
Message 1 of 10
(4,741 Views)
If you are in Windows9x, use the Call Library function to call the
GetSystemTime function in kernel32.dll You can do this by following
this procedure:

1. Create a Call Library function from the Advanced Palette
2. Right mouse-click on the function and select "configure"
3. Set the Library Name or Path to C:\WINDOWS\SYSTEM\kernel32.dll
4. Set the function name to GetSystemTime
5. Set the Calling Convention to stdcall(WINAPI)
6. Leave the return type parameter as the default (void)
7. Add a parameter by using the "add parameter after" button
8. Set the new parameter's type to "adapt to type"
9. In the diagram, create a cluster constant and fill it with eight
unsigned 16-bit integers.
10. Wire this cluster constant to the parameter input of the CalLibrary
function.
11.
The output of the function will be a cluster of eight integers
containing the following information:

Year, month, day of week, day, hour, minute, second, milliseconds

BE CAREFUL! Make sure the Calling Convention is set to stdcall(WINAPI)
or Labview will crash!

Good Luck


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
0 Kudos
Message 2 of 10
(4,741 Views)
PS! I almost forgot... The data returned by the GetSystemTime function
is always returned in Greenwich Mean Time (GMT). You will have to
account for this if you want the date and hour in your time zone!


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
0 Kudos
Message 3 of 10
(4,741 Views)
Hallo, kimberlyw,

Du meintest am 05.01.00 zum Thema date and time vi with milliseconds:

> I am trying to read the system clock with milliseconds. Does
> anybody know how to do it in Labview?

That's no good idea. PCompatibles have a resolution of about 18
milliseconds.


Viele Gruesse!
Helmut
0 Kudos
Message 4 of 10
(4,741 Views)
> I am trying to read the system clock with milliseconds. Does anybody
> know how to do it in Labview?
>

The other responses will work, but you can also just use the Date and
Time icon in LV. The seconds return value is a double precision number.
It will contain the fractional seconds. Note that the resolution of this
clock is about 55ms. In otherwords, it only changes 18 times a second.
There are higher resolution clocks on the PC, like the stopwatch timer
uses, but they don't correlate the time to the system Date and Time.

Greg McKaskle
0 Kudos
Message 5 of 10
(4,741 Views)
Greg:

According to National instruments, the 55ms timer resolution applies to
Windows 3.x. Here is an excerpt from the Knowledge Base document #
1CAEE34V on NI's web site:


LabVIEW or LabWindows/CVI timer functions use the operating system
timers. The time resolution of these timers depends on the operating
system. A list of typical timing resolutions on different operating
system is given below. This means that any software timed operation
would be accuracy of +/- 1ms on a Win95/NT operating system.

Windows 3.x = 55ms, Windows 95/NT = 1ms, Macintosh 68k = 17ms, PowerMac
= 1ms, SUN Solaris= 1ms

*************************************

I do not know whether this "system timer" is the "stop watch" timer or
the timer upon which the time and date is based, or if NI
has no idea
what it is talking about. Some clarification is in order on this
subject. I will agree with Helmut, however, that any application that
relies on the milliseconds to record or control events (other than loop
timing to conserve processor time)is ill advised.

MaxMar


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
0 Kudos
Message 6 of 10
(4,740 Views)
On Thu, 06 Jan 2000 06:40:20 -0800, MaxMar
wrote:

>Greg:
>
>According to National instruments, the 55ms timer resolution applies to
>Windows 3.x. Here is an excerpt from the Knowledge Base document #
>1CAEE34V on NI's web site:
>
>
>LabVIEW or LabWindows/CVI timer functions use the operating system
>timers. The time resolution of these timers depends on the operating
>system. A list of typical timing resolutions on different operating
>system is given below. This means that any software timed operation
>would be accuracy of +/- 1ms on a Win95/NT operating system.
>
>Windows 3.x = 55ms, Windows 95/NT = 1ms, Macintosh 68k = 17ms, PowerMac
>= 1ms, SUN Solaris= 1ms
>
>*************************************
>
>I do not know whether this "system timer" is the "stop watch" timer or
>the timer upon which the time and date is based, or if NI has no idea
>what it is talking about. Some clarification is in order on this
>subject. I will agree with Helmut, however, that any application that
>relies on the milliseconds to record or control events (other than loop
>timing to conserve processor time)is ill advised.
>
>MaxMar
>
>
>* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
>The fastest and easiest way to search and participate in Usenet - Free!
>
A quick test (Win98, LV5.1, P233) using a loop to build a numeric
array with both the LV internal Time and Date function and the
kernel32 GetSystemTime call returns double precision numbers that
remain "stuck" for 50 or 60 mS (i.e. 55mS) and then update to the new
value. The 3rd digit of precision remains at zero. This indicates
that the extract above about 1mS accuracy doesn't apply to the
Time/Date function and Greg's comment is dead right. For platform
independence the LV internal function may be preferred.

The advantage of the kernel32 calls is they can provide UTC with the
ability to SetSystemTime (similar syntax to Get except return value
wired for error as numeric 32 bit integer). Good for external
references like SNTP servers or GPS units.

You are not stuck with only UTC as the GetLocalTime and SetLocalTime
kernel32 functions have the same syntax but work in the local time
zone. Please note that the technique for wiring with clusters and
adapt to type is only recent (LV5+?) - earlier versions may need
separate dlls to get at the kernel32 call as it uses pointers to
structures (don't ask me about the details!).

Regards,
Donald Love
(remove the x's in the email address)
0 Kudos
Message 7 of 10
(4,740 Views)
> >According to National instruments, the 55ms timer resolution applies to
> >Windows 3.x. Here is an excerpt from the Knowledge Base document #
> >1CAEE34V on NI's web site:
> >
> >
> >LabVIEW or LabWindows/CVI timer functions use the operating system
> >timers. The time resolution of these timers depends on the operating
> >system. A list of typical timing resolutions on different operating
> >system is given below. This means that any software timed operation
> >would be accuracy of +/- 1ms on a Win95/NT operating system.
> >
> >Windows 3.x = 55ms, Windows 95/NT = 1ms, Macintosh 68k = 17ms, PowerMac
> >= 1ms, SUN Solaris= 1ms
> >
> >*************************************
> >
> >I do not know whether this "system timer" is the "stop watch" timer or
> >the timer upon which the time and date is based, or if NI has no idea
> >what it is talking about. Some clarification is in order on this
> >subject. I will agree with Helmut, however, that any application that
> >relies on the milliseconds to record or control events (other than loop
> >timing to conserve processor time)is ill advised.
> >


The resolution being discussed here is the stop watch. Again, it is a
relative timer with a unit of milliseconds that overflows about every 30
days and is relative to the last time the computer was rebooted. The
Date and Time function doesn't overflow until about 2040, and has a unit
of seconds. Most platforms do not provide the system time with any
fractional time. Win32 does and its resolution is the old standby from
the DOS days of 55ms or 18 ticks per second. So at least in this
situation, NI is correct, though the article could have been more
specific as to which timer it was referring.


> A quick test (Win98, LV5.1, P233) using a loop to build a numeric
> array with both the LV internal Time and Date function and the
> kernel32 GetSystemTime call returns double precision numbers that
> remain "stuck" for 50 or 60 mS (i.e. 55mS) and then update to the new
> value. The 3rd digit of precision remains at zero. This indicates
> that the extract above about 1mS accuracy doesn't apply to the
> Time/Date function and Greg's comment is dead right. For platform
> independence the LV internal function may be preferred.
>
> The advantage of the kernel32 calls is they can provide UTC with the
> ability to SetSystemTime (similar syntax to Get except return value
> wired for error as numeric 32 bit integer). Good for external
> references like SNTP servers or GPS units.
>
> You are not stuck with only UTC as the GetLocalTime and SetLocalTime
> kernel32 functions have the same syntax but work in the local time
> zone. Please note that the technique for wiring with clusters and
> adapt to type is only recent (LV5+?) - earlier versions may need
> separate dlls to get at the kernel32 call as it uses pointers to
> structures (don't ask me about the details!).
>

Thanks for the confirmation. I really like seeing people put together
elegant tests to actually measure the timing/accuracy rather than basing
important decisions on guesses and the like. It also keeps people like
me honest since I'm typically going on memory.

Greg McKaskle
0 Kudos
Message 8 of 10
(4,740 Views)
Thanks, Donald and Greg, for the clarification.


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
0 Kudos
Message 9 of 10
(4,740 Views)
I am trying to read system clock with milliseconds, for this i use "Format Date/Time String" function with the option "fractional seconds".This is correct to obtain milliseconds?
I need to read each millisecond. My operating system is better than Windows 95/NT.
0 Kudos
Message 10 of 10
(4,739 Views)