# Controling Voltage percentage wise

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?

• What have you considered so far...? If you dont want to build much with hardware, you could use an Arduino, analogReads and digitalWrite. Oct 27, 2016 at 11:11
• 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. Oct 27, 2016 at 11:23
• 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) Oct 31, 2016 at 17:27

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.

• Now you got me curious what the "2010s way" would be... Oct 27, 2016 at 11:46
• @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. 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.

• 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... Oct 27, 2016 at 11:21
• 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 Oct 27, 2016 at 11:28
• 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? Oct 27, 2016 at 11:56
• @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. 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.