Electronic – Digital circuit to compare two voltages

digital-logicvoltage

I have a task in which I have two sensors, each reading a voltage value. I want a circuit to output 1 if the difference between the two readings is smaller than 10% and 0 otherwise.

I can solve it both analogic or digitally.
Since I have more experience dealing with digital circuits than analogic ones, I thought about doing the following:
Convert the readings to binary and build a circuit which basically uses the formula | (V1 – V2) | / ((V1 + V2)/2) ) and compares it with 0.1. I think there is an easier way of solving this and wanted some help to find it.

Any help will be greatly appreciated.

Best Answer

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 1. Dual comparitor circuit using open-collector outputs to form logical AND function.

How it works:

  • R4 and R5 divide V2 by 2 giving 50% of V2 at the junction.
  • R1, 2 and 3 set reference points of 55% and 45% of V1.
  • The LM324 has open-collector outputs so they can be connected together and pulled high by R6. If either comparitor switches low the output will pull low without damage to the other comparitor.
  • CMP1 will switch low if V2/2 > 55% of V1. This is equivalent to V2 being > 110% of V1. OUT = 0.
  • CMP2 will switch low if V2/2 < 45% of V1. This is equivalent to V2 beint < 90% of V1. OUT = 0.
  • If 90% < \$ \frac {V2}{V1} \$ < 110% then OUT = 1.

I chose the resistor values to make the % calculations obvious. You can change them by scaling them up or down but keeping the ratios in each chain (and then select the nearest standard value). e.g. R4 and 5 = 10k. R1 and R3 = 47k.

Related Topic