# How do design a circuit that tells the difference of 2 Voltages is within range

#### henry kissinger

##### Newbie level 6
An analog circuit has 2 input and 1 output.

If the difference of these 2 voltages is smaller than 0.05V, then the output goes to 1V

If the voltage difference are greater than 0.05V, the output is 0V

How should I build this circuit with analog circuit components?

(the output is originally at 0V)

#### FvM

##### Super Moderator
Staff member
Differential amplifier + window comparator, combining two simple comparators.

#### Easy peasy

yes - lookup window comparator

#### fgavin

##### Newbie level 5
As other have suggested, an opamp can do all those operations. One integrated circuit that has that function can be the old timer 555.

#### crutschow

One integrated circuit that has that function can be the old timer 555.
Don't see how(?).
--- Updated ---

Henry, what's the input maximum voltage and polarity?

Last edited:

#### barry

Or just use low-offset-voltage comparators, no need for the amp.
As other have suggested, an opamp can do all those operations. One integrated circuit that has that function can be the old timer 555.
Don’t know how you’re going to do this with one opamp or a timer.

#### Easy peasy

@ Barry, 555 is effectively a window comparator - which window can be varied - within limits .....

### Akanimo

Points: 2

#### fgavin

##### Newbie level 5
@ Barry, 555 is effectively a window comparator - which window can be varied - within limits .....
I had the impression that I had access to the resistors on the 555 that set the voltage limits, but I guess not, only the control voltage pin is available.

I was told in school that the opamp can perform any mathematical function, be it a comparator, integrator, differentiator, sum, difference(-sum), amplifier.
So far we might only need the comparator and amplifier

henry, can you clarify if for input A and input B you want this condition, if abs(A-B) < 0.05V then output = 1V? and 0 otherwise?

#### KlausST

##### Super Moderator
Staff member
Hi,

More detailed, more pedantic:

"The difference between two inputs" just means "A-B".
So mathematically the task is: if (A - B) < 0.05V
So if A = 3 and B = 4 ... the result is FALSE.
If you don't want this then you probably mean: if the absolute value of the difference is < 0.05 V
This mathematically means: if |A - B | < 0.05 V
Or in hardware: difference --> rectifier --> comparator
But this is equal to: if --0.05 < (A-B) < 0.05
Or... if (A - B) < 0.05 AND (A-B) > -0.05
This could be done with the above mentioned window comparator, by using thresholds of -0.05V and +0.05V

Things you additionally need to consider/ define:
* what supply voltage do you have? (Do you have limits/ targets for the supply current?
* how accurate do you want the threshold?
* hysteresis to avoid jittery output (chattering)
* timing...how long do you allow the output to get the expectated state? Nanoseconds, milliseconds?
* define the output levels more clear. 0V as well as 1V are absolute values that allow no tolerance. This never can be realized. --> Please define the valid range for each output level.

Lets say: (example)
* LOW: -0.1V .... +0.25V
* HIGH: 0.75V ... 1.25V

Klaus

#### crutschow

555 is effectively a window comparator
Not really.
A window comparator generates an output when the input voltage is within the window voltage (no latch).
The 555 can be configured as a level sensitive latch, whose output goes high with the input is below 1/3 the supply voltage and low when the input goes above 2/3 the supply voltage.
Not the same thing.

#### Easy peasy

the 555 operates when the input goes outside the window, hence window comparator is a short description, also the limits can be modified away from 1/3 and 2/3 for an experienced designer.

#### crutschow

the 555 operates when the input goes outside the window,
Yes, but it does nothing when the input moves back inside the window, which a normal widow comparator does.
There is a difference between a level sensitive latch and a window comparator.

#### FvM

##### Super Moderator
Staff member
I feel that the discussion is a kind of theoretical. You won't actually use LM555 as windows comparator for this
application, e.g. due to lack of voltage accuracy. I'd suggest LM393 for a first try.