LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a h:m:s stamp to a 1-D data array

I am collecting data every 2.5sec. How can I add a time stamp to this that includes the second in which that particular data was collected. I'm also having trouble recording the data in a single column, instead of a long row. Thanks
0 Kudos
Message 1 of 9
(3,621 Views)
Do you want to add time to data that has already been collected, or add the time to the data and write it as the data is being collected?

You can add the time to the data by using the Get Date/Time String VI from the Time & Dialog palette, and wiring that to a Write Characters to File.VI under the File I/O palette. Add a tab to the end of the Date/time string to make it "neat" by combining the time and a Tab with a string concatenation VI before going into the Write Characters to File.VI. After the time has been written, you can write the data value to the file using the Write to spreadsheet file.vi.

This *should* make your data show up in columns instead of rows, as you mentioned.

If you need an example, let me know.

Mark
0 Kudos
Message 2 of 9
(3,621 Views)
Thanks for the response Mark, my hangup was that I didn't have the sec. in my time and date vi, figured out to add a boolean true to turn it on, and the columns instead of rows. I need to add the time as the data is being collected. It seems like I'm getting too repetitive in my methodology, (I was going to add another case structure to build an array of dates and times and add that to the data array), so I sent you the file. Take a look if you have a sec and let me know if that's the way to go, I can just make it a small VI, or if you have a better suggestion. Thanks
Andras
0 Kudos
Message 3 of 9
(3,621 Views)
I can open your VI, but unfortunately, you use two custom subvi's, and I can't load those. Therefore, I'm not able to look at how you get the date/time.

I've modified yours, however, and I'll post it here. See if you like it better.

I've set the VI to run when opened, so you don't have to press the run button at the top left.

Mark
0 Kudos
Message 4 of 9
(3,621 Views)
A lot more than I expected, but thanks. It makes figuring out how to accomplish this a lot simpler. The explanations are great. The one thing I have to add is the automatic naming of the files, I'll let you know if I have trouble with it. Thanks
0 Kudos
Message 5 of 9
(3,621 Views)
Initially i tried running the file by adding your case structure inside my while loop, I've made some slight cosmetic changes since 12/17. This produced a result where the loop is prompting a new file name window at each iteration, after every point, and is slowing the computer down. I remembered what you said about appending to the file instead of saving a new one each time, so i figured the appending was not turned on. The boolean operator said true to "append to file", but within the diagram the corresponding control was set on new file, and continues to say that although I tried to save it with the control pressed in the "append" position. Therefore, I tried inserting my instrument driver into your diagram, with the same repetitive res
ults. I tried to go through step by step but I'm missing something. If you've got more time, please let me know if you can think of a solution.
0 Kudos
Message 6 of 9
(3,621 Views)
Are you using a VI which specifically asks for the filename, or are you letting the VI that writes the data ask for the name when it gets it? We may need to use a shift register on your while loop that contains an empty filename when started, then gets updated with the new filename when the data gets saved the first time.

Mark
0 Kudos
Message 7 of 9
(3,621 Views)
I am actually using a VI which automatically reads the date and time and uses that as the name designation for the file, I tied this into the "file path connection of the "write character to file" vi. However, I kept my vi outside your case structure, which is probably incorrect. In addition, it actually seems to be redundant this way, since I'm realizing that I've been closing to windows asking for file names, one with a predesignated name, from my VI, and one without, your case structures "write to ....". Let me know if this answers your question. I wasn't sure what you were asking. I think 'a VI which specifically asks for the filename' is my date/time VI, and the 'VI that writes the data and asks for the name when it
gets it?' is the "write to ...." VI? Now, I've confused myself. Your solution seems to make sense though, if it keeps repeating the request, the name would have to be carried through to maintain this name for all updated saving of data....
0 Kudos
Message 8 of 9
(3,621 Views)
I was thinking more like this!

Mark
0 Kudos
Message 9 of 9
(3,621 Views)