07-17-2013 08:34 AM
Hi. I want to realize a program where I want to generate a sine and take only the positive monotonic part.
So i tought to find the min and max index of the function and realize a program like the one attached.
As you can see if you set the frequency at 10Hz it works fine... the problem is when you change the frequency for example at 20 or 50H...it seems that it doesn't find the min and max properly.
Can you suggest me some tips?
Thank you
Solved! Go to Solution.
07-17-2013 08:46 AM
The problem is with your Express vi set up. Select "Automatic" for number of samples and Check "Integer number of cycles".
07-17-2013 08:51 AM
mmm no it doesn't work 😞
07-17-2013 10:04 AM
At higher frequencies, you have multiple peaks and valleys. Which one is chosen for getting the max index and which one for the min index? It looks like you are looking for the index values that are greater than the max index AND less than the min index to zero out. But suppose the Min index winds up coming before the Max index? That boolean condition will never be true.
And do you want to zero out all the decreasing parts of the slopes? Even if you did not have an index detection problem, it is still only geared towards the first peak/valley combo and is not geared towards to dealing with multiple peaks and valleys.
07-17-2013 10:23 AM - edited 07-17-2013 10:24 AM
@s.turino84 wrote:
and take only the positive monotonic part.
This means the derivative is positive. So do a derivative. If the derivative is greater than 0 keep the current value, otherwise set to 0.
07-18-2013 01:39 AM
Hi cross instead yesterday i thought it in the way you will find in the VI attached. I used the shift register to compare the i-value with the i-1-value. If the i-value is > than the i-1 value I set it as output otherwise in the other cases I set it as 0 except when the i-value = max/min value) ....
but to be honest I prefer your solution that is more clear 🙂 so thank you