Question about Comparator Circuits - Page 1
Forum section: electronics / beginners

author: LoveLaika
author_rank: Frequent Contributor
timestamp: May 21, 2020, 04:11:45 pm
content: I have some questions about comparator circuits as part of a sensor circuit. The basic concept seems pretty simple:Given an op-amp, its output goes high if ([IN+]-[IN-]) > 0 or it stays low if ([IN+]-[IN-]) < 0.With regards to the comparison of the inputs, IN+ and IN-, in order for a comparator op-amp to work properly, do they have to be referenced to the same low potential for accurate comparison (i.e., do REF+ and REF- have to be the same)?With regards to the power supplies of the comparator op-amp, do they have to be referenced to the same low potential as the inputs (i.e., does S- have to be the same as REF+ and REF-)? I ran some tests, and based on what I see, it appears that the power supplies only provide an upper/lower bound for the comparator output regardless if S-, is the same as REF+ or REF-. I just want to make sure that my understanding is correct. In a way, it kind of reminds me of crossing clock boundaries.

author: David Hess
author_rank: Super Contributor
timestamp: May 21, 2020, 05:57:00 pm
content: With exceptions which do not matter here, just like an operational amplifier, comparators have an input voltage range which is usually less than the supply voltage range. Depending on the internal configuration, the inputs may be referenced to either the positive or negative supply, or both.

author: LoveLaika
author_rank: Frequent Contributor
timestamp: May 21, 2020, 06:49:26 pm
content: Thanks for your reply. I think I understand. So, as long as the comparator inputs are referenced to one of the same supplies as the comparator's power supply, there should be no problems; otherwise you would be most likely hitting the limits of the op-amp input range? In my diagram, and in my sensor circuit that I'm building, REF+ and REF- are not connected to GND, but instead to a negative voltage (say -10 V) in order to make sure that comparator inputs are referenced to the same potential. If the comparator power supply is referenced to +5V (for S+) and GND (for S-), then like you said, I'd probably be reducing the input supply range given the limitations, but this can be fixed by connecting S- to the same potential as REF+ and REF-. Am I correct in my understanding here? If this is the case, then my output will go negative when the input difference is less than 0, and that's not a good thing.

author: Wimberleytech
author_rank: Super Contributor
timestamp: May 21, 2020, 07:53:51 pm
content: Quote from: LoveLaika on May 21, 2020, 06:49:26 pmYes, there most be a common reference somewhere, your inputs cannot dc float.QuoteCommon-mode input range of an opamp depends on the architecture. Look at the datasheet for the amplifier of interest...it will tell you. Regardless, as stated before, your inputs must have a dc relationship to the amplifier's supply (one or the other).

author: David Hess
author_rank: Super Contributor
timestamp: May 21, 2020, 10:58:56 pm
content: Quote from: LoveLaika on May 21, 2020, 06:49:26 pmThat is right; there must be some galvanic DC connection between the inputs and supply to prevent the inputs from wandering out of range.The inputs must also be DC coupled to the supply to provide any input bias current for the same reason.

author: Wimberleytech
author_rank: Super Contributor
timestamp: May 21, 2020, 11:12:05 pm
content: Quote from: David Hess on May 21, 2020, 10:58:56 pmI went to TI site and grabbed a random opamp to make this point. Wouldn't you know it. It was a CMOS folded cascode architecture. No input current required!

author: LoveLaika
author_rank: Frequent Contributor
timestamp: May 22, 2020, 04:09:07 am
content: Thanks for your reply. I'm using the TLC272 with the following specs as my op-amp of choice. It's all based on its negative supply being referenced to GND, and when that happened, my input voltages were definitely not in range of the specs. However, when referenced to the same 'virtual ground' as my inputs, well then it's all jolly well good, except for that output. Can LEDs handle a reverse voltage of -10 volts?

author: LoveLaika
author_rank: Frequent Contributor
timestamp: May 22, 2020, 04:09:46 am
content: Just curious, what Op Amp did you look at?

author: Wimberleytech
author_rank: Super Contributor
timestamp: May 22, 2020, 11:57:27 am
content: Quote from: LoveLaika on May 22, 2020, 04:09:46 amhttp://www.ti.com/lit/ds/symlink/lm321lv.pdf

author: Wimberleytech
author_rank: Super Contributor
timestamp: May 22, 2020, 12:06:17 pm
content: Quote from: LoveLaika on May 22, 2020, 04:09:07 amYes, read this threadhttps://www.eevblog.com/forum/beginners/what-is-the-reverse-breakdown-voltage-of-a-red-or-green-5-mm-led/

author: Wimberleytech
author_rank: Super Contributor
timestamp: May 22, 2020, 12:10:12 pm
content: Quote from: LoveLaika on May 22, 2020, 04:09:07 amThis is a classic CMOS opamp.With a source-follower output, the VOL is going to be more than a volt off the positive supply. So with a 5V supply, you get a nominal max of 3.8 according to the specQuoteWhat is wrong with the output?

author: LoveLaika
author_rank: Frequent Contributor
timestamp: May 22, 2020, 03:11:04 pm
content: Thanks for your reply. VOH is right, based on the output I'm seeing in the simulation. I was worried about the output because I attached an LED at the op-amp output, so driving it down to -10 V, I thought that an LED couldn't handle that reverse bias voltage when the LED is oriented with respect to ground (and a resistor). I saw your reply though that led to the LED reverse bias discussion, so that made me more optimistic about the LED being able to handle it in my overall application.I honestly chose the TLC272 because I saw another video that used it, so I thought I would use it too (at least as a generic baseline if not set in stone). That choice is flexible, though it is nice to have two op-amps on one IC.

author: Wimberleytech
author_rank: Super Contributor
timestamp: May 22, 2020, 05:14:26 pm
content: If you are driving an LED, just put an NPN on the output of the opamp and drive the LED via the collector to VDD. Put a resistor in series with the base of the NPN of course.

author: LoveLaika
author_rank: Frequent Contributor
timestamp: May 22, 2020, 06:17:11 pm
content: Thanks for the idea. That sounds a lot better (and safer) than what I was doing. I think I see the advantages of doing it that way, and it provides more current to the LED than what I had before.

author: David Hess
author_rank: Super Contributor
timestamp: May 22, 2020, 08:41:27 pm
content: Quote from: Wimberleytech on May 21, 2020, 11:12:05 pmThe input leakage current will still eventually drive the inputs out of range if provisions are not made to direct the leakage into the supply.

author: Wimberleytech
author_rank: Super Contributor
timestamp: May 23, 2020, 10:11:14 am
content: Quote from: David Hess on May 22, 2020, 08:41:27 pmOf course. Probably should have clarified dcbiascurrent in my response.

author: LoveLaika
author_rank: Frequent Contributor
timestamp: May 23, 2020, 07:44:51 pm
content: Feels like any general-purpose op-amp will work as long as the input voltage range and the absolute power supplies are within range of the specs. TLC272 won't work for me, so I'm playing around with other generic op-amps. Funny how some of them work and some don't in simulation.

author: Wimberleytech
author_rank: Super Contributor
timestamp: May 23, 2020, 08:10:10 pm
content: Quote from: LoveLaika on May 23, 2020, 07:44:51 pmFiguring out why any particular opamp does not work can be a useful exercise. But, it could lead you down a rat hole if it is the model at fault and not the actual opamp.

author: LoveLaika
author_rank: Frequent Contributor
timestamp: May 24, 2020, 04:07:54 am
content: Well, on one of the op-amp models that I'm trying out, it seemed to work in my easier, less complex schematic to model my voltage regulator, but when applied to the actual voltage regulator simulation, it falls out of the sky dead. I blame my voltage regulator model for having me to work around its faults, which is probably what caused the issue in the first place. TI makes some pretty nice products, but their simulation models really suck even when I try using their own software instead of LTspice.

author: Wimberleytech
author_rank: Super Contributor
timestamp: May 24, 2020, 02:22:55 pm
content: Quote from: LoveLaika on May 24, 2020, 04:07:54 amPost the asc file of the circuit that is giving you a problem. Somebody here will help you.

author: LoveLaika
author_rank: Frequent Contributor
timestamp: May 25, 2020, 03:26:21 am
content: Thanks. I might try that. I just hope it's okay to post in the Beginner Forum. I don't want to accidentally post in the wrong place and get yelled at by moderators.