07-31-2017 09:04 AM
Two questions here:
1. How to I take a continuous semi-infinite number of measurements from start to a push button stop.
2. How to get the results to write to file after the stop.
My current VI is attached, I have tried different methods but so far can only get it to stop and write to file after a set number of samples.
07-31-2017 09:11 AM
Hi dflynn,
1. You already do that: take readings as soon as you start your VI until you stop it…
2. Then you should place the WriteFile function after the loop! THINK DATAFLOW!
But: why do you want this? You would need to collect all data in the loop in (possibly) huge arrays - no fun…
Btw. do yor really want to ask for a file name in each iteration? Really?
07-31-2017 09:13 AM
You have "crippled your understanding" (in my humble opinion) by using Express VIs. Here is what you really want to do:
The logic is simple when stated this way, but gets "clouded over" when buried within an Express VI.
I (almost) never use Express VIs, so it is possible that my "solution" here is not correct, but I think the option "If a file already exists, Append to File" is what you want to do in Express-VI Land. You also want to Save to One File and Ask User to Choose, but only once.
See if that makes a difference.
Bob Schor
07-31-2017 09:14 AM
The problem is your DAQ Assistant settings. Your loop will stop when you get an error. And I'm certain you'll get a timeout error because you are requesting 1 million samples, but at a rate of 5000 Hz. That would take 200 seconds to acquire, but the default timeout value is 10 seconds. You'll only windup with 50,000 samples, the function will timeout and the loop will end.
Try acquiring a smaller number of samples such as 5000 and it will write data every one second.
The next steps you'll need to learn are to get rid of the Express VI's, and perhaps use a producer consumer architecture to separate the file writing from the acquisition.
07-31-2017 09:16 AM
Do not read so many samples per iteration. 1M samples at a 5kHz rate is 200 seconds worth of data. So you can only stop your loop every 3.33333 minutes! And that is assuming the stop button is read after the read (not likely). So the delay will be more like 6.5 minutes to stop your VI! So cut the number of samples to read down to something more like 500. This would be 100ms worth of data, making your VI a lot more responsive (ie, each iteration of the loop will be 100ms, meaning your stop condition will be checked every 100ms).
Also, there is a "Stopped" output of the DAQ Assistant that you should be using to stop your loop.
07-31-2017 09:35 AM
Wow thanks for all of the fast answers! I'll break replies up into pieces to try making it easier to follow.
GerdW, I should have phrased that differently. Normally my application is testing a product line where I run one or two 4 second tests on a product, then change over to another product and repeat. So yes, as annoying as it is to be asked for a file name each time it works for my application.
I have a different test coming up where I need to compare two products performing a similar task, so my total time is unknown. One could last 10 seconds, the other could last 10 minutes but I have no way of knowing until the tests are run so running the program based off set samples/frequency could get me in trouble as I only have one shot at capturing the data.
I suppose I can turn my frequency way down for this application in an attempt to save memory and speed up the process. I want to hit start, capture data for however long the test runs, then hit stop and export the data rather than relying on a set number of samples. I will be moving the move samples out of the loop as well, sounds like that will solve an issue with my normal testing!
07-31-2017 09:41 AM
Bob_Schor, I agree that using Express VIs is kind of cheating and limiting myself but at the moment I am only doing basic data collection so the more simple my program the better. Need to keep it so myself and my fellow mechanical engineers who have never used LabView before can understand. I'll look further into "If a file already exists, Append to File" and see how it will work.
07-31-2017 09:42 AM
RavensFan, is there a way to bypass the DAQ Assistant sample settings?
07-31-2017 09:46 AM
You can open up the Express VI and change the settings to something else.
But better is to open up the Example Finder and search for the examples using the actual DAQmx functions.
07-31-2017 09:47 AM
Crossrulz, if I understand right do you mean that I can create smaller loops, then combine them into one write file to increase performance?