TPCANTimestamp into readable time

This forum covers third party software that is for example developed with our APIs
Post Reply
KRotmann
Posts: 7
Joined: Thu 27. Oct 2022, 10:26

TPCANTimestamp into readable time

Post by KRotmann » Thu 22. Feb 2024, 15:01

Hello!
For a current project, I need to read data from CAN using Labview. I am using the kdi_labview_api_for_pcan_basic_fd-1.0.0.10 1 and Labview Version Q3 2023 (32-bit).
So far, I've established a connection and am able to read CAN Data via the Function "CAN Read". The Code returns the CAN messages, but also the TPCANTimestamp out.
The question is, how do I convert the type TPCANTimestamp (e.g. 30F0000 06F4 7D60) into UTC time (with Labview)?

From the following entries in the form we figured out one could use the following formula to convert the timestamp into milliseconds:
viewtopic.php?f=119&t=2529&p=7503&hilit=timestamp#p7503
viewtopic.php?t=3223

{
int32 millis: --> 30F0000
int16 millis_overflow; --> 06F4
int16 micros; -->7D60
}

time_milliseconds = micros + 1000 * millis + 0x100000000 * 1000 * millis_overflow

Using this formula, we get weird results (e.g. negative numbers), and we don't know how to convert these milliseconds into a readable time, e.g. UTC.
Any help would be great!

Best regards,
Kirsten

PS: In the attachment an Output of the Example PCAN_BASIC_READ_EXAMPLE from the APi.
Attachments
RCV CAN data.PNG
RCV CAN data.PNG (50.98 KiB) Viewed 992 times

M.Maidhof
Support
Support
Posts: 1712
Joined: Wed 22. Sep 2010, 14:00

Re: TPCANTimestamp into readable time

Post by M.Maidhof » Thu 22. Feb 2024, 15:48

Hi,

please see info in the help of PCANBasic API. The time-stamp contains the number of microseconds since the start of Windows. There is no relation to the UTC time.

Take care that all these struct values are unsigned values, without negative numbers:

Code: Select all

public value struct TPCANTimestamp
{
    UInt32 millis;
    UInt16 millis_overflow;
    UInt16 micros;
};
regards

Michael

KRotmann
Posts: 7
Joined: Thu 27. Oct 2022, 10:26

Re: TPCANTimestamp into readable time

Post by KRotmann » Fri 23. Feb 2024, 10:22

Hello Michael,

thank you very much for the reply!

I have another question: In comparison to PCAN Exlorer, time is displayed either relative (how many ms have passed since the start of recording CAN) or in absolute time (Compare images below).

Is there any possibility to display the time analogically in Labview, and if yes, how?
Attachments
Time in absolute
Time in absolute
absolute.PNG (20.28 KiB) Viewed 952 times
Time in relative
Time in relative
relative.PNG (14.54 KiB) Viewed 952 times

M.Maidhof
Support
Support
Posts: 1712
Joined: Wed 22. Sep 2010, 14:00

Re: TPCANTimestamp into readable time

Post by M.Maidhof » Fri 23. Feb 2024, 11:23

Hi,

you have to do this in your application. You need to get the UTC time when the first frames was received, and use the timestamp from the first message as an offset for the future timings in UTC time. So this is just programming, nothing to do with our API or LabView. As we don't use LabView, we can't tell you how to manage this with this tool.

regards

Michael

Post Reply