LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How-to set pre-specified time for amplitude measurement vi?

In acquiring data at 100 Hz, I'm writing this to file while using the Amplitude & Level measurement VI to decide when the data has peaked. I've built arrays to accumulate the data but I don't see a simple timing scheme to continue this for one or five minutes.

This is a GPIB instrument read over a GPIB-USB-B adapter in LV 7.0 running on Windows XP Pro. The computer is a Pentium 4, 2.4 GHz, with 512 MB RAM.
0 Kudos
Message 1 of 6
(3,198 Views)
Since I am using 6.1, I cant see your attah. But sound like you want to acquire your data only for five min. Then you just use the while loop or for loop with "Wait Until Next ms Multiple", then you calculate your time. For example, your loop interval is 1ms then 5mins, how many times. Or you can use the real time clock in labview. Use "Get Date/Time In Seconds" and then you compare your time. But all this is machine dependent. If you change your PC, nobody know what will happen. ANd another issue is if your acquisition is take some times, then i think all the above solution may not accurate.
SO suggestion here is if you want to stop exectly at 5 mins, then you might want to use parallel loop. check your time in the parallel loop and if timer == 5 mins, then go to s
ome other state. But it is not recommend again. You may not know what your instrument is doing. So a few factor you have to think about. Post your VI in 6.1 then I can take a look.
------------------------------------------------------------------
When you feel sad, laugh
0 Kudos
Message 2 of 6
(3,198 Views)
I saw your code and it looks like you are writing the data to file with the Write LV Measurement File. If you go to the property page, you will see that it is set to overwrite existing files so you will only get the last file that is written. You can change it to append, or you might perfer, like the previous poster suggested, just collecting all of your data and writing it to file once outside of the loop.

If you want to be sophisticated, look in the LabVIEW shipping examples (open LabVIEW >> help >> find examples and search for file i/o) for examples on writing to files. It is generally not too bad to write your own customized file writing utlities once you learn the basics. Plus you can add all the bells and whistles you want.

Look in the LabVIEW
user manual (open Labview >> help >> search the LabVIEW bookshelf) for an overview of the file i/o functions
0 Kudos
Message 3 of 6
(3,198 Views)
Thanks! I'm actually looking to stop writing to file based on detection of the peak event. I'll then execute other post-acquisition code to analyze the collected data and save that to a different file. At that point, I'll also have an option of saving the raw data or a condensed, "significant-points- or averaged-only" file.

I've also tried to collect a sequence of arrays to build up to 10,000 points before executing the (Amplitude ... VI) but it doesn't seem to impact the measurements. The timing is still unknown but I think that's the least of my problems.
0 Kudos
Message 4 of 6
(3,198 Views)
So I do not have the Fluke or the driver to see how your code runs. From what LabVIEW tells me with the wire size, it looks like you are reading one point at a time from the instrument. You will need to address this so you can get useful data. It is not that reading one point at a time is bad--it just slow. Often it is more desirable to collect more than one point at a time to get a fixed dt between the points. I would focus on seeing the data in a graph first.

Once you are able to get the data comming in a numeric array then you can focus on termiating the acquistion when a peak is found. There are several ways to define a peak. You can say it is a point that is larger than the surrounding points but this will only show a local maximum. Noise will often cause a peak to be undesirably found. Another method for peak detection takes in account hysterisis. This says that if a high value is n units higher than later points, it must have been a peak. Look for hysterisis on NI's site for a better description. Another method for peak detection says that any values above x is a peak. This is useful if you want to collect data that is rising until 6V. LabVIEW has some VIs for peak dection on arrays. I recommend playing with them but remember you will need to decide what works best in your application.

Now that you have data in the form of an array and a way to analyze it, you are in business. Well almost. How much time can elapse between aquiring data and analyzing it. If it is not critical, you can aquire 1000 points, analyze it, determine if you need to aquire more (use a while loop) and iterate or not. If the timming is more critical then you can use a model for VIs where there are two while loops in parallel. In one loop, you can aquire data and feed it to a queue. This allows data to be transfered to the second loop that can dequeue the data and analyze it. When the analysis indicates the data acquision loop can be triggered to stop when it returns with data. This method allows for data to be streamed off the device as fast as possible and then later processed in another loop while the VI is waiting for more data. It is very slick and difficult to code. Look in the LabVIEW shipping examples for queue to see examples of queue use. This data processing loop can write to file as the data is avaliable (slow) or it can save the data and write to the file at one time once the peak has been detected (fast). You can even add logic to only write data up to the peak. (the ease of this depends on how to detect the peak).

I do not know if I have helped or not. It is a lot of stuff to consider. I recommend looking for a simmilar example program. This can really jumpstart any project. Look in the shipping examples and use the advanced search page. I cannot say enough good things about how well that searches NI's site for example programs, knowledgebase articles, discussions, etc.
0 Kudos
Message 5 of 6
(3,198 Views)
Many thanks for such excellent pointers to specific help features (and the caution on trying to overachieve a fairly simple task !).

You're correct in the one-point-at-a-time data acquisition. I've been lazy in simply taking one part of the prewritten driver and using that for reading the data continuously. I'll go back and examine the Fluke driver to look for more functionality. A most helpful item would be to limit the data to ~2 Hz. That's plenty for my needs just now.

I'll look at the shipping examples to see if I can find a suitable example.

Chris Nelson, one of our Minneapolis sales engineers, suggested building an array before running the Amplitude & Level Measurement VI. Apparently, the latter works on each chunk of data
fed to it if one keeps the "original segments" size. Therefore, building an array of 1000 points or so would allow meaningful peak detection.

In an initial trial of this, I found that I could collect 10,000 points at ~50 Hz and still process data continuously. However, the peaks reported were changing faster than expected: about every 2 seconds instead of every 200 seconds. I'll try this again with a pre-specified size of 10,000 points and see what happens.
0 Kudos
Message 6 of 6
(3,198 Views)