LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving multiple data to file from NI

Solved!
Go to solution

Hi all, 
I am currently trying to make a program, where I am logging 11 temperatures, and want to save this to a text file. I am using the NI9213 module.

I have made headers for the temperatures, as the locations need to be added at some point. However, when I run the program, the dialog box comes up first, and only the headers are saved.

 

I have made tried using the append file function, but it does not work..

I also tried removing the headers, however the dialog box does not always show, and half of the time, the data is not saved.

 

Any ideas what to do and how to fix it? 🙂

Thanks! Please ask if something is unclear.

cha_au_0-1737984216472.png

 

0 Kudos
Message 1 of 4
(117 Views)

Hi cha,

 


@cha_au wrote:

I have made headers for the temperatures, as the locations need to be added at some point. However, when I run the program, the dialog box comes up first, and only the headers are saved.

 

I have made tried using the append file function, but it does not work..

I also tried removing the headers, however the dialog box does not always show, and half of the time, the data is not saved.


The answer is: THINK DATAFLOW!

 

As the FileWrite function is called AFTER the loop finishes you get only the header until then.

When you want to save data in the loop then you need to save the data in the loop...

Best regards,
GerdW


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

Hi, 

I see the point. So I need to put the save data inside the while loop? 

I actually followed this tutorial, where they do it outside the while loop.

NI-DAQmx multi-channel data acquisition LabVIEW program - YouTube

 

But without the headers, it sometimes saves all the data. Isn't the point of the shift register, that they give a value each cycle? So all the values from the shift register will be saved? 

0 Kudos
Message 3 of 4
(105 Views)
Solution
Accepted by topic author cha_au
  • Your data only gets saved if you stop the loop using the stop terminal. If you abort the VI instead, any code after the while loop will not execute.
  • It is a really (really!) bad idea to save after the loop, because all data will be lost e.g. if a crash or power failure occurs.
  • Most of your shift registers are not initialized (unless there is a wire we cannot see hidden under the loop), meaning they might contains huge amounts of stale data from previous runs.
  • You are also accumulate ever-growing arrays and if the VI runs forever, you'll eventually run out of memory. Way before that, you will get performance issues due to allocation problems.
  • Even if you would save after the loop, all you need is one shift register with a 2D array where you append a row. 12x fewer wires! (Still, don't do it. Save inside the loop!)
  • Since you want all data, just open the file (and write the headers) before the loop, append a row of data with every iteration, and close the file after the loop. The memory use will be small and constant.
  • Don't learn LabVIEW from Youtube, there is a lot of garbage out there! The right place is here in the forum and the learning resources listed at the top.
0 Kudos
Message 4 of 4
(61 Views)