LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

precise time stamping of serial data

I am having trouble with precise timestamping  of incoming serial data recived on 4 ports using 4 separate threads that continually attempt to read a byte.

 

When the expected frame is recieved the data is tagged with a time stamp.

 

The issue seems to be windows xp or the serial ports themselves.  I am using an xsens serial to usb, 2 lavaport serial cards and the built in serial port.

 

Any suggestions for precise timing?

0 Kudos
Message 1 of 2
(3,211 Views)

 

there is some hints:

   -for milisecond precise timestamp, you can use GetLocalTime,GetSystemTime or GetTickCount.

    But to achieve true milisecond scale, you need use timeBeginPeriod(1)/timeEndPeriod(1) otherwise you get 10-16ms scale depend on system

    (please read help pages on msdn for timeBeginPeriod function)

   - create your program to not use CPU too much(no pooling,just message and/or sync wait),

     or even better, do not run any other apllication which consume lot of CPU/DISK resources on the same PC

   - for serial communication (but this also depend on baud rate) you can try to set send/receive driver buffer to 1 (from windows device manager)

   - try different serial port card/converter(with different drivers)

   - if still need something to try, set higher process and thread priority (SetPriorityClass,SetThreadPriority)

 

After all of this, on windows, there are no precise timing.Even if you do everything you can do, there is still chance to get time gap, but you can detect it (in milisecond precision)

 

0 Kudos
Message 2 of 2
(3,189 Views)