10-01-2020 05:31 AM
I cannot open the VI, I am using LV 2017 version. Your version is different than mine. Can you please upload it again ?
10-01-2020 07:06 AM
Please, ignore my ignorance. Can you please tell me about how you did it step by step ?
10-01-2020 11:37 AM - edited 10-01-2020 11:40 AM
Saved for 2017.
I included comments of @altenbach's algorithm in my .vi, but here it is in pictures, in case it helps:
We find the mean and offset the graph by that amount. So, now it's centered around 0.
This part may look weird, but it's each element of the array multiplied by the next element in the array.
Result: For each instance that the original graph crosses zero, there is a negative (*barely* less than zero) value.
So here are all the less-than-zeroes of the multiplied graph:
And here are those cursors super-imposed onto the shifted graph:
We then find the most extreme value (either max or min) in between each set of vertical (yellow) cursors.
(It just dawned on me...I hope you're not colorblind.)
These extrema (maxima and minima) are shown with red cursors here:
@altenbach then used that information to produce this graph:
All I really added to the .vi was a way to sort whether each extreme was a max or min.
I then index the maxima and minima separately to create a "max" array and "min" array, from which the peak-to-peak value was derived.
Also, kudos to this post (also by @altenbach) that taught me how to do the vertical cursors.
-joeorbob
10-02-2020 04:47 AM
Thanks for your help. This method is queit good but i still am having problems with it. Like it sometimes does not take a Max or min point at the start of the graph and in the end of the graph it takes the mid value which is not the max or min point. I have attach the image to address my concerns
10-02-2020 05:50 AM - edited 10-02-2020 05:51 AM
@Pukhtun_Yum wrote:
Thanks for your help. This method is queit good but i still am having problems with it. Like it sometimes does not take a Max or min point at the start of the graph and in the end of the graph it takes the mid value which is not the max or min point. I have attach the image to address my concerns
That's why I said "probably needs a few tweaks depending on the phase near the edges.". Would be easy to fix on both sides, but I left it out for simplicity.
On the left, we need to check if the first points of the data is descending or ascending and on right left we need to make sure that we ignore maxima unless both sides have a zero crossing. What have you tried?
If you think you need help with that, attach the new data.
10-02-2020 08:50 AM
Hey, thanks for your guidance. I tried to figure it out but was unable to do it. Can you please have a look and fix this issue.
10-02-2020 01:22 PM
For the left side, start with index zero instead of the first zero crossing. For the left side, make the two auto-indexing output tunnels conditional and wire the loop termination condition to their lower input. (I actually already designed for that by using the unusual "continue if true" mode)
This works for the current data. Of course you need to make it "slightly smarter" so it detects if there is a peak (or not!) before/after the last zero crossing. (not shown). A simple solution would be to only make the correction to the autoindexing tunnels as described. This way it will only count extrema that are between zero crossings. While that would drop the first peak here, maybe that's a loss we can take.
Another option would be to look for zero crossings in the second derivative. (also not show), giving the peaks directly!
You just need to be a bit more creative. 😉
10-02-2020 04:25 PM
@altenbach wrote:
Another option would be to look for zero crossings in the second derivative. (also not show), giving the peaks directly!
You just need to be a bit more creative. 😉
Here's a version that uses the zero crossings of the first derivative to find the starting index and ending condition.
The derivative is a simple finite difference, so it's pretty susceptible to noise - that's why I still used @altenbach's code for the main algorithm, instead of finding the peaks directly.
Anyway, it's a fish for you. Learn from it what you can.
-joeorbob
(P.S. @altenbach, how close am I to making some Rube Goldberg Code? 😁)
10-02-2020 06:49 PM
@User002 wrote:
(P.S. @altenbach, how close am I to making some Rube Goldberg Code? 😁)
I was able to simplify it "slightly" by adding some filtering to the derivative before finding the zero crossings. Note that anything that exclusively contributes to the 2D array can be deleted because it is just for display. Also note that due to the filtering, the result might not agree exactly.
I still like my original better because it might show trends how the amplitude behaves as a function of time.
10-12-2020 10:41 AM
Thanks again for your contineous help. I have been busy with other stuff and now I am back to the VI that you helped me in. I understood the logic of the VI but not 100%. Thats why I am still facing problems in it, The data that i am recieving from DAQ is not pure sine and because of that the VI takes min max points at the mid of the wave as shown in the images that i have attached. Can you guide me about what to be done so that the VI just takes only the MAX and MIN points and not any other ?