Question from the Customer:
I’m using the Komodo CAN Solo Interface with Komodo Software API. Can you help me understand the timestamps? Do timestamps change with the bit rate? What are the units of the timestamp? Here is what I’m looking at in the example code monitor.c, the structure of km_can_info_t:
are multiples of 1MHz. If any other rates
are desired, this code needs to be changed.*/
#define TIMESTAMP_TO_NS(stamp, samplerate_khz)
(u64)(stamp * (u64)1000 / (u64)(samplerate_khz/1000))
Response from Technical Support:
Thanks for your questions! Here are the details about the sample rate.
The sample rate is separate from the Komodo Interface bit rate
The sample rate is the frequency of the clock that used internally for sampling signals – it is not the related to the bit rate of the Komodo Interface.
The timestamp value is generated in API
The API function km_get_samplerate returns the value of the sampling clocks frequency in Hertz. In the example code that you’re looking at, this value is obtained and converted into Kilo Hertz (shown as khz in the example code).
The actual timestamp value read from the device, which is part of the data structure returned by the API function km_can_read, is in ticks of the internal sampling clock. Both of these values, khz and ticks, are then passed to the macro TIMESTAMP_TO_NS, which converts the value to nanoseconds.
For the Komodo Interface, the sampling clock is 50 MHz. In this case, the parameters in the example script are as follows:
- km_get_samplerate(km) = 50000000
- km_get_samplerate(km) = (5000000/1000) = 50000
- info.timestamp (as an example) = 48
- Arguments to TIMESTAMP_TO_NS (48, 50000)
- Value returned by the above function:
((48 * 1000)/(50000/1000)) =
((48 * 1000)/50) =
(48 * 20) =
960 ns
Additional resources that you may find helpful include the following:
- Komodo CAN Interface User Manual
(For details about API, refer to the section API Documentation.)
We hope this answers your question. You can contact us and request a demo that applies to your application, as well as ask questions about the Komodo CAN interfaces and other Total Phase products.