How To Detect If Two Voltages Are The Same And Trigger An Output If They Are
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.



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.







simulate this circuit &ndash; 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 ...