Logic indication that current is flowing though a connector - Page 1
Forum section: electronics / beginners

author: derGoldstein
author_rank: Regular Contributor
timestamp: July 24, 2016, 01:10:19 am
content: I'm trying to figure out how to set a logic pin high (or low) when something is plugged into a DC socket. The socket is the source of the power. I don't have a mechanical way of finding this out (like most barrel sockets), so I have to rely either on current flowing through the connection, or voltage changes. The only way I can think of is using a comparator and a current-sense resistor (along with, I think, 3 other resistors), but is there some simpler way of doing it?If I place a sense resistor in series I know that I'll get a slight voltage drop on across it, as well as a tiny amount of current created by the very subtle bottleneck. I thought I'd be able to use that change to trigger a mosfet or a darlington, but I'm too dim to figure it out. Is there a way to do it without adding a comparator to the circuit?

author: Rerouter
author_rank: Super Contributor
timestamp: July 24, 2016, 01:13:38 am
content: Edit, sorry you just want to detect current flow, what voltage, and what is the maximum allowable current?, where does this voltage supply originate from?

author: derGoldstein
author_rank: Regular Contributor
timestamp: July 24, 2016, 01:28:57 am
content: The voltage would be between 5V and 18V, but if I only have a solution for a fixed voltage that's fine. Amperage can go up to 5A, but I'm trying to flip a logic pin if current goes over ~5mA (so I can only use a very low-value current-sense resistor if I want to keep it small). The power supply is "in" the circuit I'm working on, it's a battery pack.I'm guessing that since the max possible current is 5A and I'm trying to sense a minimum of 5mA that I won't be able to do so accurately (without it becoming expensive), but it doesn't have to be -- if it trips on 20mA that's fine too, as long as it doesn't trip due to something like 0.005mA.

author: Brumby
author_rank: Unknown
timestamp: July 24, 2016, 01:34:52 am
content: I haven't designed anything using them - but does anyone have an opinion on a Hall effect device for this application?

author: derGoldstein
author_rank: Regular Contributor
timestamp: July 24, 2016, 01:47:18 am
content: I've used them, and they're very difficult to get a proper reading from. For one thing if you're trying to detect milliamps they're almost useless, but even if you're in the amps range, you have to be *very* careful how you lay out the PCB. They'll pick up noise from anything. The chips that use this almost always have some nominal resistance, so you could just as well use a very low-value sense resistor and a sensitive op-amp (it'll be cheaper than a medium-quality hall-effect sensor and more accurate).If you must keep the sensing circuit separate then they're useful, for example high-voltage stuff.

author: Rerouter
author_rank: Super Contributor
timestamp: July 24, 2016, 01:55:31 am
content: OK so looking at the conventional approach, for lets say a 0.1V drop at 5A, you would be using 0.02 ohms, at 5mA that would then be 100uV, so technically in the ball park of what an op amp can do, but very likely to be effected by noise at the lowest end,

author: Monkeh
author_rank: Super Contributor
timestamp: July 24, 2016, 02:08:00 am
content: Diode (or 'ideal diode', FET switch) between connector and circuit, voltage divider to sense voltage on the connector side of the diode?

author: derGoldstein
author_rank: Regular Contributor
timestamp: July 24, 2016, 02:23:07 am
content: Quote from: Monkeh on July 24, 2016, 02:08:00 amBut I still need a comparator here... Also I need to add a large FET that can handle 5A in series. Or did I misunderstand?

author: Monkeh
author_rank: Super Contributor
timestamp: July 24, 2016, 02:26:20 am
content: Quote from: derGoldstein on July 24, 2016, 02:23:07 amWhat do you need a comparator for? You either have 0V or your divided supply voltage. For a wide input range, use a transistor to invert the signal. And 5A does not need a particularly large FET, SOT-26 options exist for that sort of current. Bulky diode, though.E: SOT-26 options exist in NFET.. checking for PFET.E2: Yes, many choices in SOT-26, SOT-23, cute little DFNs (2x2mm small enough for you?)..

author: NMNeil
author_rank: Contributor
timestamp: July 24, 2016, 03:17:41 pm
content: Quote from: derGoldstein on July 24, 2016, 01:10:19 amChange the barrel socket?Drill a small hole in the top of the socket and have an IR LED bounce light back from the outside (shiny bit) of the DC plug when it's put in.A magnet on one side of the socket and a hall sensor on the other to detect a drop in Gauss as the DC plug is inserted.Sorry, I'm a real beginner at electronics and have moved from the automotive field, so most of my thinking involves purely mechanical solutions first.

author: Brumby
author_rank: Unknown
timestamp: July 24, 2016, 03:50:10 pm
content: Interesting idea - but what if a plug is inserted and the power isn't on?

author: derGoldstein
author_rank: Regular Contributor
timestamp: July 24, 2016, 05:32:03 pm
content: Quote from: Monkeh on July 24, 2016, 02:26:20 amI really tried to understand how this works before I posted a reply, so I wired up some tests, but I don't understand how I can get an indication voltage that I can use...The image I'm attaching is a MOSFET being used as a "diode" the way it would be used for reverse-polarity protection. I'm using an IRF540 here, but I also tried a couple of other mosfets and they work the same. I understand that they're not modern mosfets, however, and that there are specifically mosfets designed to be used this way.Before I connect a load to this, the source of the mosfet is 0V, and when I connect a load it's around V0.001, so it's behaving like a very low-value resistor.How would I directly use this behavior, without a comparator, to generate a voltage high enough to turn on a small signal mosfet? I assume that I'm misunderstanding what you meant, but I don't know how else I'd configure this...

author: Monkeh
author_rank: Super Contributor
timestamp: July 24, 2016, 05:37:38 pm
content: Now ponder how you would get a voltage by using a diode. You're on the wrong side of the supply.You'll have to get a little creative to use a FET. A simple diode, however, is pretty easy. Whether it's workable or not depends greatly on just what you're powering, and we have no idea what that is.

author: derGoldstein
author_rank: Regular Contributor
timestamp: July 24, 2016, 06:22:07 pm
content: Quote from: Monkeh on July 24, 2016, 05:37:38 pmI'm powering a 50ohm resistive load using a 5V power supply.Here's how I'd place a diode in series (attached). I'd get a voltage drop across the diode, on one side or the other, when the load is attached. What am I missing?

author: Monkeh
author_rank: Super Contributor
timestamp: July 24, 2016, 06:24:21 pm
content: Quote from: derGoldstein on July 24, 2016, 06:22:07 pmBasic diode operation.When the supply is not present at this connector, the anode of your diode will be at 0V (when pulled down by, say, a voltage divider). When the supply is present, it will be at supply voltage (and a voltage divider can be used to get this down to a logic level...). Who cares what the cathode is at?If you want to change the goalposts (backreading, you seem to be doing this every post), then you'll need a current shunt and an amplifier. If you just want to sense whether the supply is at that connector or not, as your original post indicated..

author: pyroesp
author_rank: Regular Contributor
timestamp: July 24, 2016, 06:44:48 pm
content: What's the minimum voltage you need to have a logic 1 on your input ?Quick search on TTL (as example) voltage levels show a minimum 2V for a logic 1 to be read.A simple voltage divider using a resistor + zener (3.3V ?) should do the trick, for voltage sensing.Or even a transistor + zener and pull up on the basis of the BJT:

author: derGoldstein
author_rank: Regular Contributor
timestamp: July 24, 2016, 06:55:06 pm
content: Quote from: Monkeh on July 24, 2016, 06:24:21 pmYou mean when I first said that the maximum would be 5A at 5-18V and then I changed it to a resistive 50ohm load? I just did that so I could understand the operation using a very specific scenario, since you said you didn't know what I'm powering. The original goal(-post) is the same, to determine if something is connected to the supply.I think you meant using a diode on the device being connected, but I need to know this on the supply circuit. That's why I keep mentioning a sense resistor, since that's the first thing I think of to determine if current is flowing.

author: derGoldstein
author_rank: Regular Contributor
timestamp: July 24, 2016, 07:47:26 pm
content: Quote from: pyroesp on July 24, 2016, 06:44:48 pmZener voltage, that could work...If I use a voltage divider after a sense resistor then I can select very specific voltage tripping point. It would mean 1 sense resistor, 2 resistors for the divider, and a zener, which is the same part count as using a comparator but it's smaller and cheaper. The only problem is that zeners are unreliable, which leads me to the most common alternative -- the TL431. It can be used as a comparator with an internal voltage reference.Thanks, I think this could work!(on logic 1 -- indication of 2V would be enough, yeah, though a 2.5V change would be safer.)

author: Monkeh
author_rank: Super Contributor
timestamp: July 24, 2016, 07:57:26 pm
content: Still can't quite figure out what on earth you're doing or what you require. Or why you're overcomplicating things.If you simply want to determine if an external voltage is present at the connector: Place a series diode in the positive rail. Sense the voltage (via divider, transistor, optocoupler..) on the anode.If that's not suitable (heat dissipation, diode drop, ...), then you'll have to tell us more so we know what is and isn't appropriate!

author: derGoldstein
author_rank: Regular Contributor
timestamp: July 24, 2016, 08:41:19 pm
content: Quote from: Monkeh on July 24, 2016, 07:57:26 pmIt may have been a mistake to mention the particular problem, I shouldn't have mentioned a connector at all.I'm trying to set a logic pin high if more than around 5mA is flowing though a conductor. That's it. The additional relevant information is that the maximum current going through this conductor is 5A, and that I'd like to not disrupt the flow of current as much as possible. The only other parameter which is relevant is that the voltage is relatively low (less than 18V).I shouldn't have mentioned the connector or the power supply or the particulars of the load or any of that. I just need to know if more than 5mA is flowing from point A to point B.