From 11:00 PM CDT Friday, Nov 8 - 2:30 PM CDT Saturday, Nov 9, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From 11:00 PM CDT Friday, Nov 8 - 2:30 PM CDT Saturday, Nov 9, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
11-02-2011 04:26 AM
Hi!
I think this is very simple question and might be easy solution but I cannot find it. I have square wave and I'm counting peaks (max and min) and summarize them with add function. This structure is inside while loop so when another iteration takes place it automatically deletes former values and begins counting all over again. I would like program to count peaks until I press stop.
I have attached program and the mention structure is in the bottom part of it.
Thanks for all the help!
Jure
Solved! Go to Solution.
11-02-2011 02:37 PM
At 1387 KB, I don't want to open your VI, but I can suggest a few things.
Look into Peak Detector.vi or Peak Detector PtByPt.vi
Another way since charts have a History, you can read the History (which is an array) with a Property Node and get the array min/max. If you are getting the min/max over a very large dataset, you'll need to store the min/max values into another array, then at the end of the acquisition, perform a min/max on those value. This is necessary because the History length is finite, defaulting to 1024 samples. The same issue occurs with Peak Detector PtByPt.vi - the amount of data you can analyze is finite, and/or constantly overwritten, so storing data into shift registers is inevitably something you have to "get good at" to do this kind of thing on large datasets (i.e. long acquisitions or very fast sampling).
All of this assumes you are looking for amplitudes. You did say Square Wave so maybe you meant period?
11-03-2011 03:56 AM
Hi Jure!
As far as I understand, what you would like to do is sum the 'count' and 'count 2' in consecutive runs of the lower while loop.
You can accomplish this by using shift registers to store values between loop iterations.
If you have further questions, don't hesitate to ask 😉
11-03-2011 04:38 AM
Thanks for answers!
I would like to use shift registers, but on example given you can only use it with for loop? I tried to use them by adding another for loop inside while loop but again, it doesn't remember previus values. Can it be used with for loop? If I use shift register on while loop, final value stays blank...
11-03-2011 05:01 AM - edited 11-03-2011 05:01 AM
Hi,
you can use a shift register with while loop as well - simply drag a wire from the 'x + y' to the edge of the while loop, right click the tunel and select "replace with shift register". Just don't forget to initialize the shift register with 0 at the start of your application. I created a cut down version of your code just to show you the way to do it.
11-03-2011 05:19 AM
Thank you very much! I have added shift registers and everything is workking fine except for some reason it count 10x as much? It shows 1 + 1, but it counts 20, 40, 60,....?
11-03-2011 06:12 AM
You are welcome 🙂
I reviewed your code. My assumption is, that it counts every edge, however you are running the loop as fast as the system allows it to and so you simply cannot see every update. If you want to verify this, put a wait function inside the loop - then you should see individual increments as well.
11-03-2011 06:21 AM
You are right! It goes much faster than I tought. Thanks for all the help, much apreciated!
11-03-2011 06:29 AM
I'm glad that I could have helped.
If you have more questions, please don't hesitate to ask.