UBM Tech

# Dual op amp takes absolute difference

Lindo St Angel, Motorola General Systems Sector, Arlington Heights, IL - June 6, 2012

Originally published in the August 6, 1992, issue of EDN

A traditional implementation of an absolute-difference function comprises a difference circuit followed by an absolute-value circuit; the entire circuit requires at least three op amps. The design problem is complicated in single-supply-only systems, which usually require an artificial ground, typically one-half of the supply. The circuit in Figure 1 takes the absolute value of the difference of two voltages using only two single-supply, ground-referenced op amps. The circuit is designed for dc or low-speed operation.

For the case where V1>V2, IC1A is disabled because diode D1 is off. IC1B and its associated resistors form a classic difference circuit where VOUT= (R2/R1)(V1−V2).

For the case where V2>V1, diode D1 conducts, producing the composite amplifier system made up of both IC1A and IC1B, where VOUT=(R2/R1) (V2−V1). Using these two equations, the overall function of the circuit for V1 and V2 greater than zero is as follows: VOUT=(R2/R1)|(V1−V2)|.

The circuit was built and tested with R1=10 kΩ and R2=220 kΩ. For V2>V1, the composite amplifier system has poor phase margin and is unstable. Thus, the circuit compensates the loop with the dominant pole formed by R3 and C1. At a gain of 22 and a desired response time of about 300 μsec (the 10 to 90% rise time when V2 becomes 0.1V greater than V1), values of R3=56 kΩ and C1=850 pF produced the best empirical results. R3 and C1 will vary, depending on the required speed of the response and the closed-loop gain.

Also, when V2>V1, the output of IC1A becomes a function of the factor 2V2−V1. Thus, IC1A may saturate for large values of V2. The factor’s upper limit is as follows, where VSAT is the saturation voltage for IC1A: (2V2−V1)<VSAT(R1+R2)/R2. For the LM2902 operating from 5V, VSAT is approximately 3.5V. This last equation also implicitly sets a common-mode voltage (VCM) limitation. You can see this limitation by setting V1=V2=VCM and allowing the factor (2V2−V1) to reduce to VCM.