LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a timeout for a write to measurement file operation?

Solved!
Go to solution

Hi,

 

I have a question that I believe will produce a very simple and straightforward answer but I am not sure how to approach it.  I am writing data to a LabVIEW measurement file and am enabling the write to measurement file subVI with a simple boolean button (i.e. When the button is clicked data is being saved and vice versa).  Instead of having to click the button a second time to stop saving data I would like for it to reset itself after a certain period of time so that all of my files end up being the same size and scale.  I'd like to think that all I need to do is use one of the timing functions (Functions->Programming->Timing), but I don't know which one.  Any help will be appreciated.

 

Thank You,

bsteinma

0 Kudos
Message 1 of 9
(3,578 Views)

Try using the Elapsed Time Express VI.

 

See attached.

Message 2 of 9
(3,559 Views)

Hi Ravens Fan,

 

If I wanted to place a button that will start the timer and begin saving after being pushed then stop after the time has run out where would I place it.

 

Thanks,

bsteinma

0 Kudos
Message 3 of 9
(3,544 Views)
Solution
Accepted by topic author bsteinma
It's there.  That is what the button marked "Save" does.  You would just need to put your file writing code in the case structure as well.
Message 4 of 9
(3,532 Views)

Thanks Raven Fan,

 

That worked.

0 Kudos
Message 5 of 9
(3,519 Views)

The timeout function works well but I hadn't checked the file I was saving to in order to make sure that was alright.  For some reason the file is much larger than it should be.  I am using the write to measurement file vi and am opening the files up in Excel.  I am acquiring data using the DAQ assistant, to read 1800 samples at 300 Hz.  When using the timeout code that you prepared for me, even if I only save data for 6 seconds, I get several thousand data points in the saved file.  I don't know why this is happening because it doesn't do that without the code I used from you.  Could you help me follow your code so I know what each portion does.  Does it have anything to do with where I placed the  write to measurement file vi.

 

Thanks,

bsteinma 

0 Kudos
Message 6 of 9
(3,505 Views)

It is kind of hard to debug unless you post your code. Smiley Wink

0 Kudos
Message 7 of 9
(3,497 Views)

Hey Ravens Fan,

 

I've posted the code I have before adding the changes and after.

 

Thanks,

bsteinma

Download All
0 Kudos
Message 8 of 9
(3,488 Views)

Does the before code work the way you want it to?  If not, what do you want it to do?

 

The problem with the after code which uses the elapsed time structure is that now you've added the DAQ assistant, you've changed the timing mechanism of your code.  Now the DAQ assistant collecting 1800 samples at 300 Hz, takes 6 seconds to collect the data.  That doesn't seem like a problem.  But the elapsed time structure occurs later.  So it takes 6 seconds to run before those while loops end.  In that time, the loops are running every 10 milliseconds putting the same dynamic data (blue wire) over and over again in the Express VI.

 

Since the DAQ Assistant sets your timing, I would go back to the before picture.  If anything, you may want to put the save button in a small sequence structure with an error wire running through it so that the DAQ assistant is assured to complete before the Save button is read.  That way if you click save in the middle of the 6 seconds, the data will be saved on that iteration of the loop rather than the next iteration of the loop and the next 6 seconds.

0 Kudos
Message 9 of 9
(3,480 Views)