06-25-2014 01:29 PM
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
06-25-2014 04:15 PM - edited 06-25-2014 04:16 PM
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...
06-25-2014 04:27 PM
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
06-25-2014 04:34 PM
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...
06-25-2014 04:44 PM
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.
06-25-2014 04:45 PM
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
06-25-2014 04:51 PM
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...
06-25-2014 04:56 PM
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.
06-25-2014 05:06 PM
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...
06-25-2014 05:56 PM
that sound exactly what i am looking for i will try to build it up and then will post it thanks until now.
Martin