I have a signal that I sample at 500khz. I am trying to detect a rise, fall and the peak in the incoming data. The base of the peak could be  for 250 usec or 2.5msec, amplitude could be 6db or 15db above the noise floor. I don't have good snr unfortunately.  The dc level of the signal is not constant but move much more slower  than the ac component.  

At the decision point, I need to know the slope of the rise and fall. This is a hard realtime system and I really need to make a decision in the 100usec after the downward slope reach to dc level. 

I am looking for suggestions how can I efficiently implement an algorithm that is decent.  

Currently I do a running average (past 25 data points added together) and try to detect the trend. Once I detect the trend up I start seeking trend down and once I do that I collect perhaps another 50 samples and start calculating. 

Noise now easily screws this algorithm, hence the question. 


For the benefit of others, I have end up implementing a Moving Average followed by integrator. Moving average of past 64 data smoothed enough but lost rise to a degree, integrating last 8 values gained back the rise and I simply seek for rise and fall, later I did a linear regression for the slope. Works ok, not great but ok.

  • $\begingroup$ Can you post a plot of a data sequence that your current algorithm fails on? $\endgroup$
    – Jim Clay
    Jul 7 '12 at 17:30
  • $\begingroup$ Doing this sort of thing in spite of significant noise is quite difficult. Juancho's suggestion of a differentiator is probably a good one. $\endgroup$ Jul 7 '12 at 18:30

You should start with a bandlimited differentiator (equivalent to a differentiator followed by a low-pass filter). The differentiator will remove the low frequency trend and will respond sharply to your peaks and slopes. The low-pass component will remove noise beyond the cutoff frequency.

You should design your cutoff frequency so that you get clean pulses for your slopes.

Positive slopes will slow as positive pulses; negative slopes as negative pulses, and the peak will correspond to the zero-crossing between positive and negative.

This type of filter is normally implemented as a FIR filter. The number of samples for your filter will then depend on your real-time constraints, the sharpness at the cutoff frequency, and the cutoff frequency itself.

  • $\begingroup$ I am not very well versed with DSP. Can you point me to a possible implementation? Based on your answer and my limited knowledge, I think the link (holoborodko.com/pavel/numerical-methods/numerical-derivative/…) does exactly what you mention. If I were to use such an approach, I do not know 1) How to determine my frequencies? 2)How to select filter coefficients? $\endgroup$
    – Ktuncer
    Jul 8 '12 at 1:53
  • $\begingroup$ Also the following link solves a similar problem and contains good bunch of links. dsprelated.com/showmessage/123740/1.php $\endgroup$
    – Ktuncer
    Jul 8 '12 at 1:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.