08-02-2010 04:51 AM
Hello
I am trying to find a way to take data samples from a stream of strain measurements that is input to Labview from a NI 9237. These samples must be written to a file for later analysis. The vi must be capable of recording a burst of data at a user defined interval and sampling rate.
For example record at 10Hz for 10 seconds every 15 minutes.
My attempt at doing this is attached (as you can probably tell see I am quite a beginner at Labview).
In my example I have used a random generator to simulate my data from the NI 9237. By using a for loop I have tried to get the vi to write 5 data points to the file. However it writes the same data point to the file 5 times, instead of 5 successive data points.
Ultimately I would like the vi to write data to the file for a period of time (10 seconds) instead of writing a defined number of data points.
Can anyone please advise how I should go about achieving this?
Many thanks
Solved! Go to Solution.
08-02-2010 07:06 AM
I tried to show in an example what I mean. You can you Notifier operation or Queue elements to trigger the savin loop. It is up to you!
08-02-2010 08:02 AM
Here is how I would do it.
08-03-2010 04:30 AM
Many thanks for the suggestions. I'll give them a try.
Regards
08-04-2010 03:53 AM
Hi,
The reason you get the same value every time is because the random number generator lies outside the for-loop, it will generate a new value every time the while-loop runs another iteration, not the for-loop (so now it will generate a number every 15 minutes).
In this case there is no need to use sequence strucutres (as the previous posts already have showed), but if you use sequence structures you can add another frame to it instead of having two different structures.
Also, is there any particular reason that you don't want to write a specific amount of data points? If you sample uniformly it is easy to calculate how long a certain number of samples will take and if you sample uniformly in the same rate for a specific period of time you will always get the same number of datapoints. 100 samples at 10 Hz will take 10 seconds to acquire. Since you are a beginner in LabView I would recommend that you take a look at Getting Started with NI-DAQmx to get some tips on how you can acquire your data.
Regards
Anders
01-20-2011 08:40 AM
01-20-2011 09:43 AM
Something like this?
01-20-2011 09:45 AM - edited 01-20-2011 09:45 AM
I would create a separate task which is used to write the data. Data to be written to the file can be passed to this task via a queue. You could set values to determine how much data needs to be written and at what intervals. Your data acquisition can post data to the queue. Your queue can be configured so that it will only contain enough entries to hold the amount of burst data you want to save. Any additional data posted to the queue would be dropped. Your write task could be in a loop that periodically checks to see if your time interval has been met. When it does it can dequeue all the elements from the queue and write them to the file. It will go back to waiting for the timer to expire. Now that the queue is empty your data acquisition will be able to fill it again with the next set of data.
NOTE: When you have your logger task pull the data from the queue you should use the queue status vi to grab all of the data at once and then flush it. If you dequeue elements one at a time in a loop your data acquisition task will start filling it again before you have written everything out. This would result in more data getting written to file than you want.
01-24-2011 04:04 AM