Xplosiv166 wrote:
> Hi,
>
> I need to implement a software peak detector in either C, C++, C#.Net,
> Visual Basic.Net (as these are the languages i know).
>
> It is not just a simple sine/cosine input signal but more of a series of
> impulses, please see picture: -
>
> http://www.andy166.pwp.blueyonder.co.uk/Peaks.jpg
>
> The arrow indicates the peak i need to measure and the mess as the bottom
> is meant to be some smaller peaks with different frequencies.
>
> What is the best way to do this? other than an FFT if there is a better
> way can anybody point me in the direction of some examples/tutorials?
I probably don't understand what you want. It would seem that your
question is about the time signal, but an FFT is for frequency analysis.
Assuming that the reference to FFT is a red herring, the sample rate
would need to be known. Sharp peaks indicate high frequencies. To derive
the peak from a sample set, there needs to be a sample near the peak.
This isn't hopeless, but it's not simple.
Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Xplosiv166 wrote:
> Hi,
>
> I need to implement a software peak detector in either C, C++, C#.Net,
> Visual Basic.Net (as these are the languages i know).
>
> It is not just a simple sine/cosine input signal but more of a series of
> impulses, please see picture: -
>
> http://www.andy166.pwp.blueyonder.co.uk/Peaks.jpg
>
> The arrow indicates the peak i need to measure and the mess as the bottom
> is meant to be some smaller peaks with different frequencies.
Define "measure". {That's much more thought provoking than it
appears ;}
Suggestion: Sketch the problem on grid paper. If you define
"measure" in any of five ways that crossed my mind the answer to
your question will be sitting there.
That you mention using an fft suggests either:
your sketch doesn't adequately portray the problem
you are trying an excessively complicated approach
>
> What is the best way to do this? other than an FFT if there is a better
> way can anybody point me in the direction of some examples/tutorials?
>
> Thanks,
>
> Xposiv166
On Nov 10, 12:58*pm, "Xplosiv166" <andrew_...@blueyonder.co.uk> wrote:
> Hi,
>
> I need to implement a software peak detector in either C, C++, C#.Net,
> Visual Basic.Net (as these are the languages i know).
>
> It is not just a simple sine/cosine input signal but more of a series of
> impulses, please see picture: -
>
> http://www.andy166.pwp.blueyonder.co.uk/Peaks.jpg
>
> The arrow indicates the peak i need to measure and the mess as the bottom
> is meant to be some smaller peaks with different frequencies.
>
> What is the best way to do this? other than an FFT if there is a better
> way can anybody point me in the direction of some examples/tutorials?
>
> Thanks,
>
> Xposiv166
Well, if you can't figure out that then there's something wrong with
your knob.
On Mon, 09 Nov 2009 17:58:58 -0600, Xplosiv166 wrote:
> Hi,
>
> I need to implement a software peak detector in either C, C++, C#.Net,
> Visual Basic.Net (as these are the languages i know).
>
> It is not just a simple sine/cosine input signal but more of a series of
> impulses, please see picture: -
>
> http://www.andy166.pwp.blueyonder.co.uk/Peaks.jpg
>
> The arrow indicates the peak i need to measure and the mess as the
> bottom is meant to be some smaller peaks with different frequencies.
>
> What is the best way to do this? other than an FFT if there is a better
> way can anybody point me in the direction of some examples/tutorials?
For the life of me I can't see how an FFT is going to measure a peak for
you. If you need to filter _then_ measure, an FFT may help you with the
filtering, but that's about it.
Your question is vague. Good mathematical definitions of the peak that
you want to automatically measure can be astonishingly hard to write in
such a way that you don't end up automatically measuring noise -- expect
to spend weeks with well-detected false peaks and missed real peaks,
possibly both in the same data set.
Tell us what you _really_ want, and perhaps someone can help. If you're
really truly looking at a data set that looks like your sketch, then just
take the maximum.
On Nov 9, 6:58*pm, "Xplosiv166" <andrew_...@blueyonder.co.uk> wrote:
> Hi,
>
> I need to implement a software peak detector in either C, C++, C#.Net,
> Visual Basic.Net (as these are the languages i know).
>
> It is not just a simple sine/cosine input signal but more of a series of
> impulses, please see picture: -
>
> http://www.andy166.pwp.blueyonder.co.uk/Peaks.jpg
>
> The arrow indicates the peak i need to measure and the mess as the bottom
> is meant to be some smaller peaks with different frequencies.
>
> What is the best way to do this? other than an FFT if there is a better
> way can anybody point me in the direction of some examples/tutorials?
>
> Thanks,
>
> Xposiv166
Peak detector?
Method 1:
You sift through the samples and pick the highest value
Method 2:
You start the first sample, and compare to next sample. If next
sample is hgher then you compare to that sample. Keep making
comparisons until you have run through your time interval of interest.
Tim Wescott wrote:
> On Mon, 09 Nov 2009 17:58:58 -0600, Xplosiv166 wrote:
>
>> Hi,
>>
>> I need to implement a software peak detector in either C, C++, C#.Net,
>> Visual Basic.Net (as these are the languages i know).
>>
>> It is not just a simple sine/cosine input signal but more of a series of
>> impulses, please see picture: -
>>
>> http://www.andy166.pwp.blueyonder.co.uk/Peaks.jpg
>>
>> The arrow indicates the peak i need to measure and the mess as the
>> bottom is meant to be some smaller peaks with different frequencies.
>>
>> What is the best way to do this? other than an FFT if there is a better
>> way can anybody point me in the direction of some examples/tutorials?
>
> For the life of me I can't see how an FFT is going to measure a peak for
> you. If you need to filter _then_ measure, an FFT may help you with the
> filtering, but that's about it.
>
> Your question is vague. Good mathematical definitions of the peak that
> you want to automatically measure can be astonishingly hard to write in
> such a way that you don't end up automatically measuring noise -- expect
> to spend weeks with well-detected false peaks and missed real peaks,
> possibly both in the same data set.
>
> Tell us what you _really_ want, and perhaps someone can help. If you're
> really truly looking at a data set that looks like your sketch, then just
> take the maximum.
Tim, do you have any reason to believe that there will be a sample near
the peak? Do you suspect that the waveform might be repetitive?
Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
On Nov 9, 6:58*pm, "Xplosiv166" <andrew_...@blueyonder.co.uk> wrote:
> Hi,
>
> I need to implement a software peak detector in either C, C++, C#.Net,
> Visual Basic.Net (as these are the languages i know).
>
> It is not just a simple sine/cosine input signal but more of a series of
> impulses, please see picture: -
>
> http://www.andy166.pwp.blueyonder.co.uk/Peaks.jpg
>
> The arrow indicates the peak i need to measure and the mess as the bottom
> is meant to be some smaller peaks with different frequencies.
>
> What is the best way to do this? other than an FFT if there is a better
> way can anybody point me in the direction of some examples/tutorials?
>
> Thanks,
>
> Xposiv166
There is no general-purpose solution to your problem. Just come up
with something on your own.
> On Nov 9, 6:58 pm, "Xplosiv166" <andrew_...@blueyonder.co.uk> wrote:
>
>>I need to implement a software peak detector in either C, C++, C#.Net,
>>Visual Basic.Net (as these are the languages i know).
>>What is the best way to do this?
> There is no general-purpose solution to your problem. Just come up
> with something on your own.
There are two general purpose solutions: do it yourself or hire someone
who knows.
On Mon, 09 Nov 2009 20:37:39 -0500, Jerry Avins wrote:
> Tim Wescott wrote:
>> On Mon, 09 Nov 2009 17:58:58 -0600, Xplosiv166 wrote:
>>
>>> Hi,
>>>
>>> I need to implement a software peak detector in either C, C++, C#.Net,
>>> Visual Basic.Net (as these are the languages i know).
>>>
>>> It is not just a simple sine/cosine input signal but more of a series
>>> of impulses, please see picture: -
>>>
>>> http://www.andy166.pwp.blueyonder.co.uk/Peaks.jpg
>>>
>>> The arrow indicates the peak i need to measure and the mess as the
>>> bottom is meant to be some smaller peaks with different frequencies.
>>>
>>> What is the best way to do this? other than an FFT if there is a
>>> better way can anybody point me in the direction of some
>>> examples/tutorials?
>>
>> For the life of me I can't see how an FFT is going to measure a peak
>> for you. If you need to filter _then_ measure, an FFT may help you
>> with the filtering, but that's about it.
>>
>> Your question is vague. Good mathematical definitions of the peak that
>> you want to automatically measure can be astonishingly hard to write in
>> such a way that you don't end up automatically measuring noise --
>> expect to spend weeks with well-detected false peaks and missed real
>> peaks, possibly both in the same data set.
>>
>> Tell us what you _really_ want, and perhaps someone can help. If
>> you're really truly looking at a data set that looks like your sketch,
>> then just take the maximum.
>
> Tim, do you have any reason to believe that there will be a sample near
> the peak? Do you suspect that the waveform might be repetitive?
>
> Jerry
I was taking the question at face value and assuming sufficient sampling
to catch a peak -- but making sure you're sampling fast enough is
certainly one thing you'd need to do to catch a peak.
_Assuming_ a rounded enough peak you could interpolate the 'actual' peak
time from three or more samples of the peak waveform using a quadratic
curve fit. I've done this when the situation warrants it -- but you have
to do the engineering up front to make sure that it's a viable option and
not just fantasy.
Xplosiv166 wrote:
> Hi,
>
> I need to implement a software peak detector in either C, C++, C#.Net,
> Visual Basic.Net (as these are the languages i know).
>
> It is not just a simple sine/cosine input signal but more of a series of
> impulses, please see picture: -
>
> http://www.andy166.pwp.blueyonder.co.uk/Peaks.jpg
>
I am getting a 404 error from that URL, which makes it kind of difficult
to make any comment at all.
Shape detection? transient detection? envelope detection as used in a
dynamics compressor?
Tim Wescott wrote:
> On Mon, 09 Nov 2009 20:37:39 -0500, Jerry Avins wrote:
>
>> Tim Wescott wrote:
>>> On Mon, 09 Nov 2009 17:58:58 -0600, Xplosiv166 wrote:
>>>
>>>> Hi,
>>>>
>>>> I need to implement a software peak detector in either C, C++, C#.Net,
>>>> Visual Basic.Net (as these are the languages i know).
>>>>
>>>> It is not just a simple sine/cosine input signal but more of a series
>>>> of impulses, please see picture: -
>>>>
>>>> http://www.andy166.pwp.blueyonder.co.uk/Peaks.jpg
>>>>
>>>> The arrow indicates the peak i need to measure and the mess as the
>>>> bottom is meant to be some smaller peaks with different frequencies.
>>>>
>>>> What is the best way to do this? other than an FFT if there is a
>>>> better way can anybody point me in the direction of some
>>>> examples/tutorials?
>>> For the life of me I can't see how an FFT is going to measure a peak
>>> for you. If you need to filter _then_ measure, an FFT may help you
>>> with the filtering, but that's about it.
>>>
>>> Your question is vague. Good mathematical definitions of the peak that
>>> you want to automatically measure can be astonishingly hard to write in
>>> such a way that you don't end up automatically measuring noise --
>>> expect to spend weeks with well-detected false peaks and missed real
>>> peaks, possibly both in the same data set.
>>>
>>> Tell us what you _really_ want, and perhaps someone can help. If
>>> you're really truly looking at a data set that looks like your sketch,
>>> then just take the maximum.
>> Tim, do you have any reason to believe that there will be a sample near
>> the peak? Do you suspect that the waveform might be repetitive?
>>
>> Jerry
>
> I was taking the question at face value and assuming sufficient sampling
> to catch a peak -- but making sure you're sampling fast enough is
> certainly one thing you'd need to do to catch a peak.
>
> _Assuming_ a rounded enough peak you could interpolate the 'actual' peak
> time from three or more samples of the peak waveform using a quadratic
> curve fit. I've done this when the situation warrants it -- but you have
> to do the engineering up front to make sure that it's a viable option and
> not just fantasy.
If you know at the outset that peak measurements will be important, then
a very fast sample rate is called for. (The anti-alias filter shouldn't
be relaxed.) Alternatively, upsampling can be used as a method of
interpolation. None of which defines what a peak actually is.
Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
On Tue, 10 Nov 2009 14:11:20 -0500, Jerry Avins wrote:
> Tim Wescott wrote:
>> On Mon, 09 Nov 2009 20:37:39 -0500, Jerry Avins wrote:
>>
>>> Tim Wescott wrote:
>>>> On Mon, 09 Nov 2009 17:58:58 -0600, Xplosiv166 wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I need to implement a software peak detector in either C, C++,
>>>>> C#.Net, Visual Basic.Net (as these are the languages i know).
>>>>>
>>>>> It is not just a simple sine/cosine input signal but more of a
>>>>> series of impulses, please see picture: -
>>>>>
>>>>> http://www.andy166.pwp.blueyonder.co.uk/Peaks.jpg
>>>>>
>>>>> The arrow indicates the peak i need to measure and the mess as the
>>>>> bottom is meant to be some smaller peaks with different frequencies.
>>>>>
>>>>> What is the best way to do this? other than an FFT if there is a
>>>>> better way can anybody point me in the direction of some
>>>>> examples/tutorials?
>>>> For the life of me I can't see how an FFT is going to measure a peak
>>>> for you. If you need to filter _then_ measure, an FFT may help you
>>>> with the filtering, but that's about it.
>>>>
>>>> Your question is vague. Good mathematical definitions of the peak
>>>> that you want to automatically measure can be astonishingly hard to
>>>> write in such a way that you don't end up automatically measuring
>>>> noise -- expect to spend weeks with well-detected false peaks and
>>>> missed real peaks, possibly both in the same data set.
>>>>
>>>> Tell us what you _really_ want, and perhaps someone can help. If
>>>> you're really truly looking at a data set that looks like your
>>>> sketch, then just take the maximum.
>>> Tim, do you have any reason to believe that there will be a sample
>>> near the peak? Do you suspect that the waveform might be repetitive?
>>>
>>> Jerry
>>
>> I was taking the question at face value and assuming sufficient
>> sampling to catch a peak -- but making sure you're sampling fast enough
>> is certainly one thing you'd need to do to catch a peak.
>>
>> _Assuming_ a rounded enough peak you could interpolate the 'actual'
>> peak time from three or more samples of the peak waveform using a
>> quadratic curve fit. I've done this when the situation warrants it --
>> but you have to do the engineering up front to make sure that it's a
>> viable option and not just fantasy.
>
> If you know at the outset that peak measurements will be important, then
> a very fast sample rate is called for. (The anti-alias filter shouldn't
> be relaxed.) Alternatively, upsampling can be used as a method of
> interpolation. None of which defines what a peak actually is.
>
> Jerry
Or, depending on the characteristics of the peak and what you really need
to know, you build a peak detector into hardware from which you extract
all pertinent statistics from at sampling time.