10-12-2012 12:31 AM
Hello everyone..
I am currently working on a project in which I have to read the data from a unit and display that data using LabVIEW. I am using serial communication for reading the data. The read data is in hex format.
Now, I want to convert this hex string to a time stamp value. I am reading total 16 bytes. How to convert this hex data to a time stamp value. I have developed a VI. But I want to know that the displayed time stamp is correct or not? Or suggest me some other solution.
I am using LabVIEW 2011.
Thanks & Regards,
Manisha
10-12-2012 12:50 AM
Hi mancan,
As Iam using LV2009 Iam unable to open your example.Anyway for converting hex to time stamp
10-12-2012 01:03 AM
Thanks Danil for ypur quick reply.
I have tried that but it is giving me error. I have posted my VI with LabVIEW 2009 and the error. Please suggest me if am wrong.
Thanks & Regards,
Manisha
10-12-2012 06:20 AM
Please tell us the constitution of the string and we can then try and extract some meaningfull data out of it.
10-12-2012 06:36 AM
Thanks Danil and Ace,
I have solved that problem by modifying the code at hardware side.
Thanks & Regards,
Manisha
01-14-2013 10:23 PM
A very late response, however for reference, a solution to your problem would be similar to the example I'm attaching. In this example, a timestamp in generated and converted to date/time. All of the fields are converted to an I8 except for the fractional seconds. That field is multiplied by 100 (2 decimal places) and then converted to an I8. Each value is cast to a string, and then concatinated. The cast process will create a the equivilent hex string.
Converting from hex string to timestamp is simplified if your string is an U8 or I8 (for time it should be the same thing since there shouldn't be negative time) because you can use string to byte array. The byte array will now each time value seperated in the same order of the string. Using the index array, and the date/time to seconds, you can bundle each element to create your timestamp. The seconds to date/time can be used with the bundle to fill in any missing fields. For example, if you timestamp only has hour:min:sec:hsec, you can still have todays date in your timestamp. Sorry I didn't see this post till now, however I hope this helps you in the future.
01-14-2013 10:59 PM
Thank you Mr_Steve.
Thanks for this solution. But I have already done modification at hardware side for this problem. But this will definitely help me in future.
Thanks & Regards,
Manisha