How Are Transactions Timestamped and What Is the Unit of Measurement for the Komodo CAN Solo Interface?

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:


/* This will only work for sample rates that
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.

Example of Calculating the Timestamp

For the Komodo Interface, the sampling clock is 50 MHz. In this case, the parameters in the example script are as follows:

  1. km_get_samplerate(km) = 50000000
  2. km_get_samplerate(km) = (5000000/1000) = 50000
  3. info.timestamp (as an example) = 48
  4. Arguments to TIMESTAMP_TO_NS (48, 50000)
  5. 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:

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.

Request a Demo