09-16-2015 04:44 AM
Hi,
I got this system handed over to me. I'm new to LabView and simply need to save the data that comes from array "Average Voltage"(Inside the while loop) to do some further test of our product.
I'll like it to do similar to this.
1) Save in excel file.
2) Save only when a buttom is pressed and save the next 5 ilteration.
3) Save and manipulate the data, so it is shown in 6 colums(1 from each LED) instead of 1 long colum.
I tried different things with T/F case structure, that solved the buttom-demand. But I'm in doubt of which I should use, Write To Measurement file or Write to Delimited Spreadsheet (Using labview 15.0) to suit my propose best possible?
It also seems to be to much to handle when i try write to txt file, because it pops up with and error that I dont know how to fix, but it is telling this:
Error -200279 occurred
Possible reason(s):
The application is not able to keep up with the hardware acquisition.
Increasing the buffer size, reading the data more frequently, or specifying a fixed number of samples to read instead of reading all available samples might correct the problem.
Property: RelativeTo
Corresponding Value: Current Read Position
Property: Offset
Corresponding Value: 0
Task Name: Analog channel
Thanks in advance
Solved! Go to Solution.
09-16-2015 08:05 AM
The key here is making sure your file writes don't interfere with your data collection.
For this purpose, you should look into the Producer/Consumer Pattern. You should have a separate while loop waiting to do your file write and pass the data along a queue.
Write measurement vs. Write Delimited shouldn't matter much in this case. You said you wanted an Excel file. If that's true, then you'll need to use the Report Generation Toolkit or use ActiveX. If you just want a file that can be read in Excel, I'd recommend Write Delimited.
09-16-2015 10:43 AM
I agree with Taki, but want to make a few additional points:
Bob Schor
09-17-2015 03:44 AM - edited 09-17-2015 03:47 AM
09-17-2015 03:45 AM
I'll look into that pattern, thanks!
And I think i'll just need to use Delimited, thats enough for me.
09-17-2015 04:58 AM
Hi 08anja,
As Taki and Bob said, it's important to consider the dataflow and what you would like the program to do.
The two file functions you cited are both high level file I/O. This means that every time that function is called, it will open a reference to a file, write data to it, and close the reference. This takes time and isn't very efficient. I would recommend instead using a producer-consumer architecture, as well as using low level file I/O functions. The best one for your application, in my opinion, would be the TDMS file format. LabVIEW has functions to open ar eference to a TDMS file, write or read data to/from it, and close the file reference after the process is complete. TDMS files can be quite easily read in Excel with a free add on, and they're essentially a modified binary file so they allow high speed streaming while still retaining the capability to be read in Excel and contain information about the data such as channel names.
The error code you cited is often caused by not reading data fast enough, so you'll likely need to read them at a faster rate, or read multiple samples from your buffer.
As for formatting your data so that it will appear how you like, this shoudl simply come down to array manipulation. I would try probing the wires during exectuion to see what the arrays look like at the moment so you can see how LabVIEW is manipulating them. That way you can then figure out what you need to do to acheive your desired array layout.
Regards,
09-17-2015 07:32 AM
Okey, I hear what you say and tried with the TDMS file but end up doing this. It works okey except that I cannot run the program while having the txt file open. This is not essensital but could be nice 🙂
But what I end up doing is:
It writes my data in the txt file as shown in following document. I also shown what my wanted scenario could look like. What can I do to make it look like the example below?
Scenario at the moment | |||||||||
2,973682 | 2,973655 | 2,973651 | 2,973735 | 2,973671 | 2,973716 | These are from 1. measurement | |||
2,973819 | 2,973866 | 2,97383 | 2,973856 | 2,973832 | 2,973725 | These are from 1. measurement | |||
2,973819 | 2,973866 | 2,97383 | 2,973856 | 2,973832 | 2,973725 | These are from 1. measurement | |||
2,973746 | 2,973829 | 2,973832 | 2,973806 | 2,973856 | 2,973846 | These are from 1. measurement | |||
2,973746 | 2,973829 | 2,973832 | 2,973806 | 2,973856 | 2,973846 | These are from 1. measurement | |||
2,973632 | 2,973656 | 2,973697 | 2,97359 | 2,973703 | 2,97364 | These are from 2. measurement | |||
2,973685 | 2,973792 | 2,973833 | 2,973761 | 2,97354 | 2,973701 | These are from 2. measurement | |||
2,973685 | 2,973792 | 2,973833 | 2,973761 | 2,97354 | 2,973701 | These are from 2. measurement | |||
2,973767 | 2,973743 | 2,973825 | 2,973679 | 2,973746 | 2,973754 | These are from 2. measurement | |||
2,973767 | 2,973743 | 2,973825 | 2,973679 | 2,973746 | 2,973754 | These are from 2. measurement | |||
My wanted scenario ish: | |||||||||
LED # | 1 | 2 | 3 | 4 | 5 | 6 | |||
# of measurement | |||||||||
1 | 2,988309 | 2,988288 | 2,988217 | 2,988285 | 2,988212 | 2,988265 | |||
2,988309 | 2,988288 | 2,988217 | 2,988285 | 2,988212 | 2,988265 | ||||
2,988322 | 2,988305 | 2,988281 | 2,988294 | 2,988293 | 2,98827 | ||||
2,988322 | 2,988305 | 2,988281 | 2,988294 | 2,988293 | 2,98827 | ||||
2,988233 | 2,988247 | 2,98831 | 2,988236 | 2,988268 | 2,988227 | ||||
2 | |||||||||
1,233123 | 2,988288 | 2,988217 | 213 | 2,988212 | 2,988265 | ||||
1,2312 | 2,988288 | 2,988217 | 1,23 | 2,988212 | 2,988265 | ||||
2,988322 | 1,2 | 2,988281 | 2,988294 | 2,988293 | 2,98827 | ||||
1,23 | 2,988305 | 2,988281 | 1,2 | 2,988293 | 2,98827 | ||||
2,988233 | 2,988247 | 2,98831 | 2,988236 | 2,988268 | 2,988227 |
09-17-2015 08:13 AM
To do what you are looking for with your file format, you can either use the TDMS format which will allow you to implement such a structure with the channel names etc. or you can save the data into the file manually. I would highly recommend using the TDMS file format because it's by far the easiest way of doing what you want. If you do feel the need to use an ASCII file format, I would stronlgy advise against using high level file I/O functions like the Write to Delimited Spreadsheet VI because it is much slower and much more memory intesive.
As for opening the file while it is being edited by LabVIEW, I don't believe you will be able to do this.
Regards,
09-18-2015 04:07 AM - edited 09-18-2015 04:23 AM
Okey thanks.
I'll try include the TMDS file instead. But as i have my data in an array. Can i just wire the my data from my array into the Write to Measurement(TMDS) function?
The TMDS is supposed to be created by the Write to Measurement function, right? Or i'm supposed to use those function under file I/0 --> TMD Streaming?
Super, then i'll dont try to do that 😉
09-18-2015 04:38 AM
The Write to Measurement File Express VI is still a high level file I/O function, so to use TDMS streaming you'll need to use the functions under the TDM Streaming palette. You could also have a read through some of the pages here if you're unsure of how to use those functions or you want to know more about how to format your data.
Regards,