Circuit Design – How to Detect If Two Voltages Are the Same and Trigger an Output

circuit-designvoltage measurement

enter image description here

Basically, I'm struggling to design a circuit with the following requirements:

Requirement 1: Output is high (say 5v) when the two input voltages are different. [If it makes it any easier the output voltage only needs to be high when, say, input 2 is lower than input 1. That is the output is 5v when voltage 2 is less than voltage 1.]

Requirement 2: As soon as the 2 voltages are equal, the output shoots down to 0v (grounded/low). [Or as soon as voltage 2 is in a few microvolts or nanovolts below voltage 1, ie they are very close, then the output immediately shoots to 0v.

Requirement 3: Once the 2 input voltages are no longer equal the output goes back to high (5v). [As soon as voltage 2 is out of the microvolts or nanovolts range below voltage 1, ie voltage 2 is below voltage 1 (voltage 2 will never be higher than voltage 1, it can only match it) then the output immediately shoots up to 5v.

I've tried using a basic subtractor using opamps, but you see the 2 input voltages are sinusoidal. This means the difference between the 2 inputs can be very small, and the output as a result, slowly decreases to 0 rather than immediately 'trigger/shoot down' to 0. It would be useful if the output was a steady 5v and as soon as say the 2 inputs are within a very small range of each other (say a few microvolts or nanovolts) then the output immediately drops to 0. Once the two input voltages are no longer in that range, then the output shoots back to 5v.

Thank you!
Any help is appreciated.

Best Answer

You are looking for a specialised "window comparator". As the name suggests this would use comparators rather than op-amps. (The symbols look the same but their internals are different.) Many of these have open-collector outputs which makes logical OR functions quite easy to implement.

enter image description here

Figure 1. A basic window comparator using a fixed voltage reference. Notice that both open-circuit outputs are tied together with a pull-up resistor. Source: Electronics Tutorials.

The problem with this circuit is that the reference voltages are fixed. You want the reference voltages to track the other input.

More later. I have to put on the rice ...

... Rice is on.

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 2. The tracking window comparator concept.

  • With the arrangement of Figure 2 a fixed current is run through R1 to IN2 which causes CMP1 + input to be I1 x R1 volts higher than IN2.
  • Similarly a fixed current is run through R2 causing CMP2's - input to be I2 x R2 volts lower than IN2.
  • In theory I1 and I2 should cancel out causing no current draw from IN2. In practice IN2 will have to supply the difference in currents due to imperfections in the current sources.
  • The result will be a moving window with fixed offsets that track the voltage at IN2. This defines the tolerance for "voltages equal".

Your challenge will be to design the constant current sources. I suspect that you might have to use a negative voltage rail for I2 and a few volts more than 5 V for I1.

Rice nearly done ...