# Op-amp peak detector with gain

Discussion in 'Electronic Basics' started by SDC, Sep 9, 2006.

1. ### SDCGuest

I need a single-supply positive peak detector with a gain of 2. (Previously
I used an op-amp with a gain of 2 followed by a peak detector, but would
like to simplify the circuit.) The input voltage will range from 0V to about
2.5V.
Will the following circuit work? (Please excuse my ignorance - I don't have
much experience with op-amps.)

.... Steve

IC=LM324

+-[10K]-+----[10K]----+----------+
| | | |
=== | | |\ |
GND | |\ +-- |-\ |
+--|-\ 1N4148 | >---+---o Vout = Vin(pk) x 2
| >-->|--+----|+/
Vin o-------|+/ | |/
|/ 0.01uF---

2. ### EeyoreGuest

You need the diode in the feedback loop to avoid seeing a significant effect
from the forward voltage drop.

Graham

3. ### SDCGuest

In my circuit, won't the first op-amp's output just rise to about 0.6V
higher and automatically compensate for the diode to balance the circuit, as
it would do in a standard (unity gain) peak detector as shown below:-

IC=LM324
+-------------+---------+
| | |
| | |\ |
| |\ +--|-\ |
+--|-\ 1N4148 | >---+---o Vout = Vin(pk) x 2
| >-->|--+---|+/
Vin o-------|+/ | |/
|/ 0.01uF---

4. ### SDCGuest

A typo in my last post with the unity gain peak detector. Vout=Vin(pk), NOT
Vout = Vin(pk) x 2

.... Steve

5. ### EeyoreGuest

Yes, silly me ! I haven't actually seen that configuration previously so I
missed that point.

You'll need to consider drift due to the input bias current of the 2nd op-amp
btw.

for bandwidth and precision ?

Graham

6. ### SDCGuest

This circuit will only be used for test purposes, and precision isn't too
important. I'm developing a 2-quadrant 12V, <= 40A regenerative brush-motor
controller and will eventually measure both driving and braking currents for
current limiting. I'm using a PIC16F876 to run the show. Although I'm
running the PWM at 20kHz, the motor's inductance smoothes this to a more
constant voltage, so bandwidth isn't much of a problem either. The sensing
element is a 10 milliohm, 3W (Ohmite) current-sensing resistor and the
amplifier's front end is a precision op-amp rectifier with a (maximum) gain
of 5, giving 50mV/A. I want a total gain of 10, so that the output is
100mV/A, hence the extra gain in the peak detector stage.
I need the input to be able to go right to 0V and wanted to keep the parts
count and cost as low as possible. That's why I'm using an LM324. (Also,
it's the only quad op-amp that I have on hand.)
Why is this a bad choice?

.... Steve

7. ### EeyoreGuest

I'd have thought that the LM324's inpur bias current will cause quite a high
rate of droop ( or rise ) in the peak detector voltage on the cap. Yes, it's pnp
input. So, in the absence of an input, your output will float toward the supply
rail.

Are they really OK with inputs as low as ground on a single supply btw ?

Graham

8. ### SDCGuest

Thanks for the continued interest Graham. The LM324 datasheet claims
that the common-mode input range extends to the negative supply rail, as
does the output if it is not heavily loaded. It also claims fairly low input
bias currents, about 100nA for the '324A. This is why I'm using the '324,
(besides the prev mentioned fact that it's the only quad that I have on
hand). However, I don't want the output to rise in the absence of inputs.
This could potentially be a problem. I was probably going to add a
high-value, (1M to 10M, yet to be determined), bleed resistor across the
cap. Do you think the voltage across the capacitor would still rise due to
the input bias current, even if I used a 10M resistor, allowing for the
leakage of the cap?

.... Steve

9. ### SDCGuest

It appears that mt ISP is having problems. 10 minutes and my reply hasn't
appeared, so here it is again:-

Thanks for the continued interest Graham. The LM324 datasheet claims
that the common-mode input range extends to the negative supply rail, as
does the output if it is not heavily loaded. It also claims fairly low input
bias currents, about 100nA for the '324A. This is why I'm using the '324,
(besides the prev mentioned fact that it's the only quad that I have on
hand). However, I don't want the output to rise in the absence of inputs.
This could potentially be a problem. I was probably going to add a
high-value, (1M to 10M, yet to be determined), bleed resistor across the
cap. Do you think the voltage across the capacitor would still rise due to
the input bias current, even if I used a 10M resistor, allowing for the
leakage of the cap?

.... Steve

10. ### EeyoreGuest

The 10M will limit the effect to 100.10^-9 x 10.10^ 6 = 1000.10^-3 or 1V !

You need a fet input op-amp.

Graham

11. ### SDCGuest

When you put it like that:- (10^-9 x 10.10^ 6 = 1000.10^-3 or 1V !)
Incidentally, I hadn't realised that the input stage of the '324 was PNP.
I don't have room for 4 single FET input op-amps. I could use a pair of
CA3230's, if I can find them. Off the top of your head, do you know of a
quad FET input op-amp with a common mode input range and output that extends
to 0V, (in a 5V single-supply circuit)?
I'll also do a quick Google
.... Steve

12. ### EeyoreGuest

You specifically need 4 ?

Unless DC precision is an a big issue, I'd look at TI's offerings. I'm sorry but
I'm not that familiar with the single supply types.

Graham

13. ### SDCGuest

Yes, I do need four - two for the precision rectifier and two for the peak
detector. In my prototype, I used separate CA3130E's. I just checked out a
few of the LFxxx series and the LT1058, but their input/output ranges aren't
suitable. Thanks for the tip and for all of your help. I'm grateful. I'll
check out the TI site in the morning. I'll also check back here in case
someone has made any suggestions. It's getting late here, (NSW Australia),
so I'd better hit the sack.

.... Steve

14. ### SDCGuest

We've already covered this point in the earlier posts. The diode will not
introduce any error.
.... Steve

15. ### SDCGuest

I should have added that a fast, low-leakage would make a difference,
though.
.... Steve

16. ### SDCGuest

I left out the "diode". I'm getting tired.
.... Steve

17. ### John LarkinGuest

You'll eventually need to discharge that cap, too. Some opamps, like
the 324, have positive input bias current so will charge the cap until
it hits the positive rail.

John

18. ### SDCGuest

Yep, that's the biggest drawback. (We also covered this earlier). I've spent
the last hour or two searching for a suitable rail-to-rail input and output
running a close second.

.... Steve

19. ### Fred BartoliGuest

SDC a écrit :
No need for a 'fancy' opamp.
You can easily make it like that:

+-[10K]-+----[10K]----------------+----------+
| | | |
=== | + | |\ |
GND | |\ | `-- |-\ |
+--|-\ 1N4148 |/ | >---+---o Vout = Vin(pk) x 2
| >-->|--+---+---|\ .---|+/
Vin o-------|+/ | | v | |/
|/ | | +---'
0.01uF--- RL |
--- | 1M
| | |
=== === ===
GND GND GND

Or better if you have enough supply:

+-[10K]-+----[10K]-----------------+----------+
| | | |
=== | 2N7000 + | |\ |
GND | |\ | `---|-\ |
+--|-\ 1N4148 |- | >---+---o Vout = Vin(pk) x 2
| >-->|--+---+---||<. .---|+/
Vin o-------|+/ | | |-| | |/
|/ | | +--'
0.01uF--- RL |
--- | 10K
| | |
=== === ===
GND GND GND

20. ### SDCGuest

"Fred Bartoli"
Hi Fred, I only have a 5V supply for this circuit, not high enough for a
MOSFET, so the first of your suggestions is more suitable. It looks good to
me. I don't know why I didn't think of it. It's almost 2am here, so I'd
better get to bed and continue tomorrow. (I said this a couple of hours ago)