LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to file for time

Hi forum,

 

first thanks for all your help here! I am now using a simple state machine (start, recording, logging, stop). I would need a feature that every time i get from the start in the recording state i wirte the data to file for a defined amount of time about (5-10s). 
I was thinking to open a binary file outside the while loop then wirte in the recording state the data to this binary file and in logging read from binary file and write it to a exel or text file. Then empty the file using set file size to 0, so i have every time a empty file to wirite to. 

 

What is the best way to do this thanks for your help again.

Martin

0 Kudos
Message 1 of 15
(2,599 Views)

Sounds like you have a good plan so far. But for no longer than the test going to run, I wouldn't bother with the binary file and just save the intermediate data in a shift-register.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

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

For help with grief and grieving.
0 Kudos
Message 2 of 15
(2,569 Views)

Hi mike,

 

thanks a lot for your answer.

i am sampling 100ks/s on 8channels so it would be a big amount of data or iam fine with a shift register? There are some examples how to save waveformdata in a shift register?

Martin

0 Kudos
Message 3 of 15
(2,562 Views)

It all depends on how you handle it -- but that is a lot of data.., Let me retreat a couple steps and suggest a TDMS file. They are fast and with the (free) add-on from NI they can be read by Excel so you might not need to do the copy at the end.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

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

For help with grief and grieving.
0 Kudos
Message 4 of 15
(2,558 Views)

I would use a Producer/Consumer here.  In short, you will queue up the data to be saved and then use another loop that does nothing but read the queue and save the data.


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
0 Kudos
Message 5 of 15
(2,554 Views)

yes i was thinking about the tdms file, but the problem is i would open and close it in the while loop that makes my pc working a lot.Thats why was thinking to open a file write the data and in the logging state write the data to file and clear the other one. 

How would you create a vi that just wirtes the data to file the first 10s of the state change then stop logging. 

Thanks Martin

0 Kudos
Message 6 of 15
(2,552 Views)

No you can use its API like any other file IO: Open once during initialization, write as much as you want and then close it when you are done with it.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

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

For help with grief and grieving.
0 Kudos
Message 7 of 15
(2,546 Views)

thanks for your answer, yes i know but I have to open it outside the while loop and close it outside, I would need to close the file in the logging state. After logging the daq gets again in the recording state and writes a new logging file, so i would never go out of the while loop.

0 Kudos
Message 8 of 15
(2,542 Views)

Don't know how you are going to be implementing your state machine exactly, but here is one possible solution. Have a shift register that holds the file reference. In the record state check whether the reference is valid (see the comparison palette) and if it's not open the file. If it is valid use the existing reference to write your data. Alternately, you could have the start state open the file reference.

 

In the state where you are reading the data out to resave it, read the data, close the reference and delete the file. Write a null reference to the file reference shift register so it is ready for the next start.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

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

For help with grief and grieving.
0 Kudos
Message 9 of 15
(2,537 Views)

that sound exactly what i am looking for i will try to build it up and then will post it thanks until now.

Martin

0 Kudos
Message 10 of 15
(2,523 Views)