04-17-2013 03:20 AM
Good Morning,
I am trying to develop a VI for peak detection. I am using a USB CDAQ to measure strain values from strain gauges while running a vibration test on the particular components. I want to be able to detect the peak and trough values for each individual strain measurement throughout the test. Also with the ability of resetting the peak trough values.
Here is my line of thinking (just cant figure out how to do it exactly in LabVIEW):
1. Read in 1D array of strain.
2. Are individual values of strain in the array greater than the values from the previous iteration?
3. If YES, store the new values in another array to show a peak column
4. If NO, retain the same value in the in the peak column.
I have done something along the linee in the attached VI, but this is only for a single number. I want to do the same thing with an array input of Live data, and an array output of peak values.
Thankyou in advance for any help.
Rhys
04-17-2013 05:29 AM
If I'm understanding this right, you want to compare individual elements of arrays and return the peak for each element?
eg. if your current peaks are [1,2,3,4,5] and your latest data array is [4,3,2,1,0], you'd want the result to be [4,3,3,4,5].
You also want to be able to reset this.
I would approach this using the attached vi, which you can use as an FGV.
The max & min function compares individual elements of array inputs.
In the reset case, you can put an array of zeros, or whatever you want the reset value.
To use it, call it as a subvi in your program, and wire in the selector for the action you want.
If you wanted just the peak of 1 array, theres a function for that (Array Max & Min)
04-17-2013 05:35 AM
This might help - it utilises an action engine that checks the new array of results against the previous values (stored in shift register) and then updates the shift register values and outputs the new list of peak values for each array element.
Can obviously be made a lot more complicated and I would advise putting some sort of error handling in there to check that the array sizes are the same etc.
Hope that helps.
04-17-2013 05:45 AM
Note - reset case should be the outer most case.
Ians way of use Max Min array (always forget about that one!) and a Enum rather than just a boolean enabling a get command to be available as well is definitely a better way to do things.
04-17-2013 06:21 AM
Thank you both for your speedy replies !!
Hopefully this afternoon i will get a chance to look over them and try them out.
Thanks again!
Rhys
04-17-2013 10:47 AM
Well Guys.........Success!!
They both work exactly as I wanted, brilliant!
Thankyou Very Much!