opamp peak detect problem

Discussion in 'General Electronics Chat' started by toozie21, Oct 30, 2013.

  1. toozie21

    Thread Starter Member

    Oct 4, 2012
    43
    1
    I am trying to create a peak detect with an opamp and am having some issues (I am more of a digital guy). The voltage I expect is somewhere in the 0V-3.3V range. I am using a Microchip MCP6021 (datasheet) as my opamp and the pulse of interest is going through a 10k resistor to V+. The output goes through a 1N914 diode then then can either 1) go through a 10k to V-, or go through a 0.1uF cap to ground. The opamp is running off of a 3.3V supply.

    If I monitor the voltage after the diode, it seems like it just locks in on the max voltage in this case, and I cannot reset it. I put a momentary pushbutton across the cap to ground to try to clear it out, but it only works when I am pushing the button in, when I let go the voltage bounces back up.

    I also put a 5Mohm cap across the cap to ground to bleed off the cap (an RC of 0.5s), but that doesn't seem to have an effect.

    What simple thing about opamps am I missing here?
     
  2. ronv

    AAC Fanatic!

    Nov 12, 2008
    3,290
    1,255
    A schematic might be in order.
     
  3. toozie21

    Thread Starter Member

    Oct 4, 2012
    43
    1
    Good call.

    Here is what I had been trying to do: link

     
  4. JohnInTX

    Moderator

    Jun 26, 2012
    2,345
    1,028
    Feedback. You're running open loop at max gain. A very small differential on the inputs will rail the amp.

    Typical peak-detector circuit here (just googled it so take yer chances).
     
  5. toozie21

    Thread Starter Member

    Oct 4, 2012
    43
    1
    Interesting. Is that because I have 10k/0k (infinity) for the gain?
     
  6. JohnInTX

    Moderator

    Jun 26, 2012
    2,345
    1,028
    More like infinity/10K, still open-loop and running at the maximum (called open-loop) gain of the amplifier.

    Here's a good reference.
    TI/BurrBrown

    This one is from the old National Semiconductor Linear Applications Handbook - the analog bible of its day.

    Both show peak detection / precision rectifier applications as well as formulae for calculating the resistors for various configurations.

    Have fun!
     
    Last edited: Oct 30, 2013
    toozie21 likes this.
  7. toozie21

    Thread Starter Member

    Oct 4, 2012
    43
    1
    Thank you for the references. I was looking through both of them and I couldn't find anything in the TI reference that looked like a peak detect.

    The National Semi did have a low-drift peak detect that used two op amps, so I will have to investigate that further (I was expecting a single one more like the link from your first reply.

    I did mock up something from the first link it is looked A LOT better (wasn't railing). I left R2 at zero ohms for now, but need to experiment/read up more since I am still getting more well versed. I do believe (if I understand it right), that I have a gain of 1 (no gain), if I leave R2 as 0 ohm, which is fine by me for now.
     
  8. Slarsen

    New Member

    Apr 29, 2013
    12
    4
    What you have there in your schematic is indeed a peak detector. Your problem is that you need a little more knowledge on how to use op amps.

    An op amp has an enormous gain, ideally infinite. To operate as a linear amplifier you need to provide negative feedback using a couple of resistors. I will explain how to do this in a moment.

    Without feedback an op amp acts as a comparator. When Vin+ is lower than Vin-, the output sits at the negative power supply voltage. When Vin+ is greater than Vin-, the output sits at the positive power supply voltage.

    So in your circuit, when the pulse voltage is greater than the peak-hold voltage, the output goes to 3.3 V. The purpose of the diode is to keep the capacitor from discharging once the pulse drops back below the peak_hold voltage. (As I'm sure you know.)

    Now, if you discharge the capacitor with a switch or whatever and then its voltage immediately pops back up, that means the pulse input must still be higher than peak_hold. (And it means you're shorting the output to the negative rail when discharging the capacitor. Fortunately most op amps will survive this type of assault.)

    In conclusion, your circuit will work as long as your input voltage levels are how I described them. (Assuming the op amp isn't defective.) However, op amps don't care much for capacitive loads. I suggest inserting a 100 ohm resistor between the op anp and the capacitor.

    Oh, one other thing... are you sure this op amp is designed to work with a single power supply? Many require both a positive and negative supply. (Though there are ways to work around that limitation.) Also, are you sure it will work properly with a 3.3V supply, which is rather low? Another thing to consider is what the ouput voltage range is. Many op amps don't operate rail-to-rail. An LM324A would work in your application.

    Now let me explain how to make a linear amplifier using an op amp. There are three possibilities:

    1. Voltage Follower

    Attach the output of the op amp to the the Vin- input. Vin+ is then the input of your linear amp. The output voltage will follow the input with no amplification. The input impedance is very high, virtually infinite for some op amps.

    2. Non-Inverting Amp

    The output of the op amp is connected to resistor R1, whose other lead is connected to resistor R2, whose other lead is connected to ground. In other words, the output of the op amp is connected through a voltage divider to ground. The junction of the two resistors is connected to the Vin- input of the op amp. The output will follow the input but with a gain calculated as follows:

    Gain = R1/R2 +1

    You also need to connect a resistor from the Vin+ input to ground to keep its voltage from floating aimlessly.

    Typical resistor values: For a gain of ten, for example, make R1 = 9k and R2 = 1k. If the device has FET inputs, almost any resistance could be use for the input resistor. But if not, your input resistor should be somewhat close to R1 or R2, whichever is lower. If it's greater than that, the tiny bias current flowing through it will produce a voltage on the Vin+ input which will be amplified and seen at the output. If you calculate the resistance as though R1 and R2 were in parallel and use that resistance, that will result in the ideal situation.

    The input impedance of this amp is the same as the input resistor.

    3. Inverting Amp

    For the inverting amp, connect R1 and R2 as in the case of the non-inverting amp, but instead of connecting R2 to ground, use it as the input instead. And connect the op amp's Vin+ to ground.

    The gain for this amp is:

    Gain = - R1/R2

    The minus sign on the gain indicates that it's an inverting amp. The input impedance is the same as R2.

    The output impedance of all three circuits is virtually zero. If you want an output impedance of say, 50 ohms, you'd insert a 50 ohm resistor between the op amp's output and the load. Note that in doing this, the gain when a load is connected is half what it is without the load.

    Note that these amplifier circuits typically have both a positive and negative power supply.

    You might understand the brilliance behind the op amp concept if you take note of one thing. In all three cases above, the voltage of the Vin- input will always be the same as at the Vin+ input regardless of what the input voltage is. That's the reason the internal gain of the op amp needs to be infinite. (In theory, that is. In practice, real op amps have a gain less than infinite, though still quite large. The voltage difference between Vin+ and Vin- won't quite be zero. It will be the output voltage divided by the op amp's internal gain. For example, if the op amp has a gain of 1 million, the voltage difference will be 1 microvolt. So virtually zero.)
     
    toozie21 likes this.
  9. toozie21

    Thread Starter Member

    Oct 4, 2012
    43
    1
    Wow, and amazing writeup, thank you so much!!!

    I am dividing down a voltage that is being fed into the opamop, so I am not too worried about amplifying it, so I guess I really only need a voltage follower then, right? In theory I should have a voltage that is almost always 0V, then it will very quickly pop up to some voltage between 0 and 3.3V. I am hoping to have a micro interrupt when that happens and read the peak-hold value for that cycle and go back to sleep.

    Do you recommend the 100ohm resistor between the opamp and the cap for a voltage follower as well (and if so, before or after the diode?)?

    My opamp is a rail-to-rail, single supply (2.5-5.5V) linear type, so I should be good there.

    Again, and incredible write-up with lots of new info for me, and reminding me of some stuff from school years ago that I had forgotten.
     
  10. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    Some circuit diagrams would be in order at this point:

    [​IMG]
     
  11. toozie21

    Thread Starter Member

    Oct 4, 2012
    43
    1
    OK, I am making some progress and feeling good, but I do have another question.

    Here is a breakdown of what I am currently doing. My question is, why is the 10uF cap bleeding off so quickly even though I removed the bleed-off resistor?

    [​IMG]
    P.S. The notes were for me in the schematic, don't read into them too much, they aren't of any value :)
     
  12. Jony130

    AAC Fanatic!

    Feb 17, 2009
    3,957
    1,097
    Diode reverse leakage current may be responsible for cap bleeding off so quickly.
    Or load resistance also can quickly discharge the cap.
    t = R*C = 10K *10uF = 100ms Voltage at cap after 100ms is equal to 2/3 Vinitial.
    and the cap will be full discharge after t = 5*R*C
    http://youtu.be/jllsqRWhjGM?t=17m27s
     
  13. toozie21

    Thread Starter Member

    Oct 4, 2012
    43
    1
    Hmmm, it might be the latter because I just checked the specs on the 1N914 I am using and it speds a Vr of 5uA @ 75V.
     
Loading...