LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NICAN Timestamp

Hello everyone,

i have a question concerning NICan. I want to write messages to the
CAN Bus and get a timestamp when the message was written on the bus.
So i know the way with activating selfreception of messages but with
this method i had to search for the written message in the received
messages. I think thats not a good way. Is it possible to get a
timestamp in another way?

Best regards,
Andi
0 Kudos
Message 1 of 4
(3,092 Views)
Hello,

You could use a software timestamp in the following ways:

1. Record your machine time just before you perform the CAN Write operation.

2. Use ncWait.vi or cnWaitForState function to monitor when a given frame (or set of frames) have been sent, and record your machine time when confirmation is received.

3. Use the average of 1 and 2 above, where 1 gives you a time before the send and 2 gives you a time after the send.


Repost if you have follow-up questions!

Best Regards,

JLS
Best,
JLS
Sixclear
0 Kudos
Message 2 of 4
(3,092 Views)
This is a good idea but there is a problem, at least if you need an exact timing between the incoming and outgoing frames.

According to what I have noticed, to generate the timestamp of the frames that are read, the CAN interface doesn't use the timer of the computer but an onboard timer whith a better resolution than the 1ms of the computer's timer.

This means that different timebases are used for both types of frames (send = computer / read = CAN interface).

I made a test some months ago and I noticed that the onboard timer is not accurate. (Test was done with only 1 interface). There was an important error after some hours and this made it impossible to sort the in and out frames according to their timestamps.

Anyway, even if both timers would
run at the same speed, for high speed applications, the 1ms resolution of the computer and the incertainty about when the message was sent may be insufficient !

At this time, I haven't found a good solution for this task that nevertheless seems so easy...

Could someone from NI give us some more details about the timestamp circuitry of the CAN interfaces ?
0 Kudos
Message 3 of 4
(3,092 Views)
Hi JB,

I think with a single port, the best way to do it is using the self-reception feature. If you have a two port card, you could use the second port to receive the frame. This would give an accurate timestamp since we only know a given frame has been sent after it is acknowledged anyway. If this is the case, it'll be an accurate, albeit expensive, solution (using a port simply to timestamp writes).

Repost if you have other ideas or questions!

Take care,

JLS
Best,
JLS
Sixclear
0 Kudos
Message 4 of 4
(3,092 Views)