Author Topic: EEVblog #490 - Peak Detector Circuit  (Read 24681 times)

0 Members and 1 Guest are viewing this topic.

Offline EEVblog

  • Administrator
  • *****
  • Posts: 26994
  • Country: au
    • EEVblog
EEVblog #490 - Peak Detector Circuit
« on: June 29, 2013, 09:49:53 pm »
Fundamentals Friday.
Designing and measuring basic and precision peak detector circuits.

 

Offline lewis

  • Frequent Contributor
  • **
  • Posts: 697
  • Country: gb
  • Nullius in verba
Re: EEVblog #490 - Peak Detector Circuit
« Reply #1 on: June 29, 2013, 10:23:20 pm »
That loss of feedback when the op-amp saturates negative makes it almost impossible to measure high frequency signals. It's possible to give the op-amp some feedback on the negative half-cycle by putting another diode around the feedback loop; this helps to stabilise the op-amp, stops it oscillating, and makes the precision peak detector even more precise. See attached image (taken from page 12 here: http://www.site.uottawa.ca/~rhabash/ELG4135L8.pdf). It's a very small re-arrangement of Dave's bottom circuit.

I will not be pushed, filed, stamped, indexed, briefed, debriefed or numbered.
 

Offline sergey

  • Regular Contributor
  • *
  • Posts: 66
  • Country: ru
Re: EEVblog #490 - Peak Detector Circuit
« Reply #2 on: June 29, 2013, 10:57:24 pm »
Nice video. But one thing is not so 100% clear, unfortunately.

When Dave was probing "precision diode" (voltage follower modification where op-amp compensates voltage drop) it doesn't seem to be perfectly clipped. Is it just because op-amp isn't fast enough and that "undershoot" will become smaller with lower frequency input / faster op-amp?
 

Offline EEVblog

  • Administrator
  • *****
  • Posts: 26994
  • Country: au
    • EEVblog
Re: EEVblog #490 - Peak Detector Circuit
« Reply #3 on: June 29, 2013, 11:02:51 pm »
That loss of feedback when the op-amp saturates negative makes it almost impossible to measure high frequency signals. It's possible to give the op-amp some feedback on the negative half-cycle by putting another diode around the feedback loop; this helps to stabilise the op-amp, stops it oscillating, and makes the precision peak detector even more precise. See attached image (taken from page 12 here: http://www.site.uottawa.ca/~rhabash/ELG4135L8.pdf). It's a very small re-arrangement of Dave's bottom circuit.

Yes, I wanted to get into that, but I babbled on and the video was already too long, so stuck with the basic arrangement for this video. I thought that could be a part 2.
 

Offline Dennis

  • Contributor
  • Posts: 10
  • Country: us
    • Discovering Electronics
Re: EEVblog #490 - Peak Detector Circuit
« Reply #4 on: June 30, 2013, 03:10:47 am »
Great topic Dave; has anyone ever used a circuit like this to de-bounce a switch/relay? It sure looks like a simple diode/capacitor combination would work if you didn't have a Schmidt trigger handy.
Stress: The overwhelming urge to choke the crap out of someone who desperately needs it!
 

Offline fmaimon

  • Supporter
  • ****
  • Posts: 163
  • Country: br
Re: EEVblog #490 - Peak Detector Circuit
« Reply #5 on: June 30, 2013, 04:20:13 am »
Did you noticed that the opamp spikes were syncronous with the "edges" of the generated sine wave? Maybe if it was a real sine wave it would be continuous.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 6429
  • Country: nz
Re: EEVblog #490 - Peak Detector Circuit
« Reply #6 on: June 30, 2013, 10:43:47 am »
Seems to me that a peak detector and an envelope filter are exactly the same.
The envelope filter just uses a smaller cap or higher discharge resistor to create the envelop like effect.
« Last Edit: June 30, 2013, 10:50:40 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline cthree

  • Frequent Contributor
  • **
  • Posts: 258
  • Country: ca
Re: EEVblog #490 - Peak Detector Circuit
« Reply #7 on: June 30, 2013, 10:49:40 am »
Another fine quality video
 

Offline KerryW

  • Regular Contributor
  • *
  • Posts: 109
  • Country: us
Re: EEVblog #490 - Peak Detector Circuit
« Reply #8 on: June 30, 2013, 01:51:31 pm »
A good (and fast) peak detector can be made using an LM311 comparator in place of the op-amp.
Tie the output collector (pin 7) to the + supply
Tie the output emitter (pin 1) to the capacitor, no diode needed.
You need enough of a load to offset the output transistor leakage current.

The circuit is shown in the TI datasheet, fig. 24.
One accurate measurement is worth a thousand expert opinions
- Adm. Grace Hopper
 

Offline bktemp

  • Super Contributor
  • ***
  • Posts: 1623
  • Country: de
Re: EEVblog #490 - Peak Detector Circuit
« Reply #9 on: June 30, 2013, 06:26:52 pm »
I think the oscillations could be supressed by inserting a small resistor between the opamp an den capacitor (outside the feedback loop!). Yes, this makes the response to short peaks worse, but opamps don't like pure capacitive loads without any series resistance. Then the voltage would not overshoot and the opamp output would smoothly follow the input as long it is larger than the voltage at the capacitor.

Is there really no current flowing thrue a diode with no bias on it? I think this is not completely true. At least if you shine light on a 1N4148 in its transparent glass case there should be some pA or even nA flowing, depending on how much light you put into it.
In the Keithley 480 Picoammeter they have used two JFETs connected as extremely low leakige diodes at the high impedance input of the opamp as overvoltage protection. Thince the voltage at this point is exactly zero volts, they could also have used standard diodes instead of the more expensive JFETs if no current would flow in a normal diode at zero bias.
 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 14915
  • Country: za
Re: EEVblog #490 - Peak Detector Circuit
« Reply #10 on: June 30, 2013, 08:40:46 pm »
Glass bodied diodes have both photocurrent leakage and produce a photoelectric voltage with light. With zero bias they would put in an error current and with bias they would allow a leakage current. Just took a random glass diode and got a voltage of 12mV across it with just a torch. Not very repeatable, but then again I did not clean off all the black paint on it.
 

Offline dentaku

  • Frequent Contributor
  • **
  • Posts: 830
  • Country: ca
Re: EEVblog #490 - Peak Detector Circuit
« Reply #11 on: July 01, 2013, 02:14:07 am »
So a circuit like this could be used to input a regular old audio signal (a 1khz tone out of a computer or something like that) and give you a steady-ish DC voltage out that changes as the volume of the audio source changes?

I was just reading this http://www.muffwiggler.com/forum/viewtopic.php?t=14328 and I see the similarity.
 

JuanPC

  • Guest
Re: EEVblog #490 - Peak Detector Circuit
« Reply #12 on: July 01, 2013, 04:44:33 am »
Hey! What happened with DaveCad(TM)?

You should make a rubber DaveCad(TM) logo with a cnc machine or a laser machine.

Fridays my favorite day of the week  :-DD
 

Offline kaushleshchandel

  • Contributor
  • Posts: 8
  • Country: in
Re: EEVblog #490 - Peak Detector Circuit
« Reply #13 on: July 01, 2013, 03:32:10 pm »
Great video Dave!!!

This gave me an Idea. I am woking with AD9850 based signal generator. It only outputs a sine wave. And I needed square wave. So after viewing your video here is the setup I want to try. Another issue with this DDS chip is that the peak voltage varies if I change the sinewave frequency.

* Output sine wave.
* Add a peak detector to measure the max V of the sine wave, using an OpAmp based peak detection as Dave described.
* Use this feedback into another opamp that will amplify the signal from the DDS.
 

Thus, if the DDS is giving 800mV peak to peak, it can be amplified

Do you think this circuit makes sense.

 
 

Offline btober

  • Newbie
  • Posts: 1
Re: EEVblog #490 - Peak Detector Circuit
« Reply #14 on: July 01, 2013, 04:15:37 pm »
The real reason, as I'm sure Dave is well aware, for the oscillation that is seen in the behavior of the op-amp when a larger capacitor is used, is that, generally, op-amps do not "like" capacitive loads.  To elaborate a little further, unless you mean to build an oscillator, you have to avoid positive feedback, taking into account that phase shift around the feedback loop may create positive feedback in a circuit designed to have negative feedback.  I think "Stability considerations in the use of op-amps" would be a very fine topic for a future edition of Fundamentals Friday!
 

Offline Christe4nM

  • Supporter
  • ****
  • Posts: 241
  • Country: nl
Re: EEVblog #490 - Peak Detector Circuit
« Reply #15 on: July 01, 2013, 10:34:41 pm »
That loss of feedback when the op-amp saturates negative makes it almost impossible to measure high frequency signals. It's possible to give the op-amp some feedback on the negative half-cycle by putting another diode around the feedback loop; this helps to stabilise the op-amp, stops it oscillating, and makes the precision peak detector even more precise. See attached image (taken from page 12 here: http://www.site.uottawa.ca/~rhabash/ELG4135L8.pdf). It's a very small re-arrangement of Dave's bottom circuit.

Thanks! That answers the question that I wanted to ask here.
 

Offline Smokey

  • Super Contributor
  • ***
  • Posts: 1504
  • Country: us
Re: EEVblog #490 - Peak Detector Circuit
« Reply #16 on: July 02, 2013, 09:59:34 am »
...I am woking with AD9850 based signal generator. It only outputs a sine wave. And I needed square wave. ...
That chip has a built in comparator to make square waves (usually for clock generation).  Check out page 8 of the data sheet for an example circuit.
www.analog.com/static/imported-files/data_sheets/AD9850.pdf
 

Offline DBoulanger

  • Regular Contributor
  • *
  • Posts: 56
  • Country: ca
Re: EEVblog #490 - Peak Detector Circuit
« Reply #17 on: November 10, 2013, 04:01:15 pm »
That loss of feedback when the op-amp saturates negative makes it almost impossible to measure high frequency signals. It's possible to give the op-amp some feedback on the negative half-cycle by putting another diode around the feedback loop; this helps to stabilise the op-amp, stops it oscillating, and makes the precision peak detector even more precise. See attached image (taken from page 12 here: http://www.site.uottawa.ca/~rhabash/ELG4135L8.pdf). It's a very small re-arrangement of Dave's bottom circuit.

I tried this circuit, and I guess I'm missing something obvious.  The "DC" voltage at the capacitor does reflect the peak as such.  However, the output of the "follower" gives me something close to the rail, which I really don't understand.  Normally it should be pretty much the same voltage as the one presented at the non-inverting input of the "follower", right ?

I've redone my checks to validate for proper wiring many times, and I can't come up with a logical explanation.  Anyone can clarify it for me ?
 

Offline cybermaus

  • Frequent Contributor
  • **
  • Posts: 500
  • Country: nl
Re: EEVblog #490 - Peak Detector Circuit
« Reply #18 on: January 19, 2014, 05:13:54 am »
I build this peak detector, I needed if for a 25~35 KHz application and I ran into saturation recovery time issues. Which basically showed (as with the previous post?) as if follower was not following, always pressed to V- with some small peaks above it V-

I finally understood what was happening, the OpAmp recovered to slowly from saturation. This peak detector is not useable above audio frequencies. And I found there exists also a very simple improvement to Dave's example:

Just one extra component: simply add a anti-saturation diode.
Not only does it avoid saturation and thus allows much higher frequencies. It also actually reduces the current use of the circuit.

The 2nd diode (anti-saturation diode) simply allows the attempt of the opamp to equalize the inputs to not be in vain, and thus it does not saturates so drained current is much less, and by placing the resistor slightly different it the drained current actually comes from the the capacitor. If you want no sag, but a driven reset, just do not add the resistor and put a FET like normal.
 

Offline JMThomas

  • Contributor
  • Posts: 6
  • Country: us
Re: EEVblog #490 - Peak Detector Circuit
« Reply #19 on: September 06, 2015, 06:32:46 pm »
I'm terribly late to the party, but how do you know when you've captured a peak value?

In other words, what can you use to trigger the a2d sampling that reads that wonderfully charged capacitor?

(Looking at the scope trace, I could see where the op-amp started recharging the cap.  But there was often oscillation there, not to mention multiple recharges.  Would there be a Q&D way using this op-amp output to signal the ATD?)
 

Offline codeboy2k

  • Super Contributor
  • ***
  • Posts: 1838
  • Country: ca
Re: EEVblog #490 - Peak Detector Circuit
« Reply #20 on: September 07, 2015, 07:01:50 am »
You generally want your peak detector to be faster than your sample rate from the ADC.   (note: please write ADC [Analog to Digital Controller Converter], not ATD -- use the well-established acronyms). When you want to sample the peak within your sampling interval, then you know it's going to be ready and holding a peak for you. Your peak detector can be self-resetting (via a resistor across the cap, i.e. using the RC time constant) or it can be reset via a transistor across the capacitor, using an output signal from the micro after you've read the peak.  If you use a self-resetting peak-detector then you need the ADC to sample it fast enough to get the reading before it decays.  If you use a reset transistor, then your ADC can be slower than your peak detector and you can reset it after each reading.

To design the peak detector you need to know your input signal, and design it so that it is fast enough to track and hold the peaks that you want (i.e. choose the proper op-amp and cap)

Peaks are always going to be within some time period that you establish. You can wait 1 us or 1 second for a peak to arrive. It's completely up to you and usually depends on what you are sampling. You just need to make the peak detector hold it that long, and you sample it at the required rate.

You can't just decide that I'll wait for the peak to arrive and trigger the ADC when it does, because how long should you wait?  You can't wait forever, so you have to wait some time period.  This is going to be your ADC sample rate.

Yes, you can get fancy and do some tricky stuff with analog switches, holding caps and comparators to hold the previous peak value value and the current value and trigger the ADC using the comparator output when the current value is greater than the previous value.  But you generally don't need that added complication, if your peak detector is fast enough you can just sample the peak value periodically.

« Last Edit: September 10, 2015, 03:36:49 pm by codeboy2k »
 

Offline lewis

  • Frequent Contributor
  • **
  • Posts: 697
  • Country: gb
  • Nullius in verba
Re: EEVblog #490 - Peak Detector Circuit
« Reply #21 on: September 09, 2015, 08:21:46 pm »
note: please write ADC [Analog to Digital Controller],

Ahem, it's Analogue* to Digital Converter

*British spelling of Analogue.
I will not be pushed, filed, stamped, indexed, briefed, debriefed or numbered.
 

Offline codeboy2k

  • Super Contributor
  • ***
  • Posts: 1838
  • Country: ca
Re: EEVblog #490 - Peak Detector Circuit
« Reply #22 on: September 10, 2015, 03:35:25 pm »
note: please write ADC [Analog to Digital Controller],

Ahem, it's Analogue* to Digital Converter

*British spelling of Analogue.

*embarassed* yeah, converter... I knew that too, for several years now :)  I slipped, thanks for the correction, I fixed it.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf