Comparator circuit that triggers on a fixed differential voltage - Page 1
Forum section: electronics / beginners

author: MisterHeadache
author_rank: Regular Contributor
timestamp: July 23, 2025, 03:15:22 am
content: Been racking my brains on this, but cannot seem to come up with a comparator circuit that works under these conditions (which means it likely is obvious). Let's say I have two voltage signals V1 and V2. I want to trigger an action (e.g. close a relay, turn on an LED or whatever) whenever thedifferencebetween the signals exceeds a preset threshold Vdiff. The catch is Vdiff >>0 and V1 and V2 can vary between 10V and 60V, but V2 is always equal to or less than V1.Examples for Vdiff=6V:V1=12V, V2=10V --> no triggerV1=12V, V2=2V --> triggerV1=32V, V2=22V --> triggerV1=36V, V2=36V --> no triggerAnd so on. A basic comparator doesn't work because it triggers very close to Vdiff=0. Using resistors to set up voltage dividers for each input also doesn't work because both V1 and V2 float. I looked at a window comparator circuit but that doesn't look appropriate either. What am I missing?

author: planet12
author_rank: Regular Contributor
timestamp: July 23, 2025, 03:31:01 am
content: What about a two stage approach with a differential amplifier feeding into a comparator? If you can get a ground-referenced voltage representing the differential, the comparator side becomes simple.

author: digsys
author_rank: Unknown
timestamp: July 23, 2025, 03:41:48 am
content: As above - adding - my favorite comparator IC is the TPS3700 .. has precision Ref built in

author: bdunham7
author_rank: Super Contributor
timestamp: July 23, 2025, 03:42:29 am
content: Quote from: MisterHeadache on July 23, 2025, 03:15:22 amWhat do you mean by "they float"? Do they not share a common ground, are they totally not referenced to ground at all, are they floating from ground at some (possibly very high) voltage? Is there a problem with giving them a high-impedance reference to ground like a differential amplifier input? An example of that would be something like 4 5M resistors, one from each side of the voltage going to ground.

author: MisterHeadache
author_rank: Regular Contributor
timestamp: July 23, 2025, 12:10:47 pm
content: Quote from: bdunham7 on July 23, 2025, 03:42:29 amSorry, bad use of the word 'float'. They are both referenced to ground. By float I meant that they aren't steady, they vary up and down but always with V2 equal or less than V1.Quote from: planet12 on July 23, 2025, 03:31:01 amThat's it! I see it now, use the diff amp to strip off the common mode voltage, then feed the output into the '+' input of the comparator. The '-' input of the comparator is simply a resistor divider with the midpoint voltage set to the trigger point voltage. I'm off to the LTSPice to set up the circuit and play around with it.This solution follows one of my favorite work axioms - keep adding parts to the design until the problem is solved. Makes future management driven VAVE projects easier

author: magic
author_rank: Super Contributor
timestamp: July 23, 2025, 12:49:22 pm
content: Quote from: MisterHeadache on July 23, 2025, 03:15:22 amWith this kind of voltages chances are that you don't need extraordinary precision, so maybe like that:- NPN base to V1, collector to the 60V rail- PNP base to V2, collector to a grounded resistor- another resistor between the two emittersThen measure voltage across the grounded PNP collector resistor, it will be roughly proportional to V1-V2-1.5V.

author: Zero999
author_rank: Super Contributor
timestamp: July 23, 2025, 02:18:46 pm
content: The whole function can be performed with a single comparator and potential dividers.The comparator's output will swing positive when V3>V2, irrespective of V4.In the simulation, V(+in) is swept from 15V to 35V, so it trips at 25V, which is V2+V4.

author: MisterHeadache
author_rank: Regular Contributor
timestamp: July 24, 2025, 01:12:56 am
content: Thanks for the good feedback, glad to see this got some interest and is helping me move this forward!Quote from: Zero999 on July 23, 2025, 02:18:46 pmNot entirely following where my two voltages V1 and V2 would be applied in this simulation. Also, my upper voltage limit is 60V, V1 to V2 differential can be 50V, not seeing any comparators on Digikey that can handle those specs.Here’s what I came up with (see attached). I’m using a ‘fancy’ differential amplifier, a current sense amplifier, the INA281A1. Why? Because it can handle over 100V common mode and +/-12V differential on the inputs, all while working off 5V DC power.Let’s say I want my Vdiff trigger voltage to be 18V. With the resistor divider set such that R1/(R1+R2) ratio equals 1/144, with an 18V differential from V1 to V2, the voltage differential at the input of the INA281 will be 0.125V. The gain of the A1 version of the INA281A1 is 20x, so its output would then be 2.5V, exactly half of the supply voltage.I feed that into the non-inverting input of an op amp, a dual OPA2310. Why that one? I’ve already got one on the rest of my design and have one amp to spare. Set the inverting input to half of 5VDC and use the op amp output to drive the usual 2N3904, BLAMMO – when V1-V2 reaches 18V, my relay gets triggered.Also if V2 happens to go to GND, the differential input at the INA281 is 0.416V, well within the 12V limit. The output will have gone to the 5VDC rail before then but that’s fine.

author: ledtester
author_rank: Super Contributor
timestamp: July 24, 2025, 01:52:59 am
content: Quote from: MisterHeadache on July 24, 2025, 01:12:56 amIn the real circuit ignore the voltage sources V4 and V3 and connect your inputs to +in and -in.It works by comparing V(+in)/2 with (V(-in)+V(ref))/2 and this determines what the voltage on the comparator inputs can be. I think with other resistor values (and maybe an additional one to ground) you can have it compare V(+in)/3 and (V(-in)+V(ref))/3 which would further reduce the comparator input voltages.The output impedance of +in and -in should be well less than 1M.

author: Zero999
author_rank: Super Contributor
timestamp: July 24, 2025, 10:48:12 am
content: Quote from: MisterHeadache on July 24, 2025, 01:12:56 amThe circuit simply compares potential difference between the -in and +in with the voltage at ref.In my previous schematic, V4 is the common mode voltage. It's there to show that it has no effect and U1's output simply changes from low to high when V3 >V(ref), the latter of which is connected to 10V.QuoteThe OPA2310 isn't optimal. You're better off with a comparator IC with an open collector output. Then you don't need another transistor.There's no need for fancy ICs.If you're using 5V as a reference but want it to trigger at 10V, then change the ratios of R1 & R2 and R3 & R4.threshold = V(ref) * R1/R2R3 = R1R4 = R2The good thing about this is the input voltages to the comparator are scalled by the potential dividers:V(ninv) = V(+in)*R2/(R1+R2)In this case If V(+in) = 100V, then V(ninv) = 331/3V, which is within the range of the cheap LM393 when run off a 36V supply.It might make more sense to use a 2.5V reference IC, rather than the 5V supply and R1 = 1M2 & R2 = 300k. The reference will be more stable than the 5V rail and the input voltages to the comparator will be1/4of V(+in) and V(-in).

author: MisterHeadache
author_rank: Regular Contributor
timestamp: July 24, 2025, 12:19:28 pm
content: Ah, OK I get it now. I set it up in LTSpice and played around with it and understand now how it works. Definitely a simpler approach. Thanks!Part of why I went wrong initially was thinking I could just alter the ratio of R3 and R4, to adjust the trigger voltage, but that doesn't work because I need a fixed trigger VOLTAGE and a resistor divider is a fixed RATIO. So as both V1 and V2 increased, so increased my trigger voltage. This way, by using a high impedance resistor divider that is the SAME ratio for both inverting and non-inverting inputs, and a much lower impedance voltage source to set the offset and thus the trigger (along with where my V1 and V2 are coming from also having much lower impedance), the circuit works elegantly.

author: Zero999
author_rank: Super Contributor
timestamp: July 24, 2025, 08:44:48 pm
content: For completeness. Both the reference and the input voltages can be floating, with differential inputs.I've changed the ratio of the dividers to 8 and the reference to 1.25V, which is floating on 2V. The input floats on 100V and the highest voltage the comparator's inputs see is 15.11V.The other simulations used an ideal, behavioural comparator made with voltage controlled switches. This time I've used an LM393 model, which has an open collector output, pulled up to 5V.