# Absolute value of difference circuit

Discussion in 'The Projects Forum' started by kender, Aug 15, 2011.

1. ### kender Thread Starter Senior Member

Jan 17, 2007
263
1
Colleagues,

Im trying to come up with an analog circuit that would let me detect when the difference (error) between 2 signals becomes greater than a preset threshold. Both signals are DC between 0V and +2V. Either one can be more positive. A negative supply rail is available in the system. Some inaccuracy can be tolerated.

There are number of approaches to the problem. For example:
1. Take the difference of the signals with a differential OpAmp circuit (or InAmp), then take absolute value of that with another OpAmp circuit, than compare it to $V_{max,err} = const$ with a threshold comparator. That would require 3x building blocks: 2x OpAmp, 1x comparator.
2. Alternatively, take the difference of the signals with a differential OpAmp circuit (or InAmp). Then do a window comparison $-V_{max,err} < V < + V_{max,err}$. That would also require 3x building blocks: 1x OpAmp, 2x comparator.
Could there be more elegant ways of doing this (or am I asking for too much)?

Any suggestion, insight or reference is really appreciated!

- Nick

2. ### MrChips Moderator

Oct 2, 2009
14,496
4,268
Use a microcontroller with A/D converter builtin.

3. ### praondevou AAC Fanatic!

Jul 9, 2011
2,939
489
That's the approach I would choose. However for a precision rectifier/absolute value circuit you'd need 2 Opamps, then the comparator.

4 Opamps fit into one package. There is nothing inelegant to it.

Last edited: Aug 16, 2011
4. ### kender Thread Starter Senior Member

Jan 17, 2007
263
1
According to the figure on p.87 here (TI OpAmp handbook), it may be possible to make an absolute value circuit with a single OpAmp.

5. ### praondevou AAC Fanatic!

Jul 9, 2011
2,939
489
Oops, looks strange, I wonder how it can measure the absolute value if for example the input voltage is negative and is limited by the lower diode's forward voltage drop....

I don't get it, maybe because it's almost midnight.?

The circuit on page 89 looks more like what I meant.

Last edited: Aug 15, 2011
6. ### SgtWookie Expert

Jul 17, 2007
22,194
1,763
That "Absolute Value" circuit on page 87 absolutely doesn't work. I wonder how they snuck that one past the proofreaders?

May 11, 2009
5,939
1,224
8. ### ErnieM AAC Fanatic!

Apr 24, 2011
7,907
1,789
Actually I think your second approach is far simpler and most likely to work first time out of the box.