---
title: Precision rectifiers and log amplifiers
heading: Putting diodes and transistors inside the feedback loop
eyebrow: C6 · Lesson 28 · Precision rectifiers and log amplifiers
xp: 40
---

::: hook
A diode rectifier throws away the first 0.7 V of every signal, so it can't measure a 100 mV sine at all. Put the diode inside an op amp's feedback loop and the op amp drives its output whatever it takes to make the diode conduct, so the rectified output follows the input down to microvolts: a **precision rectifier**. The same trick with a transistor's exponential in the loop turns an op amp into a **log amplifier**, whose output is proportional to the logarithm of its input over many decades.
:::

::: play
- Two half-wave rectifiers fed the same 1 V sine: a plain diode into a resistor, and a **superdiode**, with the diode inside an op amp's feedback loop.
- The plain diode's output only begins when the input passes about 0.6 V. The superdiode's follows the positive half cycles exactly.
- Lower the input amplitude toward 0.1 V: the plain rectifier gives nothing, while the superdiode still rectifies.
:::
:::

```sim circuit
VIN in 0 sine 1 V 1k Hz         @ 0,1 down 4
D2 in out2                      @ 0,1 right 3
RL2 out2 0 10k                  @ 3,1 down 4
U1 in out x VSAT=12 GBW=1M      @ 5,3 flip
D1 x out                        @ 8,3 right 2
RL out 0 10k                    @ 10,3 down 2
slider: VIN.amp 0.1..2 log
scope: v(in), v(out), v(out2)
time: 0..3m s
```

::: predict
## A superdiode uses an op amp with an open-loop gain of 10⁵. How small an input can it still rectify?

- [ ] 0.7 V
- [ ] About 0.1 V
- [x] About 7 µV
- [ ] Any input at all, however small

::: reveal
About 7 µV: the diode still needs 0.7 V, but the op amp supplies it, needing only $0.7/10^5$ at its input to do so. In practice the op amp's offset voltage and speed limit it first: when the input goes negative the op amp's output swings to its rail, and recovering from there takes time.
:::
:::

::: nameit
## Precision rectifiers

**Superdiode.** An op amp drives the diode, and feedback is taken from the diode's cathode (the output). While the input is positive, the op amp raises its own output to one diode drop above the input, and the output equals the input. When the input goes negative, the diode turns off, the output rests at 0 V through the load, and the op amp's output drops to its negative limit: slow to recover at high frequencies.

**Better half-wave.** An inverting amplifier with one diode in its feedback path and a second diode catching the other polarity keeps the op amp in its linear range throughout.

**Full-wave (absolute value).** A half-wave rectifier's output, doubled and summed with the input in an inverting summer, gives $|v_\text{in}|$. Averaging it gives $\frac{2}{\pi}V_p$ for a sine, which AC voltmeters scale by $\frac{\pi}{2\sqrt2} = 1.11$ to read RMS.

**Precision peak detector.** A superdiode charging a capacitor holds the input's peak; its droop is set by leakage and the buffer's bias current, $dV/dt = I_B/C$.

## Log and antilog amplifiers

A transistor in the feedback path of an inverting amplifier, its collector at the virtual ground: the input current $v_\text{in}/R$ must flow in the collector, so the output sits at $-V_{BE}$:

$$v_\text{out} = -V_T\ln\frac{v_\text{in}}{RI_S}$$

about −60 mV per decade of input, accurate over five or more decades. Swapping the transistor and resistor gives the **antilog** (exponential) amplifier, $v_\text{out} = -RI_Se^{v_\text{in}/V_T}$. Both drift with temperature through $V_T$ and $I_S$, so practical log amps subtract a matched transistor's $V_{BE}$ and correct for $V_T$. Logs turn multiplication into addition: log, add, antilog is an analog multiplier.
:::

```sim circuit
VIN in 0 1                      @ 0,0 down 3
RIN in m 10k                    @ 0,0 right 2
Q1 m 0 out npn IS=1e-14         @ 3,-2 left
U1 0 m out                      @ 2,1
slider: VIN.amp 0.001..10 log
scope: v(out)
time: 0..1m s
meter: v(out)
```

::: example
## A log amplifier has R = 10 kΩ and a transistor with $I_S = 10^{-14}$ A. What does it output for a 1 V input, and how much does that change per decade?

::: solution
1. **Output for 1 V.** The input current is 1 V / 10 kΩ = 0.1 mA:
   $$\begin{aligned} v_\text{out} &= -0.02585\ln\frac{10^{-4}}{10^{-14}} \\ &= -0.595\ \text{V} \end{aligned}$$
2. **Change per decade.**
   $$V_T\ln 10 = 59.5\ \text{mV}$$
3. **Check.** 0.1 V in gives −0.536 V, and 10 V gives −0.655 V.

**Answer:** the output is −0.595 V, and it changes by 59.5 mV per decade.
:::
:::

::: example
## A precision full-wave rectifier feeds an averaging filter for an AC voltmeter. What does it read for a 1 V peak sine before scaling, and what scale factor makes it read RMS?

::: solution
1. **Rectified average.** The average of $|\sin|$ is
   $$\frac{2}{\pi} = 0.637\ \text{V}$$
2. **Scale factor.** The RMS is 0.707 V, so the meter multiplies by
   $$\frac{0.707}{0.637} = 1.11$$
3. **Other waveforms.** For any other waveform this "average-responding" meter is wrong; a true-RMS meter computes the RMS instead.

**Answer:** it reads 0.637 V before scaling, and a scale factor of 1.11 makes it read RMS.
:::
:::

::: example
## A precision half-wave rectifier uses an op amp with a gain of 10⁵ and a slew rate of 0.5 V/µs. How small a signal can it rectify, and how long is its output stuck at each zero crossing?

::: solution
1. **Dead zone.** The loop divides the diode's 0.6 V by the open-loop gain:
   $$\frac{0.6\ \text{V}}{10^5} = 6\ \mu\text{V}$$
   against 0.6 V for a bare diode.
2. **Time stuck at each zero crossing.** The op amp's output has to jump between the two diodes' drops, about 1.2 V:
   $$\frac{1.2\ \text{V}}{0.5\ \text{V}/\mu\text{s}} = 2.4\ \mu\text{s}$$
3. **What that costs.** At 10 kHz that's 2.4% of each 100 µs period, enough to show as an error; that's why fast precision rectifiers use fast op amps.

**Answer:** it rectifies signals down to about 6 µV, and its output is stuck for 2.4 µs at each zero crossing.
:::
:::

::: check
given: vin = 0.01 | 1 | 5; R = 1 | 100; IS = 1 | 100
answer: -0.02585*ln(vin/(R*1000*IS*1e-15))
unit: V
tolerance: 0.2%

## A log amplifier has R = {R} kΩ and a transistor with $I_S$ = {IS} fA. What does it output for {vin} V in?

::: right
Right. $-V_T\ln\frac{v_\text{in}}{RI_S}$ = {answer}.
:::

::: misses
- [0.02585*ln(vin/(R*1000*IS*1e-15))] It's an inverting amplifier: the output is negative.
- [any] Not yet. The collector current is $v_\text{in}/R$, and the output is $-V_{BE}$.
:::
:::

::: check
given: T = 250 | 300 | 350
answer: 8.617e-5*T*ln(10)*1000
unit: mV
tolerance: 0.5%

## By how much does a log amplifier's output change per decade of input at {T} K?

::: right
Right. $V_T\ln 10$ = {answer}.
:::

::: misses
- [8.617e-5*T*1000] Per decade, multiply $V_T$ by $\ln 10$.
- [any] Not yet. $\frac{kT}{q}\ln 10$.
:::
:::

::: check
given: A = 1e3 | 1e5 | 1e6; VD = 0.3 | 0.7
answer: VD/A*1e6
unit: µV
tolerance: 0.5%

## A superdiode's op amp has open-loop gain {A}, and its diode needs {VD} V. What input does the op amp need to turn the diode on?

::: right
Right. $V_D/A$ = {answer}.
:::

::: misses
- [VD*1e6] The op amp supplies the diode's drop; its input needs only $1/A$ of it.
- [any] Not yet. $V_D/A$.
:::
:::

::: check
given: Vp = 0.5 | 1 | 10
answer: 2*Vp/pi
unit: V
tolerance: 0.5%

## What is the average of a full-wave rectified sine of {Vp} V peak?

::: right
Right. $\frac{2}{\pi}V_p$ = {answer}.
:::

::: misses
- [Vp/sqrt(2)] That's the RMS; the average of $|\sin|$ is $2/\pi$.
- [any] Not yet. $\frac{2}{\pi}V_p$.
:::
:::

::: check
given: vin = 0.3 | 0.6 | 0.7; R = 1 | 10
answer: -R*1000*1e-14*exp(vin/0.02585)
unit: V
tolerance: 0.5%

## An antilog amplifier has R = {R} kΩ in feedback and a transistor ($I_S = 10^{-14}$ A) at its input. What does it output for {vin} V in?

::: right
Right. $-RI_Se^{v_\text{in}/V_T}$ = {answer}.
:::

::: misses
- [any] Not yet. The transistor sets the current, $I_Se^{v_\text{in}/V_T}$, which flows through R.
:::
:::

::: check
given: IB = 0.01 | 1 | 50; C = 1 | 100
answer: IB*1e-9/(C*1e-9)*1000
unit: mV/s
tolerance: 0.5%

## A precision peak detector holds its value on {C} nF, and its buffer draws {IB} nA of bias current. How fast does it droop?

::: right
Right. $I_B/C$ = {answer}.
:::

::: misses
- [any] Not yet. $dV/dt = I/C$.
:::
:::

::: check
kind: parts
given: A = 1000 | 100000; Vd = 0.5 | 0.7; SR = 0.3 | 3 | 20; f = 1 | 20

## A precision rectifier uses an op amp with gain {A} and slew rate {SR} V/µs; its diodes drop {Vd} V.

::: part
answer: Vd/A*1e6
unit: µV
tolerance: 0.5%

### How large is its dead zone?

::: misses
- [Vd*1e6] The loop divides the drop by the open-loop gain.
- [any] $\frac{V_D}{A}$.
:::
:::

::: part
answer: 2*Vd/SR/(1000/f)*100
unit: %
tolerance: 0.5%

### What fraction of each {f} kHz period is spent jumping between the diodes at the zero crossings? (One jump per period, of two drops.)

::: misses
- [any] $\frac{2V_D/\text{SR}}{T}$.
:::
:::
:::

::: check
kind: derivation
vars: R = 1000..1000000, S = 1e-16..1e-12, v = 0.001..10, T = 0.02..0.03

## A log amplifier has input resistor R and a transistor with saturation current S, at thermal voltage T, with input v.

::: step
answer: -T*ln(v/(R*S))

### What's its output?
:::

::: step
answer: T*ln(10)

### How much does the output change per decade of input?
:::

::: step
answer: R*S*exp(v/T)

### What does an antilog amplifier with the same parts output for an input of −v?
:::

::: right
Right. The log and antilog are inverses, and both carry $V_T$'s temperature dependence.
:::
:::

::: explain
## Why does putting a diode inside an op amp's feedback loop remove its 0.7 V drop?

::: model
The op amp compares the output, taken after the diode, with the input, and drives its own output to whatever voltage makes them equal. If the diode needs 0.7 V to conduct, the op amp simply puts its output 0.7 V above the input, and the diode's drop is supplied by the op amp instead of being subtracted from the signal. The error left over is the diode's drop divided by the op amp's open-loop gain, microvolts. The same idea puts any nonlinear element inside the loop: the loop forces the element's current or voltage to whatever the input demands.
:::
:::

::: practice

::: check
given: k = 10 | 100 | 1000
answer: 0.02585*ln(k)*1000
unit: mV
tolerance: 0.5%

## A log amplifier's input rises {k} times. By how much does its output fall?

::: misses
- [any] $V_T\ln k$.
:::
:::

::: check
given: Vavg = 0.637 | 2 | 6.37
answer: Vavg*pi/(2*sqrt(2))
unit: V
tolerance: 0.5%

## An average-responding meter measures {Vavg} V for a sine. What RMS does it display?

::: misses
- [any] Multiply by 1.11.
:::
:::

::: check
given: vin = 0.1 | 5; R = 1 | 10
answer: vin/R
unit: mA
tolerance: 0.5%

## What collector current flows in a log amplifier with {vin} V across its {R} kΩ input resistor?

::: misses
- [any] $v_\text{in}/R$.
:::
:::
:::
