Author Topic: Peak detector nightmare.  (Read 12291 times)

0 Members and 1 Guest are viewing this topic.

Offline DBoulangerTopic starter

  • Regular Contributor
  • *
  • Posts: 56
  • Country: ca
Peak detector nightmare.
« on: November 15, 2013, 07:27:36 am »
Hi everyone,

I'm just trying to set a bare bone peak detector.

I've tried multiple circuits, but can't get it to work as expected.

The last one I tried is the one presented in the picture.  You will see the circuit on the first picture, then the expected result.

I don't come close to what's on the pic. For instance, the output doesn't follow whatsoever, simply dead, nada.  I changed, tested the diode numerous times, I tried with a TL072 and a TL074.  No luck whatsoever.

If possible, could someone give it a try, even with a u741, just to see if that works and if it does, I'd greatly appreciate if you could post screenshots from the oscilloscope and even of the breadboard, so that I "see" where I goofed.

Thanks for your help.

PS : The results shown on the pic are based on a +/-15 V supply and a 5Vpp input signal.  I just want to use that peak detector for signals roughly from 1Hz to 150-200KHz.  If you have better solution(s) than the one presented here, by all means, feel free to suggest.

Thank you for your help.
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1673
  • Country: pl
  • Troll Cave Electronics!
Re: Peak detector nightmare.
« Reply #1 on: November 15, 2013, 07:44:47 am »
LTSpice says it works. Moreover, I've used such a circuit many times and it works. Albo, you should use low offset fast comparator for that to achieve best results.

Either circuit labs simulator sucks or you set it up wrong.


I love the smell of FR4 in the morning!
 

Offline johansen

  • Super Contributor
  • ***
  • Posts: 1221
Re: Peak detector nightmare.
« Reply #2 on: November 15, 2013, 07:50:19 am »
a closer look at OP's output suggests a bug in the simulator.
edit: being drunk, couldn't quite tell the difference between the colors representing V prediode and V out. the circuit is simulated correctly..
« Last Edit: November 15, 2013, 07:52:37 am by johansen »
 

Offline AndyC_772

  • Super Contributor
  • ***
  • Posts: 4348
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: Peak detector nightmare.
« Reply #3 on: November 15, 2013, 08:17:49 am »
TL074 is way too slow to do peak detection on a 200kHz signal. Whenever the peaks occur in your signal, the output has to slew all the way from saturation at the negative rail to the peak value of the signal, and then charge the capacitor. It's a much more demanding application than simply amplifying a 200kHz signal linearly.

The critical parameter to look for when considering an op-amp for this type of circuit is the slew rate. The figure you'll most often see quoted for a device is its bandwidth, or more specifically, the gain-bandwidth product. Often, though these figures are rather optimistic, and only really apply for very low level signals. The rate of change of the output voltage depends not just on the frequency of the signal but also its amplitude, and here you're working with a very high amplitude signal: 15V (the magnitude of the negative supply voltage) plus the peak voltage of the signal. That's the range over which the output of the op-amp has to swing.

At the opposite end of your range, if you want the circuit to work down to a few Hz, then you'll need a large capacitor. This isn't necessarily a major problem, but it will mean that your op-amp will take many cycles to charge it up... you won't be measuring instantaneous peaks, more like a long-term average of the positive extent of your signal.

First thing to do IMHO is find why your circuit isn't working at all. Set it to a nice low frequency - a few hundred Hz will do - and check it's working as expected. Post your actual measurements on each pin of the op-amp if it's still misbehaving. Then, ramp up the frequency and observe the output of the op-amp, you'll soon see the problem with using it at higher speeds.

You don't need the pull-down on the -ve input of the op-amp, by the way - it's in parallel with the resistor you already have across the output capacitor.

Offline qno

  • Frequent Contributor
  • **
  • Posts: 422
  • Country: nl
Re: Peak detector nightmare.
« Reply #4 on: November 15, 2013, 10:38:44 am »
The 10 uF capacitor is to large to charge in on time by the 081.
Try someting in the 1 to 10 nF range.

Put a diode between the - input of the opamp and the output of the output with the kathode connected to the output.
This wil solve som of the slew rate problems.
Why spend money I don't have on things I don't need to impress people I don't like?
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1673
  • Country: pl
  • Troll Cave Electronics!
Re: Peak detector nightmare.
« Reply #5 on: November 15, 2013, 01:16:27 pm »
I remember using LM339 for peak detection of 100kHz sine wave, although I've used a smaller capacitor value. Also, LM339 has an open-collector output, so you may need to increase charging current somehow. There are multiple ways including current source, push-pull stage, using other comparator with push-pull output or even inverting the input signal and flipping the whole circuit around the ground potential and driving the capacitor below GND with OC output only.
I love the smell of FR4 in the morning!
 

Offline qno

  • Frequent Contributor
  • **
  • Posts: 422
  • Country: nl
Re: Peak detector nightmare.
« Reply #6 on: November 15, 2013, 08:37:12 pm »
Open collector comparators are not suitable for this circuit.

Maybe you mean an LM324?
Why spend money I don't have on things I don't need to impress people I don't like?
 

Offline KerryW

  • Regular Contributor
  • *
  • Posts: 112
  • Country: us
Re: Peak detector nightmare.
« Reply #7 on: November 15, 2013, 09:20:16 pm »
How about open EMITTER comparators?

The data sheet for the LM311 shows a FAST peak detector circuit.

The LM311 has an uncommitted emitter and collector.  Tie the collector to + voltage.  Tie the emitter to a cap, and to the - input.  Apply pulses to the + input.  You will need a large resistor to drain the transistor leakage.
One accurate measurement is worth a thousand expert opinions
- Adm. Grace Hopper
 

Offline smashedProton

  • Frequent Contributor
  • **
  • Posts: 642
  • Country: us
Re: Peak detector nightmare.
« Reply #8 on: November 15, 2013, 09:43:12 pm »
You can get rid of RL.  The cap will drain in a quarter of a second the way it is set up now.
http://www.garrettbaldwin.com/

Invention, my dear friends, is 93% perspiration, 6% electricity, 4% evaporation, and 2% butterscotch ripple.
 

Offline smashedProton

  • Frequent Contributor
  • **
  • Posts: 642
  • Country: us
Re: Peak detector nightmare.
« Reply #9 on: November 15, 2013, 09:50:19 pm »
Please don't tell me that you actually have a 0 ohm resistor in there...
http://www.garrettbaldwin.com/

Invention, my dear friends, is 93% perspiration, 6% electricity, 4% evaporation, and 2% butterscotch ripple.
 

Offline DBoulangerTopic starter

  • Regular Contributor
  • *
  • Posts: 56
  • Country: ca
Re: Peak detector nightmare.
« Reply #10 on: November 15, 2013, 11:50:55 pm »
LTSpice says it works. Moreover, I've used such a circuit many times and it works. Albo, you should use low offset fast comparator for that to achieve best results.

Either circuit labs simulator sucks or you set it up wrong.




I can confirm you that my setup has been validated and revalidated multiple times.

For the emulator, I have some reserves in the sense that important specs, such as the bandwidth and the slew rate, don't seem to be adjustable.  So regardless of the opamp being specified, even a u741 would have done a perfect job, even if we know that this is actually impossible with a slew rate so low as 0.5v/us, right ?

So I feel that what the author attempted here is to present the concept although the opamp he used in his example wasn't up for the task.

Thanks for your time.
 

Offline DBoulangerTopic starter

  • Regular Contributor
  • *
  • Posts: 56
  • Country: ca
Re: Peak detector nightmare.
« Reply #11 on: November 15, 2013, 11:55:40 pm »
a closer look at OP's output suggests a bug in the simulator.
edit: being drunk, couldn't quite tell the difference between the colors representing V prediode and V out. the circuit is simulated correctly..

As mentioned previously, the emulator didn't provide any way to customize important opamp caracteristics, so the suggested circuit was assuming perfect conditions, which were far from being met with a TL082, nor with the TL07x's I attempted to replicate the circuit with.

Regards.
 

Offline DBoulangerTopic starter

  • Regular Contributor
  • *
  • Posts: 56
  • Country: ca
Re: Peak detector nightmare.
« Reply #12 on: November 16, 2013, 12:05:17 am »
TL074 is way too slow to do peak detection on a 200kHz signal. Whenever the peaks occur in your signal, the output has to slew all the way from saturation at the negative rail to the peak value of the signal, and then charge the capacitor. It's a much more demanding application than simply amplifying a 200kHz signal linearly.

The critical parameter to look for when considering an op-amp for this type of circuit is the slew rate. The figure you'll most often see quoted for a device is its bandwidth, or more specifically, the gain-bandwidth product. Often, though these figures are rather optimistic, and only really apply for very low level signals. The rate of change of the output voltage depends not just on the frequency of the signal but also its amplitude, and here you're working with a very high amplitude signal: 15V (the magnitude of the negative supply voltage) plus the peak voltage of the signal. That's the range over which the output of the op-amp has to swing.

At the opposite end of your range, if you want the circuit to work down to a few Hz, then you'll need a large capacitor. This isn't necessarily a major problem, but it will mean that your op-amp will take many cycles to charge it up... you won't be measuring instantaneous peaks, more like a long-term average of the positive extent of your signal.

First thing to do IMHO is find why your circuit isn't working at all. Set it to a nice low frequency - a few hundred Hz will do - and check it's working as expected. Post your actual measurements on each pin of the op-amp if it's still misbehaving. Then, ramp up the frequency and observe the output of the op-amp, you'll soon see the problem with using it at higher speeds.

You don't need the pull-down on the -ve input of the op-amp, by the way - it's in parallel with the resistor you already have across the output capacitor.

You were right, the TL07x wasn't up for the task.  I have to conclude that the given circuit was simply for study and explain the concept.  Not taking in account the slew rate to start with, was a bad start.  Knowing that the slew rate was important, I took for granted that the circuit was already tested with physical components, but obviously, this is not the case.

This is how we learn, I guess !

Thanks for you comments.
 

Offline DBoulangerTopic starter

  • Regular Contributor
  • *
  • Posts: 56
  • Country: ca
Re: Peak detector nightmare.
« Reply #13 on: November 16, 2013, 12:08:55 am »
I remember using LM339 for peak detection of 100kHz sine wave, although I've used a smaller capacitor value. Also, LM339 has an open-collector output, so you may need to increase charging current somehow. There are multiple ways including current source, push-pull stage, using other comparator with push-pull output or even inverting the input signal and flipping the whole circuit around the ground potential and driving the capacitor below GND with OC output only.

I recall seeing a circuit with that comparator, claiming to be somehow accurate up the the 150KHz mark.  Even if I find something else, I will give it a try, just to practice and learn.  At least with that circuit using the LM339, this was an already used circuit, not simply a potentially misleading simulation.

Thanks for bringing that idea.
 

Offline DBoulangerTopic starter

  • Regular Contributor
  • *
  • Posts: 56
  • Country: ca
Re: Peak detector nightmare.
« Reply #14 on: November 16, 2013, 12:11:56 am »
How about open EMITTER comparators?

The data sheet for the LM311 shows a FAST peak detector circuit.

The LM311 has an uncommitted emitter and collector.  Tie the collector to + voltage.  Tie the emitter to a cap, and to the - input.  Apply pulses to the + input.  You will need a large resistor to drain the transistor leakage.

I'm eager to learn more, so yes, I will consider doing something with that LM311, just for education and comparaison.  Practice makes perfect they say, so I have some work to do here !

Thanks.
 

Offline DBoulangerTopic starter

  • Regular Contributor
  • *
  • Posts: 56
  • Country: ca
Re: Peak detector nightmare.
« Reply #15 on: November 16, 2013, 12:16:11 am »
Please don't tell me that you actually have a 0 ohm resistor in there...

Hi there,

Yes, I got rid of RL which was in parallel with the capacitor.  As for the feedback resistor, like the simulation picture was stating, it was there to play with and potentialy adjust the gain.

Anyhow, with the TL07x I tried, regardless of the gain, that wasn't doing any good, simply because that type of opamp is not suited for this kind of job.

Thanks for your comment.
 

Offline DBoulangerTopic starter

  • Regular Contributor
  • *
  • Posts: 56
  • Country: ca
Re: Peak detector nightmare.
« Reply #16 on: November 16, 2013, 01:01:10 am »
Hi guys,

To make a long story short, I've been successful at having a working circuit.

So the first thing that was changed is the opamp, naturally.  Perhaps I went to an extreme, nevertheless, it works and this is what is important.  I'm using now an EL2244C having a modest 200 to 325 V/us slew rate.  So changing the opamp, changing the supply from +/-15V to +-5V and limiting the input to roughly 2.5-3Vpp, I'm now able to have a fairly precise peak reading above 200KHz.  In fact, I've tested it up to 6MHz and had a reading within 3% of the expected value.

There is no more RL, there is no feedback resistor, so I have a follower equivalent, the capacitor is a 10nF and finaly, I have a 500k resistor in serie with a 1M pot connected between the inverting input and the ground.

BTW, with the TL07x, I had a 50% reading error at 10KHz, so for that purpose, this opamp is simply useless.

Thanks everyone for your comments that helped me to take the right path to success.
« Last Edit: November 16, 2013, 01:03:51 am by DBoulanger »
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1673
  • Country: pl
  • Troll Cave Electronics!
Re: Peak detector nightmare.
« Reply #17 on: November 18, 2013, 01:09:40 pm »
Open collector comparators are not suitable for this circuit.

Maybe you mean an LM324?

No, an LM339. And it works. My masters thesis used two such peak detectors, and as a matter of fact they were not buffered, the capacitor was being charged through the pullup resistor only (but that was because i didn't know any better back then). And it worked. IIRC I've measured about 20mV or so of error between actual peak value and detector output at 100kHz and up to 3Vpp
I love the smell of FR4 in the morning!
 

Offline DBoulangerTopic starter

  • Regular Contributor
  • *
  • Posts: 56
  • Country: ca
Re: Peak detector nightmare.
« Reply #18 on: November 18, 2013, 03:40:52 pm »
Open collector comparators are not suitable for this circuit.

Maybe you mean an LM324?

No, an LM339. And it works. My masters thesis used two such peak detectors, and as a matter of fact they were not buffered, the capacitor was being charged through the pullup resistor only (but that was because i didn't know any better back then). And it worked. IIRC I've measured about 20mV or so of error between actual peak value and detector output at 100kHz and up to 3Vpp

My final protoboard isn't completed yet, so I will consider giving it a try with the LM339 and most likely the LM393 as buffering isn't really mandatory.  I have to admit, would that be with the TL07x or the EL2244, I haven't been too successful with that voltage follower buffering thingy.

I will evaluate if 100KHz is actually sufficient for my project and if so, I will consider the LM339 approach as well.  Afterall, these comparators are way cheaper than the EL2244 and if they do fit my purpose, that will allow me to save the EL2244 for something more "demanding".

Afterall, this is purely to have some fun, learn and practice, so if I happen to have some alternative ideas and they work for me, there is absolutely nothing wrong with that.

BTW, after searching and reading for peak detectors and window comparators, the LM339 seem to be used by a lof of people, so there must be a good reason for that.  I have to be aware of that open collector output structure, but that shouldn't be a show stopper.

Also, if everything work as suggested, I'll be able to get my 2 peak detectors and a window comparator out of the same IC, although I'm interested by a tri-state window comparator, which will indicate if the signal is Above, In or Below the expected window/range, so I more likely will end up wih 2 ICs instead of one, but that's not really a concern.

Thanks again for your comment.
 

Offline Fagear

  • Regular Contributor
  • *
  • Posts: 83
  • Country: ru
Re: Peak detector nightmare.
« Reply #19 on: November 18, 2013, 04:18:24 pm »
In one of my projects I used peak detector with both positive and negative detecting.
Scheme is in attachments. It registers both positive and negative parts of waveform.
Input impedance is 5 k (10 k into inverting input parallel with 10 k to ground into noninverting input). Opamp I've used is JRC4560.
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1673
  • Country: pl
  • Troll Cave Electronics!
Re: Peak detector nightmare.
« Reply #20 on: November 19, 2013, 08:42:18 am »
The inverting input of the comparator should be connected to the capacitor, so that the comparator can compensate for the voltage drop across the diode. What you have on those pictures there is buffer followed by a half wave rectifier.

It can be used if you don't care about accuracy at all but frankly, there is no reason to do so, as it takes identical number of components as a real peak detector.

I love the smell of FR4 in the morning!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf