Comparators output when both inputs are at same potential - Page 1
Forum section: electronics / beginners

author: HSPalm
author_rank: Regular Contributor
timestamp: March 08, 2017, 09:10:09 am
content: What is a comparators output when both inputs are at the same potential? Could be anything, depending which way that particular comparators offset voltage swings?What I want is a detection circuit that detects whether current is flowing in a conductor or not. So I drop a current sensing resistor in line with the voltage supply and use the voltage drop across it as inputs on the comparator. But with no current flowing, the inputs will be at the same potential (or will the input impedance of the comparator load the resistor?), can I count on the comparators output to switch between load/no-load?I attached a picture of the basic circuit in question. I gladly take suggestions on alternatives, too.

author: AndyC_772
author_rank: Super Contributor
timestamp: March 08, 2017, 09:15:05 am
content: The answer is 'it depends', on the type of comparator, the day of the week, the temperature, ambient electrical noise, and any other factor which can possibly influence an electronic device. If you simply connect a comparator across a sense resistor, the output at zero current will be unpredictable.Normally a comparator circuit will employ a small amount of hysteresis to avoid this. Have a read on this general topic, and I think you'll find the answers you're looking for.

author: HSPalm
author_rank: Regular Contributor
timestamp: March 08, 2017, 09:30:02 am
content: Quote from: AndyC_772 on March 08, 2017, 09:15:05 amThanks Andy, looking into it now.Am I wrong thinking that I'm over-complicating things? If there was a mosfet with ultra low Vgs-on that would be ideal, but of course it doesn't exist. I just need a logic high when current passes through a conductor, I feel I'm overlooking something.

author: kg4arn
author_rank: Unknown
timestamp: March 08, 2017, 10:36:37 am
content: Maybe try a different architecture. Amplify the shunt voltage drop with a difference amplifier. Follow this with a comparator referenced to a stable voltage and implemented with proper hysteresis. Just a thought. I don't know how the pros do it.

author: daqq
author_rank: Super Contributor
timestamp: March 08, 2017, 12:04:38 pm
content: When both values are equal (assuming there is no hysteresis built in the comparator) you will get an unknown state that will depend on the comparator. With one that has a hysteresis you will get the previous state.QuoteWell, there are other methods you can use for current sensing that do not have a voltage drop, such as hall effect current sensors. Or there are various current sensing ICs that are great for this purpose. They are generally some kind of shunt resistor amplifier. See:http://cds.linear.com/docs/en/application-note/an105fa.pdffor a few hints.That said, assuming you have a microcontroller available, there are plenty of them that have a built in good ADC with an amplifier that could be used for something like this (though you'd have to respect the maximal voltage).Please also note that the LM393 has an open collector type output.

author: danadak
author_rank: Super Contributor
timestamp: March 08, 2017, 12:13:53 pm
content: One method could be detection of the physical connectionof the load, like its presence, or a wire connected. Via useof a photo detector or photo reflector solution.Other methods could be TDR test of connection. Or simple ACdetection of additional capacitance.Regards, Dana.

author: Benta
author_rank: Super Contributor
timestamp: March 08, 2017, 12:20:11 pm
content: You'll need to be more specific.You need to define a threshold that sets a no current/current limit. When you've defined that, you can start playing around with input biasing and hysteresis.

author: capt bullshot
author_rank: Super Contributor
timestamp: March 08, 2017, 12:27:42 pm
content: You need to define the minimum detectable current.Then you offset the comparators input by some mV using some resistors. The offset puts the comparator into the "off" state if no current flows, if the current is large enough to provide enough mV in the other direction, the comparator turns "on". You'll have to take the comparators inherent offset and hysteresis voltage into your calculations. Say, if you can provide about >= 15mV voltage drop over the resistor at minimum detectable current, this approach should work.

author: BrianHG
author_rank: Super Contributor
timestamp: March 08, 2017, 12:49:37 pm
content: How much current do you need to detect and how much power do you need to pass?

author: MrAl
author_rank: Super Contributor
timestamp: March 08, 2017, 02:29:49 pm
content: Hi,The output state of a comparator when it's two inputs are exactly the same voltage is zero (a low) in theory and that is because of the internal gain that will not have anything to amplify, however in practice the output state is simply undefined. What this 'undefined' means is that you have to change the circuit a little to make sure that condition is avoided completely. This is not hard to do and has been done for years now, and that is to add some positive feedback which adds hysteresis to the comparator. There's no reason why this wont work unless you have a lot of noise.The way to add hysteresis is to add a large value resistor from the output of the comparator to the non inverting input, but making sure that the non inverting input has some resistance in series with it so that the hysteresis resistor can change the non inverting input voltage when the output changes state. For a really quick example, say a 1k series and 100k feedback resistor which would add about 1 percent hysteresis. This should not affect the circuit too badly and will also keep it from constantly flipping states when there is some noise present.In any circuit that detects current you probably dont want to detect 1 picoamp anyway, you probably want to detect something like 1ma or more.Another important consideration is the initial current setting, size of sense resistor, and offset drift.Whenever you set it to a certain value you are depending on the offset voltage to stay constant. This might not happen with the wrong choice of op amp or comparator part number. Your sense resistor has to drop enough voltage to allow the comparator to detect it properly over the expected temperature change. For some current levels this means that the circuit goes from hobby level to precision level, where the circuit has to be carefully designed, taking all aspects of the comparator into consideration as well as specifics about the environment.Just to note, there are some very low input offset and low drift op amps out there, which might be a better choice than using a run of the mill comparator.Last but not least, the speed of response may be important so you have to look into that also. This is basically about how fast you need to detect that current once it does appear.

author: HSPalm
author_rank: Regular Contributor
timestamp: March 08, 2017, 03:19:28 pm
content: Thanks guys, lots of great help I've gotten here.The current will vary some because the load is not something fixed, but >100mA for sure will do the trick. The sense resistor is not yet decided upon, but I want to keep it low enough value so I can chose 0603 size and not worry about power rating. But the sense resistor must also be large enough so the voltage drop is considerably larger than the comparator offset voltage. I played around with LT1011 in LTSpice but I cannot get it to switch its output. I have traced both inputs with respect to ground and they cross each other with +/- 7mV on each side which should be more than sufficient with a max Voffset on LT1011 of 0.5mV?

author: Fgrir
author_rank: Regular Contributor
timestamp: March 08, 2017, 03:30:08 pm
content: The comparator won't work properly with both inputs (7V) above it's supply voltage (5V). You need at least 0.8V headroom over the entire operating temperature range.EDIT: That 0.8V headroom requirement is for the LT1017 shown in your circuit. For the LT1011 you mention in your post you'd need 1.5V.

author: HSPalm
author_rank: Regular Contributor
timestamp: March 08, 2017, 05:09:55 pm
content: Quote from: Fgrir on March 08, 2017, 03:30:08 pmOops, I chose another comparator in the component list and forgot to switch datasheet.Thank you, that did the trick. Now I have a setup to experiment with.

author: Benta
author_rank: Super Contributor
timestamp: March 08, 2017, 06:20:52 pm
content: QuoteGood luck with finding 0603 0.033 ohm parts.

author: Fgrir
author_rank: Regular Contributor
timestamp: March 08, 2017, 06:32:34 pm
content: Quote from: Benta on March 08, 2017, 06:20:52 pmA quick search on Digi-Key shows 8 different choices in stock, not sure what you think the problem will be...

author: HSPalm
author_rank: Regular Contributor
timestamp: March 09, 2017, 08:40:25 am
content: I always go for E12 series passives, even though I know in most cases E24 and other oddities won't add much extra cost. I don't see the problem here either.Quote from: Fgrir on March 08, 2017, 06:32:34 pm9 if you don't filter by cut-tape packaging

author: BrianHG
author_rank: Super Contributor
timestamp: March 09, 2017, 09:18:58 am
content: I was going to recommend changing your resistor and comparator for a diode and PNP transistor with 2 resistor, but since you say you only have room for a single 0603 resistor and my solution would mean you loose 0.7v on your 7v source, I think this isn't for you.

author: HSPalm
author_rank: Regular Contributor
timestamp: March 09, 2017, 10:28:28 am
content: Quote from: BrianHG on March 09, 2017, 09:18:58 amCould you elaborate a bit more? I'm trying to keep component count and component size down, in general. With current sense resistor, correct biasing and hysterises I'm up to 4 resistors.

author: BrianHG
author_rank: Super Contributor
timestamp: March 09, 2017, 11:41:00 am
content: My idea was: (Using symbols from your first schematic)Tie the Emitter of a PNP transistor to VCC in your circuit.Tie the Base of the transistor to 7V in your circuit.Tie a 1k ohm resistor between the Base and Emitter.Tie a 10k resistor from the Collector to GND.The Collector of the transistor is now your EN signal.When you have an electrical load on the 7V, it will pull the Base down, by maximum 0.8v (Base to Emitter acts like a diode here), switching on the transistor pulling up the EN to VCC.Notes about this circuit:1. Choosing a sot-23 transistor like DSS5320T-7 will allow you to drive no more than 300ma safely on the 7V. You can add a silicon diode & series resistor + additional resistor to the base with a cheaper 2N3906 to raise this maximum current, but it is 3 more parts.2. For the 1k, this circuit will sense loads beginning at 1ma, if you want to lower this sensitivity, change the 1k to a 100 ohm.3. For the EN output, since your VCC might be more than 5v, add a resistor divider there to create a logic safe output level.When not driving any load on 7V, this circuit consumes 0 power. This is good for battery powered apps where you want to interrupt and wake up a CPU.

author: HSPalm
author_rank: Regular Contributor
timestamp: March 09, 2017, 11:48:18 am
content: Quote from: BrianHG on March 09, 2017, 11:41:00 amThanks Brian. I was ready to sketch up this suggestion when I felt the need to ensure we're on the same page.7V on my first schematic is the supplied voltage. VCC is where I will hook up a load after the sense resistor, there is no other supply at VCC.

author: BrianHG
author_rank: Super Contributor
timestamp: March 09, 2017, 11:53:02 am
content: Then you need to swap the VCC and 7V in my instructions. If you like, draw up a schematic to verify first. Though, getting it backwards wouldn't do much...

author: Zero999
author_rank: Super Contributor
timestamp: March 09, 2017, 01:25:27 pm
content: What's the supply voltage to the LM393?Note that the LM393 needs both of its inputs to be 2V below its power supply voltage to work properly.

author: HSPalm
author_rank: Regular Contributor
timestamp: March 09, 2017, 01:58:58 pm
content: Quote from: BrianHG on March 09, 2017, 11:53:02 amSorry Brian, I don't seem to be able to put together anything reasonable from your description. Would you mind rather telling me how the circuit is intended to work? For the most part I'm wondering where you get the 0.8V voltage drop, without limiting the output current.Quote from: Hero999 on March 09, 2017, 01:25:27 pmThanks, it was already suggested and it did the trick raising its supply voltage.

author: BrianHG
author_rank: Super Contributor
timestamp: March 09, 2017, 02:32:25 pm
content: Ok,If you were to tie 7 volts to the Emitter of a PNP transistor,Connect a load, say a lamp, to the Base of that transistor, and the other side of the lamp to the GND,The voltage the lamp connected to the Base will be getting 6.3v, that is the internal switch on voltage of the Base, IE, the 1 diode voltage drop. The lamp will receive 6.3v instead of 7v, but, it will always stay on.Now, when I say that you shouldn't go above 300ma, IE, a strong lamp, you will burn out the transistor, both in heat and Base-Emitter junction.If you don't connect anything to the Base, the Collector (current sense output) is freely pulled down to GND by the 10k resistor in my design, but, if you connect the lamp to the Base, this pulling down on the base turns on the transistor and pulls the output Collector to the 7v connected to the Emitter. This is your load sense output. With a connected load/lamp, the base is turned on and the Emitter goes high. (If you run this at 7v, then the high output will be 7v. If you are feeding a logic level MCU, a series resistor may be used is the MCU input has diode clamps, or, 2 resistors on the output using the center tap will divide the output voltage to a safe level in place of the 10k.)You should be able to try this out with a 2N3906, however, with that transistor, make sure your load, IE lamp doesn't go above 50ma, or the transistor will blow.Once you are comfortable with this, we can take a look at adding either a power diode or just a beefier transistor if you need to support loads of 1 or more amps.There is no comparator in this design. The transistor is your comparator...

author: BrianHG
author_rank: Super Contributor
timestamp: March 09, 2017, 03:02:51 pm
content: As for the comparator design, if you can place the Rsense resistor to the GND instead of the 7v, then all you need is a 5v comparator with 0v support inputs. As for the + input on the comparator, just place a resistor to GND and another to the 5v and you should get a switch working once enough Rsense goes high enough. This circuit also allow you to use any voltage for 7v like my transistor design since the comparator only needs 5v, or 3.3v if you have a 3.3v, or even less mcu supply.

author: Cerebus
author_rank: Super Contributor
timestamp: March 09, 2017, 03:10:15 pm
content: Quote from: Benta on March 08, 2017, 06:20:52 pmWho needs an 0603 part; or any part? As SMD parts have been mentioned we know there must be a PCB, so ... just fabricate a trace with the desired resistance. e.g. 1cm long, 6mil trace in 1oz copper => 0.034 ohms. Sure, it's going to be quite wide tolerance but from the sounds of it this isn't a precision job.

author: MrAl
author_rank: Super Contributor
timestamp: March 09, 2017, 05:25:47 pm
content: Hi,Just a quick note about the sense resistor size and it's effect on the precision of the circuit.I suppose you want to sense when the current is 100ma.Starting with a 1 ohm sense resistor, 100ma produces 0.1v across it, so with a 5mv offset the precision is around 5 percent so you will sense current that is between about 95ma and 105ma. This could change if the offset drift is appreciable but looks reasonable so far.Going down to a 0.1 ohm sense resistor, 100ma produces 10mv across it. With a 5mv input offset the tolerance now is around 50 percent. This means you could be sensing a current that is 50ma to 150ma roughly. You wont know without a measurement and it could change with offset drift. This may or may not be acceptable for your application.Going down to a 0.010 ohm sense resistor, 100ma produces 1mv across it. With a 5mv input offset the tolerance is now up to about 500 percent, which means we will be detecting a current somewhere between 0ma and 500ma. This is clearly unacceptable.Going back up to a 0.050 ohm sense resistor, 100ma produces 5mv across it. With the same 5mv input offset the tolerance is now about 100 percent. That means we are now sensing current anywhere between 0ma and 200ma. While 200ma may still be acceptable, 0ma will not be. A measurement would show the actual value, but any drift will quickly mess things up.It should be clear now that if we go down to 0.033 ohms it probably wont work very well. In fact, the min resistor value is probably around 0.1 ohm unless you can get away with a wider range somehow.By now you can probably see that sensing current is a little harder than sensing voltage. There are ways to do it that dont involve just a simple sense resistor and comparator, but also involve some sort of amplification. The amplifier amplifies the sense voltage and then a comparator works on a much higher voltage level. There are also chips made just for this purpose.If you intend to use a different circuit, it would be good to post that circuit here so we can take a look.

author: HSPalm
author_rank: Regular Contributor
timestamp: March 12, 2017, 04:33:20 pm
content: Quote from: BrianHG on March 09, 2017, 02:32:25 pmQuote from: BrianHG on March 09, 2017, 03:02:51 pmHi Brian, I just had the time to simulate your transistor design and I'm pleased with it. I will try to hack it in to my design when the PCBs arrive. The product is a battery pack with boost circuit, and I need the load sense signal to make sure that:1* The low voltage beeper won't beep unless the battery is in use.2* The LED voltage indicator should light when battery is in use, not otherwise unless button is pushed.So as you can see no logic level/mcu involved. Thank you fo ryour time.Quote from: MrAl on March 09, 2017, 05:25:47 pmHi MrAl,Yes, these are the considerations I've had to make. Fortunately, comparators with far less than 1mV offset is cheap and readily available. Also, the load is actually around 200-400mA, usually, but depending how complicated the design would be I wanted to cater for lower loads too. I know it's hard helping with when I don't have specifics but the project is really in a research stage where I consider several implementations. Thank you for taking your time, I appreciate it.