LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Attempting to write data to file, but getting error 200279

Solved!
Go to solution

I am having trouble when writing data to a file. About 10 seconds into the saving process, I get the error 200279. I have done some research on the topic, but am unable to corect my code. I believe I do not want to increase the buffer size, but would rather, I assume, read the data more frequently. The way I save my file is, before running the VI, I assign a location and name of the file (e.g. data.csv). The date and time is appended to the end of the actual file when the I begin to save the data (e.g. data_07-26-13_122615.csv). If the file does not exist, it creates a new file, then appends data to that file after every loop iteration. The reason I did it this way was so I do not have to worry about running out of memory, but apparently my code is flawed. 

 

save_data.png

 

save_data.png

 

I will include a copy of the flawed section of my code. Any help would be greatly appreciated.

 

Thanks.

0 Kudos
Message 1 of 6
(3,983 Views)
Solution
Accepted by topic author Mike310

Your problem is that writing to disk is slow.  It is slow enough that it is causing your DAQ buffer to overflow and cause the error and loss of data.  What you need to do is implement a Producer/Consumer.  This will put the daq and the logging to disk in seperate loops.  This will allow the DAQ to run at the speed it needs to keep up with incoming samples and the writing to disk can run at whatever rate it can.  You send the DAQ data to the logging loop using a queue.

 

You might also want to think about changing how you write to the file.  That VI is constantly opening and closing the file, which is a very slow process if you are doing it inside of a loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 6
(3,973 Views)

To expand on what has already been said, everything in your code is being done in the most inefficient way possible. For example, in addition to the file write already mentioned, you are using express VIs which are equally inefficient. You are also generating a new path with every iteration of the loop, even when the value isn't being used. Also lose the local variables. Learning about event-driven programming will also help a lot.

 

You are also using a boolean value where you should have an enum with two values (pause and continue).

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 3 of 6
(3,932 Views)

@mikeporter wrote:

You are also using a boolean value where you should have an enum with two values (pause and continue).


Hello Mike,
This particular point isn't clear... If we consider to use an enum (U8 type) or a boolean, LabVIEW stores Boolean data as 8-bit values and I'm not sure about enum (U8), certainly it should be more than 8-bit (to store the string labels)..

What you say??


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 4 of 6
(3,925 Views)

I guess I could have been clearer that the last point wasn't about code efficiency but rather readability and maintainability. 

 

Booleans are correctly used to represent values that are inherently binary; things that can answer questions like yes/no, on/off, true/false. The control in question has two values (or at least is does for now) but there is no inherent logical mapping between true/false and pause/continue. Consequently you have to remember what the mapping is - or if you are inheriting the code - hope whoever wrote it, documented it somewhere.

 

In addition, what happens if in the future this value changes to pause/continue/stop or pause/continue/stop/pause-on-error. Now you have to change this VI and everything that calls it, because you have to change the datatype of the input.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 5 of 6
(3,915 Views)

Thanks everyone for your input and help. This is the first labview program I have written, so I am a complete amateur. And I am finding it somewhat difficult to write labview code that behaves appropriately.

 

I have been attempting to write what crossrulz suggested by implementing a producer/consumer, though am having trouble. I guess I am just somewhat ignorant on the capabilities of the many functions provided. Can anyone explain how I would go about setting up two differing loops for the logging and the DAQ? How would I setup a queue which will integrate the two? When dequeueing data, does the differing timing rates of data being produced and data being logged affect the queue? Should I store the data in the queue until the queue reaches a certain predetermined size, then log and pop off all elements in the queue, then repeat? 

 

I apologize for all the questions, but I am not too familiar with coding with block diagrams.

 

Thanks again for all the help.

 

 

0 Kudos
Message 6 of 6
(3,905 Views)