09-03-2020 09:52 AM
I've since fixed that error.
09-03-2020 09:53 AM
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.
09-03-2020 09:56 AM
@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
09-03-2020 10:26 AM
@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.
09-03-2020 11:00 AM
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
09-03-2020 12:49 PM - edited 09-03-2020 12:52 PM
Neither will work as you have them written. For .tdms I was thinking something like below
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.
09-03-2020 01:31 PM
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?
09-03-2020 02:10 PM
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.