Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Find 1st/2nd/3rd... peak in FPGA in realtime

I have managed to write a realtime peak detector running at 200M, the idea is simple: Set 0 to i at the start of detect, if coming value is larger then i, set this value to i, if coming value is smaller than i, leave it alone. If reset is set, set i to 0 again. This works well, but now my job need me to find 2nd or even 3rd peak in the same context, i try to figure out how to deal with it, but till now it not clear to me, like the picture below: https://terpconnect.umd.edu/~toh/spectrum/peakfitVSfindpeaks.png Can anyone give me some idea? Thanks!
0 Kudos
Message 1 of 7
(2,885 Views)

Set a threshold (for example in your image you could set a threshold of like 1.2 and when you cross above the threshold, set i to the threshold. When you cross the threshold, send i to a "target to host" fifo.

0 Kudos
Message 2 of 7
(2,691 Views)

Thanks for your advice nanocyte.

 

But eveytime the peaks may comes with different values, so set fixed threshold doesn't seems like a good idea for my application.

 

0 Kudos
Message 3 of 7
(2,647 Views)

It's hard to make recomendations without more data sets. I really just have to guess. Could you do a dynamic threshold based on a local minimum (say the minimum of the last 256 samples) + a fixed offset? Or maybe look at NI's peak detector VI which uses second order regressions?

https://www.ni.com/en-us/support/documentation/supplemental/06/peak-detection-using-labview-and-meas...

0 Kudos
Message 4 of 7
(2,644 Views)

A simpler approach would be considering this as a runtime bubble sort of 3 elements.

 

Suggested pseudo code,

<Reset>

firstPeak = -inf

secondPeak =  -inf

thridPeak = -inf

 

<Inloop>

if (value >= firstPeak)

 firstPeak = value

elseif (value >= secondPeak)

 secondPeak = value

elseif (value >= thridPeak)

 thridPeak = value

 

This can also be considered as top N-sorted values.

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 5 of 7
(2,595 Views)

Wouldn't that just return the top 3 values all of which are in peak 4? I think OP wants the max of each peak.

0 Kudos
Message 6 of 7
(2,592 Views)

Actually I think you made a good point, if I can get peak in a window, I might be able to tell different peaks online.

 

Thanks, I will put that on test when I figured out how to code this down, a moving window is a good start:)

0 Kudos
Message 7 of 7
(2,583 Views)