10-03-2018 03:44 PM - edited 10-03-2018 04:09 PM
Hi everyone. I have a program that reads data from a compact DAQ system (cDAQ-9181, NI 9223 BNC) and writes it to a text file. I'm using the Concatenate Strings function to also add a header with column labels and a date/time stamp at the beginning of the text file.
The issue I've been running into is that when I run the program, sometimes the header shows (img1), and sometimes it doesn't (img2). I'm using the Array to Spreadsheet function for the data (img3 - the two inputs that are cropped out of the image are the date and time strings).
Since it displays correctly (...well, when it does display at all), I figure the formatting isn't an issue, but I've no clue for why it doesn't always get written to the text file. I'm still pretty new to using LabVIEW, so any and all insight to what the problem is or how I can debug is appreciated.
Additionally, this is my first time posting here, so if any additional information is needed, just let me know. Thanks!
Solved! Go to Solution.
10-03-2018 04:03 PM
Can you post the actual VI instead of an image of code? We can't tell what wiring you're actually using. Plus any other mistakes that might lead up to this.
For instance, the text input there appears to go to the top, which is the "Prompt" input and not the "text" input. And there's a wire that we can't tell if it's wired behind the node or into and out of the node, etc.
10-03-2018 04:15 PM
@Kyle97330 wrote:
Can you post the actual VI instead of an image of code? We can't tell what wiring you're actually using. Plus any other mistakes that might lead up to this.
For instance, the text input there appears to go to the top, which is the "Prompt" input and not the "text" input. And there's a wire that we can't tell if it's wired behind the node or into and out of the node, etc.
Sure thing.
Also, for some context - I pretty much took the Finite Input.vi from the Help examples and added onto it the stuff to write to a text file.
10-04-2018 01:34 AM
Hi sagunsm,
I hope you don't use the same file path for the WriteSpreadsheetFile function as you use for your own WriteTextFile function call: in this special case you would create a race condition.
Such race conditions can lead to problems like yours…
I'm not a friend of huge ConcatString functions. Most often you can solve that easier:
For the string constant:
10-04-2018 07:30 AM - edited 10-04-2018 07:34 AM
Hi GerdW,
You're right. It turns out that I've been writing a text file with both the Write To Spreadsheet and Write to Text File functions at different points in the program -- can't believe I missed that! I've simply removed the Write To Spreadsheet block, and now the program works to my liking.
I like your suggestion for how to display the text header as well. I'll have to try it out. Thank you!