Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help me detect peaks and locations of them

Status
Not open for further replies.

Supaswing

Junior Member level 3
Joined
Jul 14, 2005
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,601
Imagine you have a signal like in the attachement (sorry, made with paint), noisy with not regular peaks and peak height at different levels. What you need is counting the peaks without missing them.
I most simple I thought was a low pass (smoothing) + discrimation (difference) + threshold + minima, but I am not satisfied with this.
What would do in that case?

Thank you
 

verilog_coder

Member level 3
Joined
Jan 4, 2006
Messages
55
Helped
4
Reputation
8
Reaction score
2
Trophy points
1,288
Location
Pakistan
Activity points
1,725
peaks detection

you need to do smothing .
then you need to take the difference of signal from its previous value after certain times.
When the difference goes from positive to negative you have found a peak.
 

IanP

Advanced Member level 5
Joined
Oct 5, 2004
Messages
7,942
Helped
2,309
Reputation
4,620
Reaction score
531
Trophy points
1,393
Location
West Coast
Activity points
66,435
Re: peaks detection

What if you pass this signal through a capacitor to remove dc and just count zero-crossings?

Regards,
IanP
 

_

Junior Member level 1
Joined
Jan 18, 2006
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,449
Re: peaks detection

Like IanP suggested, you can couple with a cap and connect to a hi speed comparator with hysteresis then to a counter to count the peaks.
 

artem

Advanced Member level 4
Joined
May 22, 2003
Messages
1,350
Helped
126
Reputation
252
Reaction score
32
Trophy points
1,328
Location
Turkey
Activity points
13,450
peaks detection

I suppose that some heurisitcs do apply for the case.

You can use floating threshold for matching as :
- smooth data with LPF (if digitally - choose some window to multiply)
- implement low and high peak detection by continuosly calculating derivative of smoothed data (positive to negative - high peak,
negative to positive - low peak). Update lowest peak for every case when it is observed.
- When high peak is detected compare it to the latest low peak observed plus constant threshold value .

Low pass filter frequency is dependent on shortest possible peak width or duration

Eliminating of DC part could lead to case some peaks will not pass zero and will be missed from recording .
 

Supaswing

Junior Member level 3
Joined
Jul 14, 2005
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,601
Re: peaks detection

Thank you for your advices, the becuase trouble comes from the threshold or the hystersis setting, which I want to be autoadjusted, and actually there is a lot of divergence from sample to sample and some min are higher than other max even after high passing.
And furthermore I would like to determine the location of the peaks.
Any idea?
Thank you very much
 

artem

Advanced Member level 4
Joined
May 22, 2003
Messages
1,350
Helped
126
Reputation
252
Reaction score
32
Trophy points
1,328
Location
Turkey
Activity points
13,450
peaks detection

I already suggested floating threshold . Look to pseudocode for explanation
Code:
input signal f(t)
smoothed signal lp(t) (filtered windowed)
get_sample() - returns lp(t)
report_peak() - it is called upon peak detection

sign = 0;			// sign of derivation lp(t) - lp(t-1)
prev = 0;			// lp(t-1)
current = 0;			// lp(t)
CONST;				// constant value to be added to floating threshold base
bottom;				// floating threshold base


prev = get_sample();
current = get_sample();
sign = current >= prev? 1: -1;

if(sign == 1)
	bottom = prev;

for(;;)
{
	prev = current;
	current = get_sample();
	if(sign == -1)
	{
		if(current >= prev)
		{
			sign = 1;
			bottom = prev;
		}
	}
	else
	{
		if(current < prev)
		{
			sign = -1;
			if((bottom + CONST) < prev)
				report_peak();
		}
	}
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top