LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to calculate average of step-shaped waveform?

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,

 

Now on LabVIEW 10.0 on Win7
0 Kudos
Message 1 of 6
(3,364 Views)

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. 

Screen Shot 2012-07-27 at 12.11.12 AM.png

0 Kudos
Message 2 of 6
(3,352 Views)

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.

Josh
Software is never really finished, it's just an acceptable level of broken
0 Kudos
Message 3 of 6
(3,341 Views)

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

0 Kudos
Message 4 of 6
(3,334 Views)

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.

Josh
Software is never really finished, it's just an acceptable level of broken
0 Kudos
Message 5 of 6
(3,331 Views)

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

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 6 of 6
(3,319 Views)