Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
This Document is not yet Rated  Rate this Document

NI-CAN Timestamp Drift Relative to PC Clock

Hardware: Industrial Communications, Industrial Communications>>CAN

Problem:
Why do timestamps for my CAN frames start out synchronized to my PC clock, but drift over time?

Solution:
This is fundamentally due to the fact that the CAN card receives an initial timestamp from the PC when the ncOpen function is executed, but uses its onboard processor, which is clocked by an on-board oscillator, to determine subsequent timestamps. The fact that this oscillator drifts and is not synchronized with the PC oscillator causes the CAN timestamps to drift over time relative to the PC clock. The degree of drift may vary from system to system and, unfortunately, there is no suggested hardware fix to synchronize the clocks.

There are, however, a few software "re-synchronization" techniques which can be suggested if this poses a problem for a particular application:

  • If the application can manage "interruptions", the Network Interface or CAN object of interest can be closed and reinitialized periodically (perhaps after the timestamp has drifted sufficiently far from the PC clock), in order to resynchronize to the PC clock.


  • You could use the ncGetTimer.vi (in LabVIEW, see the CAN » Frame API » Advanced palette) or the NC_ATTR_ABS_TIME attribute (in text based languages) along with the Network Interface Object to get the absolute timestamp on the CAN card. This can then be compared to the PC timestamp using a Get Date/Time function (in LabVIEW), or an equivalent function in a text based language to return the PC clock time, to programmatically account for the timestamp drift in an application.


  • Related Links:

    Attachments:





    Report Date: 04/20/2005
    Last Updated: 10/15/2006
    Document ID: 3KJCSL4B

    Your Feedback! poor Poor  |  Excellent excellent   Yes No
     Document Quality? 
     Answered Your Question? 
      1 2 3 4 5
    Please Contact NI for all product and support inquiries.submit