07-26-2012 07:07 PM
hello, i have analog waveform which looks like an incremental step function... the step increments in fixed time duration of 'x' sec, and stays at a near constant value, but has some noise
(ex. attached image)
i would like to find out the average of values in each step...
can anyone please suggest any algorithm?
thanks,
07-27-2012 12:09 AM - edited 07-27-2012 12:12 AM
You should be able to use the "Basic Averaged DC-RMS.vi" to get the DC value. You might also be able to use "Amplitude and Levels Express VI" depending on your application.
07-27-2012 07:42 AM - edited 07-27-2012 07:44 AM
I did something like this in my Matlab days. I can give you a general idea on how I accomplished it.
1) Take the derivative (or point by point subtraction) and scan that derivative for a positive threshold. This will be the first jump in voltage, or hopefully the start of the first step.
2) Now, if you know the exact size of each step, you know the start/stop of each step. However, you likely want to only grab the center. If you get too close to the transition points, you scew your results. These centers can be calculated as Center Time = Start Time + Step Length* (N+1/ 2).
3) Now that you have the center of your step. You want a percentage of the total step (again, don't want transitions). You can get the start and stop of an individual step. Start and stop times = Center Time +/- Percentage/2 * Step Time.
4) Average the points between the times.
07-27-2012 08:09 AM
The big problem with step 1 on JW-L3CE's suggestion is that the noise may trigger false step discovery. I would probably use a threshold based on the average of the previous step plus 5*standard deviation. If the minimum height of the steps is known, use half of that plus the average.
Depending on the slope of the steps and how many data samples you might get during the step, you may find it advantageous to exclude a small number of data points before and after each step to assure that you do not include part of the step in your average.
Lynn
07-27-2012 08:15 AM - edited 07-27-2012 08:16 AM
Ahh, my bad, I didn't mean positive threshold as in "anything positive". I meant set a treshold that is positive. Half the first step height would work.
This was awhile ago, but I think mine searched for a maximum and found the treshold based on the number of steps. Assuming each step is uniform, each step would be Max/N.
07-27-2012 10:56 AM
You might want to preprocess with a fairly large-width median filter to help identify transition points. One nice thing about a median filter is that it doesn't add any phase delay to sharp transitions. Note: only use the median-filtered data to help identify true step transitions. Once you find the indices for the transitions, revert to your original data to extract out the near-DC parts for your real averaging.
-Kevin P