08-09-2010 12:49 PM
The NI-CAN doc talks about the NC_ATTR_TIMESTAMP_FORMAT attribute being available in the frame API. I set this to relative using my USB 8473 w/sync. I'm not sure how to process the received timestamp field though. The doc only talks about timestamp format being NCTYPE_ABS_TIME and make no reference to the format of the parameter when using relative timestamps.
So, how do I make use of relative timestamps? What is the actual bit/type format of the timestamp field when the device is set to relative time?
08-10-2010 10:42 AM
Hi Jeremy,
The relative format provides a double value representing the number of seconds since the beginning of your task. For more information, see page 11-103 of the CAN hardware & software manual, linked here:
CAN Hardware & Software Manual: http://www.ni.com/pdf/manuals/370289k.pdf
Let me know if theres anything I can clarify!
08-10-2010 10:49 AM
Thanks for the reply. There's still an aspect of this that I'm not understanding though. When I receive frames using ncRead, I'm going to get NCTYPE_CAN_STRUCT. That has a Timestamp field which is NCTYPE_ABS_TIME. That itself is structure of 2 32-bit values, not an individual double value.
So, is there some special way I need to typecast or handle the Timestamp field in order to really get a final decimal value since start time in seconds?
08-11-2010 04:55 PM
Hi JaremyP,
The relative and absolute timestamp data will be formatted in the same manner, so you will be able to treat the relative time data exactly like you would treat absolute data, the only difference being in the conversion from the seconds value to the date/time format if this is something you are doing in your code. If you are not sure how to get from the NCTYPE_ABS_TIME struct of 2 32 bit values to the double value for either time format, let me know and I can look into more details on that process
08-12-2010 07:32 AM
That number conversion is where I'm stumped. If you could get more details and perhaps supply a C code sample converting the NCTYPE_ABS_TIME struct to a final double value in relative seconds, I would very much appreciate it. Thanks!
08-13-2010 04:33 PM
Hi JeramyP,
The absolute time data contains the upper and lower portions of a 64 bit integer representing nanoseconds since the time start. combining the two components, then converting to seconds through division will allow you to get a double representation of the seconds. For more information, check out this article on datetime manipulation (the absolute time struct is a FILETIME struct):
http://www.codeproject.com/KB/datetime/winapi_datetime_ops.aspx?display=Print
Let me know if I can do anything else to help!
08-16-2010 07:01 AM
I believe it actually represents 100ns, not 1ns, ticks since start...
08-17-2010 10:11 AM
GPIB Guru,
You are correct - each tick is 100ns. Sorry for the confusion!