postformac Posted April 25, 2009 Report Share Posted April 25, 2009 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 Quote Link to comment
asbo Posted April 25, 2009 Report Share Posted April 25, 2009 Create a cluster that contains both your numeric measurement as well as the time stamp associated with that measurement. Quote Link to comment
postformac Posted April 25, 2009 Author Report Share Posted April 25, 2009 Hi, thanks for the reply. I can do that and it accepts the different data type but then how do I get my table to display the contents of the cluster? Is there a way to convert from a cluster to "dynamic data?"? Quote Link to comment
asbo Posted April 25, 2009 Report Share Posted April 25, 2009 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. Quote Link to comment
postformac Posted April 25, 2009 Author Report Share Posted April 25, 2009 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 Quote Link to comment
crossrulz Posted April 25, 2009 Report Share Posted April 25, 2009 There might be a better way, but create your table like this instead of the express VI. The string array coming from the top is the time string. Quote Link to comment
postformac Posted April 25, 2009 Author Report Share Posted April 25, 2009 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! Quote Link to comment
crossrulz Posted April 25, 2009 Report Share Posted April 25, 2009 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. Quote Link to comment
asbo Posted April 25, 2009 Report Share Posted April 25, 2009 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. Quote Link to comment
postformac Posted April 26, 2009 Author Report Share Posted April 26, 2009 Brilliant, got it working perfectly, thanks for the help guys! I have put the column headings in at the time that the arrays are initialised, as suggested. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.