How to detect the peak of a sinusoidal waveform of varying amplitude? - Page 1
Forum section: electronics / beginners

author: smoothVTer
author_rank: Regular Contributor
timestamp: March 14, 2017, 08:15:12 pm
content: I want to detect the peak of an arbitrary amplitude sine wave. If the amplitude were fixed, I could easily construct a comparator circuit to give me a pulse output when some target voltage is reached on the sinusoid's cycle.In my application however, the signal can vary in amplitude from a minimum of 100mV to a maximum of 3V.How would one construct a signal conditioning circuit so that I can always have a predictable peak amplitude output for feeding into a comparator? AGC? VGA? I'm not well versed in this type of circuitry so any insight is appreciated.

author: Supercharged
author_rank: Regular Contributor
timestamp: March 14, 2017, 08:27:02 pm
content: I think a differentiator circuit could do the trick for you. If the output of the differentiator is exactly zero and the input signal is bigger than zero. NOTE: This is assuming a "normal" sine wave.

author: Kleinstein
author_rank: Super Contributor
timestamp: March 14, 2017, 08:31:38 pm
content: Bringing the amplitude to a reasonable range is different from detecting the amplitude.A suitable circuit would be a kind of AGC - so automatic adjustment of gain.There are different methods to do this - depending on the frequency and amplitude range.Just for feeding the signal to an comparator (e.g. for something like a frequency counter ?) it would be enough to do rather coarse gain steps, possibly a little like an auto-ranging AC voltmeter.

author: smoothVTer
author_rank: Regular Contributor
timestamp: March 14, 2017, 08:39:37 pm
content: Exactly ... the end application is indeed a frequency counter. Fairly low frequency too: I'm looking at a max sine frequency of 2kHz

author: w2aew
author_rank: Super Contributor
timestamp: March 14, 2017, 08:41:54 pm
content: Quote from: smoothVTer on March 14, 2017, 08:39:37 pmThen you don't really need to detect the peaks - you can detect the zero-crossings. You can amplify the signal to the point of limiting, or use a comparator to turn it into a square wave, then detect frequency of that.

author: Benta
author_rank: Super Contributor
timestamp: March 14, 2017, 08:43:13 pm
content: I'm not certain I understand the question.Do you want to detect the peak amplitude (level)?Or do you want to detectwhenthe sine peaks?

author: smoothVTer
author_rank: Regular Contributor
timestamp: March 14, 2017, 09:10:01 pm
content: I need to know when the sine wave peaks, regardless of its amplitude.I do not need to know about the absolute voltage level this peak occurs.The note above about a zero-crossing detector: This could work just fine, but I'd have to remove the DC offset first. I'll give it a whirl!

author: Benta
author_rank: Super Contributor
timestamp: March 14, 2017, 09:27:15 pm
content: QuoteForget that, think about how smooth the top of a sinewave is, no way to detect the top accurately.Zero-crossing is the way to go, and is how all commercial frequency counters work.

author: David Hess
author_rank: Super Contributor
timestamp: March 15, 2017, 12:51:35 am
content: Quote from: Supercharged on March 14, 2017, 08:27:02 pmI have done it this way but differentiators are noisy. There is an alternative design which uses a pair of integrators to produce the same result. I do not think this is what the original poster wants though.Quote from: smoothVTer on March 14, 2017, 09:10:01 pmThis is what an AC coupling capacitor is for.If there is an issue with duty cycle causing baseline wander which will not happen with any reasonable sine wave, then there is an alternative using two peak detectors which produces the same results as AC coupling but without this problem but I doubt you need it. It is used where the waveform could be anything.

author: smoothVTer
author_rank: Regular Contributor
timestamp: March 15, 2017, 01:32:39 pm
content: I've simulated a possible circuit implementation of the zero-crossing detector using LTSpice. I used an LT1006 because of prior experience, however, perhaps a different op amp would be a better choice. Results indicate successful zero crossing detection with amplitudes as small as 100mV:

author: Cerebus
author_rank: Super Contributor
timestamp: March 15, 2017, 03:14:17 pm
content: Quote from: Benta on March 14, 2017, 09:27:15 pmNo argument with zero crossing, definitely the way to go, but I have to point out that the "precision peak detector" is a very well known circuit and it's quite possible to accurately detect the top of a sinewave to arbitrary accuracy, limited only by the usual disappointing characteristics of real world (as opposed to ideal) components.

author: Benta
author_rank: Super Contributor
timestamp: March 15, 2017, 03:15:22 pm
content: If it's for a frequency counter, there's no need for all the fancy stuff. Just amplify and clip, you'll get a nice square output with at least one of the edges useful for reference timing.

author: Cerebus
author_rank: Super Contributor
timestamp: March 15, 2017, 03:38:02 pm
content: Quote from: Benta on March 15, 2017, 03:15:22 pmI wasn't suggesting making it any more complicated. As I said, zero crossing is the way to go. I was merely correcting your:Quote from: Benta on March 14, 2017, 09:27:15 pmbecause thisisthe beginner's topic and we don't want a beginner wandering off with the impression that something that's been solved so often that there are standard textbook circuits to do it is somehow impossible.

author: Cerebus
author_rank: Super Contributor
timestamp: March 15, 2017, 03:41:58 pm
content: Quote from: smoothVTer on March 15, 2017, 01:32:39 pmYou might want to have a think about the common mode input limits of the op amp, the output limits of the op amp and the way those are going to interact with that diode you've strapped between ground and the non-inverting input of the amp. Hint: very few op amp inputs or outputs are happy working within 0.3V of any rail.

author: Benta
author_rank: Super Contributor
timestamp: March 15, 2017, 03:52:05 pm
content: QuoteIn theory you're right, but the effort would in no way justify the result. If I wanted to find the top, I'd cosine the signal and zero-cross detect the cosine. And then we're back to square one...

author: Cerebus
author_rank: Super Contributor
timestamp: March 15, 2017, 04:15:54 pm
content: Quote from: Benta on March 15, 2017, 03:52:05 pmYou're going round in circles just to avoid saying "Whoops, careless thing I said there." We all casually say things that are wrong, or less precise than we ought to. When we do and someone points it out the best thing to do is either graciously or quietly just accept it. My advice, stop digging.Now, can we please stop this before we wonder way off topic into engineer/pig mud wrestling.

author: tecman
author_rank: Frequent Contributor
timestamp: March 15, 2017, 04:21:29 pm
content: Use a simple peak detectorPaul