LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data Logging

I've since fixed that error. 

0 Kudos
Message 11 of 18
(926 Views)

Write to TDMS file? How would you do that? I realize that an array is probably not the most sound approach since it would be getting bigger all the time, which is why ideally I want whatever I write to overwrite the previous data.

0 Kudos
Message 12 of 18
(926 Views)

@falafes wrote:

i don't have any data logging implemented. This is also my first time doing it and i am very new to labview so I don't really know how to implement it. Ideally i would write the last value to a text file or write periodically but only store the last value so that it is easily read during start up to pick up where I left off.


LabVIEW ships with plenty of examples, go to HELP > Find Examples...   and search for Files

 

you can do .txt, .csv, .ini, .tdms to name a small few, but in your case, .txt is probably all you'll need  look at the File I/O pallete

 

0 Kudos
Message 13 of 18
(925 Views)

@pjroland1121 wrote:

@falafes wrote:

i don't have any data logging implemented. This is also my first time doing it and i am very new to labview so I don't really know how to implement it. Ideally i would write the last value to a text file or write periodically but only store the last value so that it is easily read during start up to pick up where I left off.


LabVIEW ships with plenty of examples, go to HELP > Find Examples...   and search for Files

 

you can do .txt, .csv, .ini, .tdms to name a small few, but in your case, .txt is probably all you'll need  look at the File I/O pallete

 


The advantage of .tdms is that you can write both the data as a table and a separate property for the current value. You can read the property at startup to set the value - no need to read the data and extract the value. The disadvantage is that it is not human readable, but there is an Excel add-on that allows you to open the file in Excel.

0 Kudos
Message 14 of 18
(912 Views)

Okay i have 2 implementations so far, one for .txt, one for .tdms. Can someone please tell me if one of them will work or if it needs some modifications? Thank you kindly

0 Kudos
Message 15 of 18
(908 Views)

Neither will work as you have them written. For .tdms I was thinking something like below

 

johntrich1971_0-1599155039633.png

 

You need to write your data to channel names. I also put the historical data in a different group, which will show up as a different tab when you open it in Excel. I also recommend opening the file outside of your loop and closing it after your loop ends, although with your low data rate opening and closing inside the loop is not that critical. If you're going to be logging a lot of data I would probably add some code to start a new file once the existing file has reached a maximum. You would then need for your program to look for the last increment of the file on startup.

 

Your text file will not log as you have it written. You will need to go to the end of the file each time - otherwise it will overwrite the existing data.

 

Edited to add: PS - Please ignore the sloppy coding and the Rube-Goldberg code. I threw this together quickly and intentionally did Rube-Goldberg to illustrate what is happening.

0 Kudos
Message 16 of 18
(899 Views)

i realize now that is probably misleading to call this data logging, my apologies. I would actually very much like it to overwrite the existing data as i am only really interested in the latest value. Sorry about the confusion. The code you have does that I presume?

0 Kudos
Message 17 of 18
(890 Views)

OK. You've lost me. You were talking about arrays of clusters earlier, so I thought that you meant that you were collecting data in arrays, but you also wanted to keep the last value. The code that I show does both. It will log the data each time and it will also write a property that keeps only the last value. Try it out and open it in Excel.

 

If you're only wanting to store the latest value then I would return to the .cfg file approach that I first mentioned.

0 Kudos
Message 18 of 18
(883 Views)