LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Log time in milliseconds

I am on measuring the intervals by which some interrupt occurs.
I want to log the time at which the interrupt occurs. It may by less than 1 ms.
 
What I could do, is to use the function "TimeStr()" but ius resolution is in seconds, so what I could get is something like that:
 
[12:25:10]
[12:25:10]
[12:25:11]
[12:25:11]
[12:25:11]
[12:25:11]
[12:25:11]
[12:25:11]
[12:25:11]
[12:25:11]
[12:25:11]
[12:25:11]
[12:25:11]
[12:25:11]
[12:25:11]
[12:25:11]
[12:25:11]
[12:25:11]
[12:25:11]
[12:25:12]
[12:25:12]
 
I want to measure these times in less than milliseconds.
 
Thanks
0 Kudos
Message 1 of 3
(4,658 Views)
If you use the FormatDateTimeString function, you should be able to display millisecond resolution. Here is some sample code:

#define DATETIME_FORMATSTRING "[%H:%M:%S.%f]"

double currDateTime;
int bufferLen;

char *dateTimeBuffer = NULL;
GetCurrentDateTime (&currDateTime);
bufferLen = FormatDateTimeString (currDateTime, DATETIME_FORMATSTRING, NULL, 0);
dateTimeBuffer = malloc (bufferLen + 1);
FormatDateTimeString (currDateTime, DATETIME_FORMATSTRING, dateTimeBuffer, bufferLen + 1 );


0 Kudos
Message 2 of 3
(4,629 Views)

Windows provides a function called QueryPerformanceCounter. This provides excellent accuracy.

Regards, Guenter

0 Kudos
Message 3 of 3
(4,624 Views)