LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read/Write text files in LabVIEW

We have developed an instrument control and data acquisition system for a mass spectrometer using LabVIEW FPGA. Currently we have 6 counters on the FPGA, counting for 1 second intervals and transferring data to the host using a FIFO. 

 

The data, as a local variable, is used in several different parallel loops on the host. One of these is coded to write the data to a text file. Unfortunately everything we have tried has failed. It is proving impossible using either the write to file VI provided with labVIEW, or to use the Open file, write and close file utilities. Each attempt has failed. Yet when running a dummy code we can write to files. The dummy code consists of 6 random number generators running in one loop and the write to file VI in a second loop. The random numbers are transferred across the loops as local variables.

 

Can anyone offer any advice as to what we might be doing wrong. We're beginning to feel as though we are banging our heads against a brick wall and getting very frustrated.

 

Many thanks in advance for any suggestions.

0 Kudos
Message 1 of 8
(5,449 Views)

Hi Paul,

 

you neither say, what is failing nor do you show any code... How should we help then?

 

"impossible using ... the write to file VI"

Well, usually they work just fine.

 

"Each attempt has failed."

In which way? Error number given? Did you use the debuging tools, like probing, breakpoints and highlighting?

 

"as local variables."

It seems you're not properly do program "real" LabVIEW code Smiley Wink

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(5,436 Views)

Gerd, I'm writing this from home and don't have a copy of the code with me to post, or a copy of the error codes and messages. I'll post these tomorrow.

 

Maybe my understanding of the relationship between the FPGA and the HOST is incorrect. We can transfer the data to the host. On the host we both manipulate, display the integrated counts and plot the data on charts and graphs without any problems. The only issue is when we try to write this data to a .txt file. From memory the error relates to inability to create, or open a file. Of course it may be a simple problem of incorrectly specifying the path etc. but I don't think so!

 

Anyway, I'll post the code tomorrow and hope you might be able to give some advice.

0 Kudos
Message 3 of 8
(5,424 Views)

Attached is a simple piece of code that runs fine on my laptop, but when I embed it in the Host vi. does not write to a data file. I get no errors when it runs but the file is empty?

0 Kudos
Message 4 of 8
(5,382 Views)

Hi Paul

 

Really simple error this one, all we will need to do is alter the "operation" terminal of the Open/Create/Replace File.VI. Currently with a "0" wired in, the VI can only open an existing file. If we change this to "4" it will allow the VI to replace or create.

 

Attached is a screen shot that highlights this.

 

Top Tip: press "ctrl" + "H"  to view the context help. I use it all the time as it highlights the VI you are currently hovering over and discusses its terminals inputs and outputs.

 

Hope this helps, Still got some issues? Be sure to post back!

 

Regards

Richard S
Applications Engineer
Certified LabVIEW Associate Developer
National Instruments UK&Ireland
0 Kudos
Message 5 of 8
(5,342 Views)

The attachment!

Richard S
Applications Engineer
Certified LabVIEW Associate Developer
National Instruments UK&Ireland
0 Kudos
Message 6 of 8
(5,340 Views)

Richard, many thanks for the suggestion. I have already tried this and still I get no joy. Is the issue that I'm implementing this code on the host side of an fpga project?

 

Really, this should not be so difficult but is proving to be a great frustration. 

0 Kudos
Message 7 of 8
(5,308 Views)

In general, you're doing fine with fetching data from the FPGA via some host VI(s) and streaming them to a file.

Just a few hints:

You can right-click on any terminal of the File-IO (and any other) Sub-Vis and select "create->constant". Now, an enum constant with the specific meaning is created for this input.

Why don't you use the [i] terminal of the while-loop (or a for-loop) to control the number of iterations?

 

regards

_________________________
CLA
0 Kudos
Message 8 of 8
(5,295 Views)