Peak Detector Circuit - Page 1
Forum section: electronics / general

author: mauijan
author_rank: Newbie
timestamp: October 26, 2022, 12:49:43 pm
content: I am trying to design a peak detector circuit. But it needs to be a special kind of peak detector.If a more positive peak arrives, of course the circuit needs to detect and hold it. But if a smaller, also positive peak comes, it needs to forget the last one and store this new, smaller peak. It basically needs to store every new max value. The signal is always positive.The signal is a sinusoidal waveform with frequency of about 33 Hz. The frequency can also be lower but not higher. For every cycle the highest peak needs to be detected, even when the peaks are getting smaller in magnitude. I have attached an image that explains this behaviour...Can anyone help?

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 26, 2022, 12:59:43 pm
content: Hi mauijan, welcome to the forum.For such a low frequency, I would use a microcontroller. You will have to bring the signal voltage in range of the ADC and write a bit of software.On digital values it is easy to do this. Track the maximum, and hold it when the value drops below. Then track the minimum and when this is found start tracking a new maximum, and so on.Doing it with electronics will require a fair bit of components I think. (Not really my field of expertise)

author: David Hess
author_rank: Super Contributor
timestamp: October 26, 2022, 03:42:35 pm
content: For a hardware only implementation, I would use two peak detectors and a differentiator. The differentiator sets or resets a flip-flop to select which peak detector is providing the output, and which peak detector is monitoring the input and needs to be reset.The differentiator output goes high or low depending on the slope of the input signal, which drives edge sensitive logic to control the flip-flop. This is a noisy operation so careful filtering will be required.

author: MasterT
author_rank: Frequent Contributor
timestamp: October 26, 2022, 06:33:05 pm
content: For maximum value in each period combine peak detector with zero-cross reset circuits

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 26, 2022, 06:41:05 pm
content: Quote from: MasterT on October 26, 2022, 06:33:05 pmFor this to work the signal should cross zero where as the original post states:Quote from: mauijan on October 26, 2022, 12:49:43 pmThe idea of David is interesting, but as I expected quite a bit of components to make it work.Edit: For the software solution it is also needed to apply some filtering in the code, but that is not to difficult either.

author: MasterT
author_rank: Frequent Contributor
timestamp: October 26, 2022, 06:49:36 pm
content: Quote from: pcprogrammer on October 26, 2022, 06:41:05 pmHigh Pass Filtering would make signal bipolar. Interesting, that HPF is a differentiator...

author: Infraviolet
author_rank: Super Contributor
timestamp: October 26, 2022, 07:07:15 pm
content: Just because the signal is always positive doesn't mean you can't produce a virtual ground rail against which to do the crossing detection.

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 26, 2022, 07:11:32 pm
content: Quote from: MasterT on October 26, 2022, 06:49:36 pmTrue, but you loose the level then of what it originally was.Forgot to mention that with the microcontroller solution it would need an analog output to return the detected maximums. Can be done with PWM though.Looking at the signal drawing it looks a bit like what a random voltage generator in a synthesizer would output. But I think these work with a clock, noise generator and a sample and hold circuit. Maybe it is possible to steal some bits of this idea?

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 26, 2022, 07:15:14 pm
content: Quote from: Infraviolet on October 26, 2022, 07:07:15 pmDepends on where the min and max levels will be in the signal. If a couple of maximums are below the virtual ground these might be missed.

author: MasterT
author_rank: Frequent Contributor
timestamp: October 26, 2022, 07:22:31 pm
content: Quote from: pcprogrammer on October 26, 2022, 07:11:32 pmNo, HPF is connected to zero-cross detector. Peak detector is running by input, no HPF on the line.

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 26, 2022, 09:36:43 pm
content: Not what I'd call simple using discrete parts.If the wave is just 30Hz or so, use an ADC, 1KHz sample rate will be far enough and the software is nothing fancy.But could be achieved using few inexpensive parts: 1x Quad Op-amp, 1x 74HC14, 1x 4016 cmos switch and some passives.The clocks can be used to tell the MCU when start a conversion.

author: MathWizard
author_rank: Super Contributor
timestamp: October 28, 2022, 12:00:50 am
content: Yeah you need something to reset your peak when the slope of the voltage changes negative again, then goes positive again.That's probably pretty tricky, or the signal needs to be altered 1at to make it work better for the analog circuits. I've made basic op-amp integrator's/differentiator's, but I need to learn more on all that.I bet with a microcontroller, and digital circuits, it's easy if you know programming.