# Compensating for measurement errors

I have a system where I sample some data periodically (every 10usec). The shape of the data is triangle, in other words it linearly increases and decreases in time. (Both theory and practice are in agreement, I plot the ADC output and I clearly see linear increase and decrease although there is some non-linearity but let's ignore that for the sake of discussion) However the frequency of the signal is not fixed. It may increase very fast or very slow. (narrow or wide triangle)

I am trying to locate the true peak point of the data with 500nsec accuracy, however my ADC samples every 10usec. One item on my favor is that the data values increase and decrease in sequence. I get worst case 50 samples, best case 1000 samples. (in worst case, I will have 25 samples in increasing order and 25 in decreasing order)

How can I approach this issue using DSP techniques? One idea I had was to calculate peak point from rise and fall angles. (I basically extend the left and right side of the triangle and look at where those lines cross each other). I cannot think of any other way. I welcome suggestions.

• Simply calculating the slopes and intersection is the first thing that comes to my mind. Do you need to have high accuracy, or high precision -- ie, do you want to measure peak-to-peak accurately or instead you need to correlate each peak with some other event? – Daniel R Hicks Feb 1 '12 at 13:22
• Do you have significant noise in your measurements? – Jason R Feb 1 '12 at 14:18
• Posting some images would be extremely helpful, too. – Phonon Feb 1 '12 at 14:37
• @DanielRHicks I need to calculate the time of peak accurately. The amplitude of the peak is not that big of a deal. – Frank Feb 2 '12 at 0:07
• @JasonR SNR is between 10 to 20 dB, so yes there is a lot of noise. – Frank Feb 2 '12 at 0:07

If you can reliably determine which samples are on a rising portion and which are on a falling portion, then perhaps you can do a linear regression on each (near)monotonic segment, and solve for the intersections of the computed regression lines.

If you know the non-linearity equation, then you can do a regression against that curve instead of using linear regression, and compute or numerically solve for the curve intersections, if needed.

This regression method might also help with error or robustness estimates, if needed.

• I got a question, how about I do a curve fitting for a high order (current is 8) and calculate the peak from the polynomial. I guess this is same as what you are explaining. – Frank Feb 6 '12 at 9:11
• @Frank : A regression-fitted high-order polynomial can produce wildly inaccurate estimates when extrapolating even a little bit past the endpoints, unless perhaps the underlying waveform is produced by a polynomial of that degree. – hotpaw2 Feb 6 '12 at 20:33

In a comparable situation where I need to determine the position of the peak with high accuracy I resample the signal at 2MHz (using a sync interpolation) and then search for the highest valued sample.

• What is the benefit of this approach? Isn't this same as slope interpolation? (As you resample, you probably use the slope to resample). I guess I don't know what sync interpolation means – Frank Feb 2 '12 at 0:08
• It is not the same as slope interpolation because it doesn't depend on the signal being triangular. It will also work with sines etc. – Han Feb 2 '12 at 8:34
• Sync interpolation is the technique were you replace every original sample by a sync function and calculate the interpolated samples by adding the sync function values at that sample position. (see: en.wikipedia.org/wiki/…) – Han Feb 2 '12 at 8:43