10-12-2016 09:10 PM
Let me start be aplogizing by the crudeness of my drawing. It is the best I have here at home. I am trying to wrap my brain around how to effectivily process the attached signal.
Attached I have the profile of a signal I am trying to make some specific measurements from. I am trying to measure the height of the flat area between the two red ticks and then compare it to the flat area between the two green ticks. In the end I will be subtracting the amplitude of the green from the red. I expect the real world signal to be pretty consistant and periodic. Ideally the method would allow for the subtraction regardless of frequency or the overall amplitude. I just need the difference between the two. Does this make sense?
So my overall methodology RIGHT now is something like this.
Find the max of the waveform. Use some percent of this as a trigger level. Calculate the "start of the flat" using a rising edge and the finish using a falling edge. Measure the values in between. Average them. This is value 1.
Using frequency repeat the above process 1 period away. This is value 2.
Subtract them and I get the difference. Continue the whole thing with a For loop for the entire waveform. Does this sound right to anyone?
Right now I can get the frequency easily, but I am having a little trouble getting the start and stop of my flat parts. I think I can do it using basic trigger but I am wondering if there are some easier functions I am unaware of. Any help suggestion tips would be grealty appreciated. I am more than happy to elaborate further if I have been unclear. I can try and post some code tomorrow but right now I am looking at the basic methodology.
Thanks so much.
TK
10-13-2016 01:09 AM
Well, you don't say much about the nature of your data -- is it really as "clean" as shown in your figure? Is the "Max" value consistent for Red and Green segments?
If it is fairly clean, you should be able to get a good estimate of Max (and you might not really want "Max" as much as you want "Flat Peak"). One way to determine the extent of Flat Peak (you'll need to experiment with your "real signals" which have "real noise") is as follows:
Another way of looking at this problem is to look at the derivatives of your signal. The "flat" parts are where the derivative is 0, being positive on the left edge and negative on the right. However, sometimes dealing with the signal itself is easier (and more immune to "injected noise" (taking derivatives emphasizes the high frequency components present in your signal, including random noise).
Bob Schor
10-13-2016 03:47 PM
I think I found something I can work with. Check out Waveform Scalar Limit Comparison and its example. Looks like I can pretty easily end up with an array of numbers representing the flat tops and NaN inbetween each group. Should make it easy to sort the groups from there.
Check out the function. Hopefully there are not any obvious flaws in that logic.