Jump to content

Adding time stamp to array


Recommended Posts

Hi,

I have my LV program taking a number of readings from two channels on an external device and displaying them through two numeric indicators. This works fine and I can build the readings into a 2D array for display in a table or logging to a file. I want to add time stamps for each set of readings but am having difficulty with the data types as time stamps seem to have their own specific type. I cant simply add the time stamp as an element in my array as it gives me errors with broken wires.

I have tried convering the time stamp to a numeric value and it works but it no longer looks like a recognisable time stamp. I have also tried converting my time stamp to a string and both my numeric inputs to strings which then enables me to build them all together in a 2D array but I can't get it into the correct dynamic data type for use in the table.

I have also tried using the "include time stamp" option in the build table function, but this gives me a separate time stamp for each of my input elements, so I get two time stamps per row when I only want one.

What I am trying to achieve is to display a table that shows both of my measurements and a single time stamp on each row

Thanks

Link to comment

What kind of table are you using that it takes a dynamic data input? A normal table takes a 2D string array. If you typecast both the numeric and the time stamp to strings, you can use a Build Array to create the proper input for the table.

You may not actually need the cluster - your circumstances aren't very clear. You should probably post a screenshot of your VI.

Link to comment

My actual VI that I am working on has lots of extra stuff in it and requires the input from the instrument to have the data to put in the table, so I've made a quick example VI to show basically what I am trying to do:

Download File:post-15022-1240590018.vi

The VI runs a loop and just adds 1 to a value each iteration to simulate the data from the instrument. The values are collected together in arrays and this is built into a 2D array before being put into the table. I also collect a time stamp once per iteration and build them in a separate array which I have just output to an array indicator to show the contents. What I want to do is have all 3 arrays in the same table, one per column, so that on each row I have a time stamp and the 2 "measurement" values.

Thanks

Link to comment

Ok brilliant, I tried that and it works well. I have also moved the table output inside the loop so that it appears to update the table one line at a time as the program runs. I have made it output the data to a comma seperated file which also works, and shows all of the data correctly in notepad or excell.

Is there any easy way to get it to add column headings for the output file, or do I need to do this manually by ensuring that the first item of data for each array is the column heading?

Thanks very much for the help!

Link to comment

QUOTE (postformac @ Apr 24 2009, 02:49 PM)

Is there any easy way to get it to add column headings for the output file, or do I need to do this manually by ensuring that the first item of data for each array is the column heading?

Yep, put the heading as the first row in the array. In case you didn't know, you can use the comma delimited file and make the extension a .csv (instead of .txt) and windows will automatically think it is an Excel file.

Link to comment

If you have an initialization sequence/state of some sort, that would be a great place to just pre-fill the headers; unless you're not streaming data to the file per acquisition, in which case you can use Build Array to prefix your data array with a row of headers like crossrulz described.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.