LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Temperature sensor data to text file

Solved!
Go to solution

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

0 Kudos
Message 1 of 13
(2,909 Views)

Use File I/O functions.

 

Open File before the loop, Write to Text File within the loop, Close File after the loop.

0 Kudos
Message 2 of 13
(2,907 Views)

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!

Capture.PNG

Thanks again! 

0 Kudos
Message 3 of 13
(2,887 Views)

Hi Aladdin,

 

what do you do with the FileRef you get from FileOpen?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 13
(2,873 Views)

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

0 Kudos
Message 5 of 13
(2,868 Views)

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.

Redhawk
Test Engineer at Moog Inc.

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.

0 Kudos
Message 6 of 13
(2,854 Views)

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!  Capture.PNG

0 Kudos
Message 7 of 13
(2,846 Views)

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.

 

 

Redhawk
Test Engineer at Moog Inc.

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.

0 Kudos
Message 8 of 13
(2,837 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 13
(2,822 Views)

 

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. 

 

Capture.PNG

0 Kudos
Message 10 of 13
(2,816 Views)