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.

  • \$\begingroup\$ The AD633 analog multiplier datasheet has application notes on how to use it for multiplication and division. It might be worth a look. It might persuade you to go digital! \$\endgroup\$ – Transistor May 19 '16 at 23:15
  • 1
    \$\begingroup\$ What do you want to happen if the two voltages approach 0 V? \$\endgroup\$ – The Photon May 19 '16 at 23:18
  • \$\begingroup\$ @ThePhoton If they both approach 0 V, I would want to output 1. \$\endgroup\$ – tsuo euoy May 19 '16 at 23:26


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.

  • \$\begingroup\$ Thank you so much for taking the time to do this and explain it so detailed! \$\endgroup\$ – tsuo euoy May 19 '16 at 23:47
  • \$\begingroup\$ Thanks for accepting my answer but it may discourage other answers to your question. Usual advice is to wait a day or two to see if anyone else responds. It also gives others a chance to point out errors in my answer. You should figure out what happens with this circuit as the voltages approach zero too. I didn't give it much thought. So, if you wish to un-accept my answer (for a while!) then that's fine. \$\endgroup\$ – Transistor May 20 '16 at 2:49
  • \$\begingroup\$ For a real circuit, you should probably add some hysteresis. This will add interesting complexity to exactly defining the trip points in terms of percentage. \$\endgroup\$ – WhatRoughBeast May 20 '16 at 4:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.