07-23-2020 08:18 AM
Hi,
I’m building a temperature sensor VI and I want to collect a sample every second and write the sample to a text file. The VI works fine for me however I’m struggling with text file generation. I tried to use “format into string” and wire it to “easy text file report” but didn’t work for me. I’m sure I’m missing something, and I would really appreciate any correction or feedback. VI is attached.
Thanks
Solved! Go to Solution.
07-23-2020 08:21 AM
Use File I/O functions.
Open File before the loop, Write to Text File within the loop, Close File after the loop.
07-23-2020 08:57 AM
Thanks for the feedback, I really appreciate your time and effort! I tried your method and I had no errors so far but didn’t get any results either! I think I’m wring something here incorrectly! Check out my screen capture!
Thanks again!
07-23-2020 09:07 AM
07-23-2020 09:17 AM
Hi GerdW,
Honestly, I have never used text file generation before and reading the documentations on here https://zone.ni.com/reference/en-XX/help/371361R-01/lvreport/report_gen_vis/ and http://zone.ni.com/reference/en-XX/help/370274M-01/lvoffice/word_format_text/ didn’t quite help me! I’m sure there are several methods to achieve this. However, the final VI I constructed, is not showing any error messages so I don’t really which wire is missing! here is my VI
Thanks for the help
07-23-2020 09:26 AM
GerdW is implying that you need to wire the 'refnum out' of Open/Create/Replace File to the 'file' input of Write To Text File.
Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.
07-23-2020 09:32 AM
Thanks Andrew, I guess I’m on the right track at the moment. After finish the wiring and running my VI I’m still not getting a text file!
07-23-2020 09:46 AM
Well, you haven't wired anything to the 'operation' input of O/C/R File, and the default is to just open, so that's a thing. You need to wire an enum that includes 'create' as that is what you are trying to do. The specific option you choose for that must be decided on based on your needs.
Also... Do you want a dialog box to come up every time, asking the user what to name the file and where to save it? If not, you might want to think about where you want the files saved and also think of a dynamic way to name and organize the files.
Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.
07-23-2020 10:18 AM
Are you developing an application a myRIO? That's what it looks like from your images. So keep in mind that the myRIO is actually a separate computer. It cannot directly save data to your PC. And it really does not have a UI. So the file dialog will not come up from the Open/Create/Replace File function. You need to wire up a path pointing to a location on your myRIO to save the data to. You can then use FTP or WebDAV to copy the file off.
07-23-2020 10:28 AM - edited 07-23-2020 10:44 AM
Thank you guys for the help! After reading the feedback from all of you I got the general idea here however still failing to generate a text file.
Yes, I’m using myRIO and temp. sensor. The sensor and the main program are working fine. The issue is generating a text file. I'm getting "enumeration conflict" Here is my latest trial, screen capture and latest VI.