I got 2 inputs, both form 0-5V how can i see if they diverge form one another by more than 10 percent?. And if so my output must be a 0V. How can i do such thing?

  • 1
    \$\begingroup\$ What have you considered so far...? If you dont want to build much with hardware, you could use an Arduino, analogReads and digitalWrite. \$\endgroup\$
    – Wesley Lee
    Oct 27, 2016 at 11:11
  • 1
    \$\begingroup\$ You'll either need a microcontroller with 2 ADC inputs and appropriate software, or an analog multiplier. In any quantity, the microcontroller will be cheaper. OR ... a change in the problem specification. \$\endgroup\$ Oct 27, 2016 at 11:23
  • 1
    \$\begingroup\$ Use a differential opamp to subtract the signals, then use a comparator to see if the resulting signal gets over 0.5V (if you want to handle the -0.5V case on the output of the differential op amp you'll have to provide an offset) \$\endgroup\$
    – Voltage Spike
    Oct 31, 2016 at 17:27

3 Answers 3


It's not clear what exactly you are taking 10% of to determine the maximum allowed difference between the two signal. I'll assume that you want to know whether signal B is within 10% of signal A.

There are several ways to do this.

The caveman way

Use a diff amp to make the voltage difference between the two signal. Use a voltage divider on signal A to make the max allowed voltage difference. Just comparing the two isn't good enough since the diff amp output is ± and you only have a single-ended maximum allowed threshold.

One way to solve this is to follow the diff amp with a absolute value circuit.
Then you compare abs(B-A) to the threshold with a comparator.

Another way is to make the negative of the maximum difference signal. Then use a window comparator to detect whether (B-A) is within the ±threshold range.

The 1990s way

Use a microcontroller with two A/D inputs. Measure the two signals and do the calculations to get the answer. This is the way to go as long as the signal bandwidth and response time requirements are low enough. 10 µs would be easy to do with a number of mainstream micros available today, for example.

  • \$\begingroup\$ Now you got me curious what the "2010s way" would be... \$\endgroup\$
    – JimmyB
    Oct 27, 2016 at 11:46
  • \$\begingroup\$ @Jimmy: A faster, smaller, and cheaper micro than what you could get in the 1990s, and probably integrating more of the overall system into the micro. The basic method to solve this problem is still the same now. The reason I called it the 1990s method was to emphasize how archaic the all-analog method is, and to make it clear that's really the way to go. \$\endgroup\$ Oct 27, 2016 at 11:50

How about a dual comparator (opamp) based circuit?

You can check with one comparator and a voltage divider if one input voltage is smaller than the other's ten percent. The other comparator will check the other constrain. You can then use an open collector-like circuit for a wired OR gate.

Optionally you can buffer the inputs, if the voltage divider causes too much load for the inputs.

  • \$\begingroup\$ The problem with this is that the comparison thresholds must be adjusted with the mean input voltage. 10% of 5V is 0.5V. 10% of 1V isn't... \$\endgroup\$ Oct 27, 2016 at 11:21
  • \$\begingroup\$ I think you've misread the question - as Brian points out you can't just compare to the 10% of the supply, it has to be 10% of the input which can vary anywhere between 0 to 5V. This requires a calculation of some sort either by a multiplier chip or by a microcontroller \$\endgroup\$ Oct 27, 2016 at 11:28
  • \$\begingroup\$ Use standard op amp circuits on input A to generate voltages of 0.9A and 1.1A, then use them as the control voltages on a window comparator which compares them to input B's voltage, maybe? \$\endgroup\$
    – Ian Bland
    Oct 27, 2016 at 11:56
  • \$\begingroup\$ @JImDearden I read this as using the resistor chain attached to one of the inputs i.e. set a lower threshold at 90% of V1 - in this way it is a proportional measurement/comparison. \$\endgroup\$
    – Andy aka
    Oct 27, 2016 at 12:28

The simplest solution is a 10-cent dual comparator and a few resistors. Look up 'window comparator'.

Feel free to use an ARM Cortex M0 though, you can implement blinking LEDs and all kinds of other cool features for no extra cost.


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.