Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronize Hardware Timestamp of two CANCards

I'm using two PCMCIA CanCards with totally 3 physical CAN Ports and want to log Can Datafrom different physical Can Buses. I have the problem to synchronize the timestamp of this 3 Can Ports.
If I use the ncSetAttribute Function to set the NC_ATTR_ABBS_TIME to zero, there will be differences in the Time stamp of the same Can Message (received by all 3 Ports) up to 15ms. This is two much.
First I get the Counter Value of The Windows HighPerformanceCounter (accuracy: 279.3 ns).
The i use the ncSetAttribute Function to set the Counter to zero.
With the HighPerformanceCounter Value, I'm now able to correct the Incoming Timestamps to one Basetime. But this does not work.
I measured the ncSetAttribute Function needs about 0
,380 ms to execute, so I should never have 15 ms time difference between the received CAN Messages of two Ports.
Does anyone know, if the HardwareCounter is really set when the ncSetAttribute Function returns? Or maybe the Driver caches the call ?
Does anyone have an solution for my Sync. Problem ?

Thanks for Help.

Robert Hecker
0 Kudos
Message 1 of 2
(3,715 Views)
Hi,

On the two port CAN card, the timestamps between the two frames should be close. The card uses a single timer to set the timestamp. Even if the ports are reading the same frame, there is a small latency in the on-board processor which will cause the frames to have a slightly different timestamp.

With the third port, the first problem is setting the absolute timer. The function does not cache the value, but there is going to be a time difference since the software calls cannot be executed at the same time. You could measure the delay and compensate. You could also send a frame, read the timestamps and calculate the difference.

But, the main problem is the drift of the oscillators on the cards. The cards use a quartz oscillator. With the drift you
wouldn't be able to reliably use the application for more than 60 seconds.

DiegoF
National Instruments
0 Kudos
Message 2 of 2
(3,715 Views)