Diodes before ground, what to expect? - Page 1
Forum section: electronics / beginners

author: jnz
author_rank: Frequent Contributor
timestamp: August 24, 2020, 04:19:55 am
content: I should know the answer but...I have a 3V micro and an LDO. I have 12V coming in on a known pin, but don’t know which of two options my ground will on. One will be ground, the other may be disconnected or 12V itself.Without putting a separate ground wire on this unit (not really an option), or something like a mechanical relay, I feel one of my only options is to put a diode on the two lines and assume one of them will be ground.However... this will be a 1.6V or whatever the difference in my forward voltage is to “real ground”, right?What does that mean exactly? Will my chip see 3V as normal but it’s really 4.6V when measured elsewhere? Will my chip only get 3V-1.6V? If this is a self-contained system what can I expect the problems to be? Are there current issues with this like would i have to use calculations for 4.6V and not 3V when determining power draw? Etc

author: Ian.M
author_rank: Super Contributor
timestamp: August 24, 2020, 07:56:35 am
content: Temperature extremes permitting, if you use a pair of Schottky diodes you could get the ground offset down to around 0.3V, maybe a little more if your circuit draws a high current. From your circuit's point of view it just sees the ground offset as a supply voltage drop, not important if the remaining supply voltage is still sufficient for the regulator. From an external point of view, *ALL* voltages in the circuit have the ground offset added to them, which immensely complicates interfacing any sensors that have one side externally grounded and makes non-isolated logic level digital I/O impractical. Additionally if any cable screen or ground wire is connected at both ends, it will bypass the ground selection diodes and have to carry the circuit's full supply current.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: August 24, 2020, 03:29:36 pm
content: The only real "Ground" is beneath your feet, and in electronics it is just a reference point defined by the user.Just take a simple AA (or any other) battery. If you define one end as "GND" then the other side will be +1.5V. Or if you define the second side as "GND" then the first will be at -1.5V.Opamp circuits which need a split power supply rails can easily be made by putting 2 (for example 9V) batteries in series and defining the middle terminal between the batteries as "GND".In the same way, Multimeters always have 2 wires for measuring voltages, and they only measure a voltage difference between those 2 wires. You cannot measure a voltage difference with just one wire.Now back to your circuit.If you take 2 diodes, and connect the Cathode of each to your 2 GND connector pins, and you tie the Anodes of the diodes together, then you can use these anodes as "GND" for your circuit.Your voltage regulator will then also use this as a reference, and make a voltage that is 3V3 above the (defined by you) "GND level".You also connect your microcontroller between this same "GND reference" and the output of the 3V3 voltage regulator, and it will see a nice 3V3 difference between it's power pins. Your microcontroller does not now, nor care about what the neighbours do.The most important thing to take care of is if your uC has other connections to the outside world. If there are, you will have to carefully analyse the voltage levels of those circuits, compared to the "GND" level you have created, or throw in some optocouplers or similar.

author: jnz
author_rank: Frequent Contributor
timestamp: August 24, 2020, 04:16:00 pm
content: QuoteOk, among the other answer this is exactly what I was expecting, just wanted to confirm.Now the harder part...Given that I now I have a 0.3V - 1.0V difference in my ground to the rest of the world what happens in these scenarios?1.I have a high side driver. A mosfet where the drain and source are working to get 12V to an off board device. I THINK this is OK. I THINK because the 12V is referenced to "real ground" and the mosfet isn't connected to ground at all, my device will see the full 12V. However... This may mean my gate driver needs to factor in the offset. Is this correct?2.I have one digital comm coming in. 20kbps 12V LIN Bus. This will definitely look "wrong" to my chip. I'll definitely have to consider the offset here, but is that the only problem? That one side will look like 12+offset and the other side will look like 12-offset? Yes, an optocoupler would be good here, and I could consider, but they're a little expense. There is also the idea that LIN is supposed to be rugged and should handle this offset with no additional work. Is this correct?

author: ledtester
author_rank: Super Contributor
timestamp: August 24, 2020, 04:41:29 pm
content: I am very curious to know why you don't know which of your two connections is GND / +12 / NC.Is it just a one time thing or can the connections change during the operation of the device?

author: Doctorandus_P
author_rank: Super Contributor
timestamp: August 24, 2020, 05:02:44 pm
content: I have no particular knowledge about LIN signal levels.I do know it's designed as the cheapest that can be built, and still be good enough to be used in "automotive" stuff.It's also supposed to be used as a very localized bus, for example in a car door, where CAN goes to the door, and LIN controls nodes for a door lock, window motor, and button interfaces.Is LIN built with some discrete transistors, or are there chips for them?If there are chips, they have datasheets.I do have some experience with RS485.Contrary to what many people seem to think, RS485 needs 3 wires. The 3rd wire is for a ground reference.RS485 works with differential signalling, where one signal line is (at least) a few hundred mV higher or lower than the other. It is very common to have a common mode range for the signals between -7V and +12V and communication still works, even the signals are several volts outside of the power supply rails of the RS485 driver chips. This is very useful in a shared bus. For example, I use RS485 over Ethernet cables, and also send 24V power over those cables,( upto about 1A) 1A is about the maximum ethernet cables can handle without melting, and at the end of a long cable you may loose a few volts due to copper resistance. Half of the voltage drop is in the 24V power line, but the other half is in the GND lead. This means that RS485 nodes near the end of the cable have their singal lines 2V below their "GND level"!Blindly assuming it will work is not a good idea.You'll have to analyze the circuit you use, read datasheets, etc.PC817 seems to be a common opto isolator. They cost around 40ct at the west side of this ball of dirt (10ct each in full reels), and pennies with free shipping from Ali.Ali is nice for some experiments, but quality... varies...Just for fun I looked up the price at LCSC.com.PC817 can not be sold there in one-offs. They do not do that silly western stuff.Minimum order quantity is 20pcs, but with their price of $0.02879 it still seems reasonable.I'm planning to make my first order with LCSC "soon", but have not done it yet.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: August 24, 2020, 05:06:10 pm
content: Did a picture search for LIN, but mostly found some rumpled skin.https://duckduckgo.com/?q=lin&t=hk&iax=images&ia=imagesI'll be back...I'm back.Had a quick peek at the LIN stuff, so there are driver chips for it, and had a peek at some datasheets:https://www.nxp.com/docs/en/data-sheet/TJA1020.pdfhttps://www.ti.com/lit/ds/symlink/tlin1029-q1.pdfhttp://ww1.microchip.com/downloads/en/DeviceDoc/ATA663211-DataSheet-DS20006191B.pdfIt seems that the IC's are designed to withstand some significant under and over voltages, (Sometimes from -40V to +40V), but during communication the bus is not supposed to dip below -0.3V.It was just a quick peek at some datasheets though, so check it yourself.

author: jnz
author_rank: Frequent Contributor
timestamp: August 24, 2020, 05:36:12 pm
content: Quote from: ledtester on August 24, 2020, 04:41:29 pmTrust me. I hate it. But, it depends on the customer's wiring. I am certain there will be a ground wire somewhere, but I can't predict ahead of time which one. Different builds put them in different spots. I am fully aware of how goofy this is.

author: magic
author_rank: Super Contributor
timestamp: August 24, 2020, 07:56:11 pm
content: Quote from: jnz on August 24, 2020, 04:16:00 pmYeah, it has to account for the offset in the sense that what should be a 12V power rail will be a 11.3V power rail from your circuit's perspective. Hopefully that doesn't bother you too muchJust use a P channel MOS and drive it normally: between the input rail and your virtual ground. -11.3V at the gate will suffice to turn it on.Quote from: jnz on August 24, 2020, 04:16:00 pmIncoming low state will be -0.7V to your circuit and outgoing low state will be +0.7V to others.The latter is probably no problem (see specs/datasheets of whatever you communicate with), but the former is usually very bad news. If not full isolation, input clamping and current limiting may perhaps suffice, particularly if it's required for protection anyway.

author: Ian.M
author_rank: Super Contributor
timestamp: August 24, 2020, 08:04:10 pm
content: 1. Have you considered implementing a MOSFET ideal diode circuit to reduce the ground offset?Two power N-MOSFETs, two small signal P-MOSFETs, and half a dozen resistors make it easy to get well under 100mV of ground offset even at high load currents. Its also reverse polarity protected, same as with the ordinary diodes. LTspice sim attached.2. Ground offsets of around a volt on a LIN bus will be tolerated by most LIN bus transceivers at the cost of reduced noise immunity. See LIN bus specs and individual datasheets for details.@Magic: A P-MOSFET ideal diode works if you need to implement high side power combining or reverse polarity protection. It isn't helpful low-side as providing gate bias below the lowest supply rail is rather awkward.

author: ledtester
author_rank: Super Contributor
timestamp: August 24, 2020, 10:43:37 pm
content: Quote from: jnz on August 24, 2020, 05:36:12 pmIs it just a matter of a one-time configuration at installation time? From the way I am picturing things the device won't even get power unless the right connection for GND is chosen, so maybe just have a switch or jumper for the end-user to set.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: August 24, 2020, 11:52:37 pm
content: Using a pair of N-channel mosFET's could indeed be a workable solution.Start by connecting them in such a way that the intrinsic body diodes of the fet'ss form the diode circuit mentioned earlier.Then use some resistor combination to measure the voltages on the drains of botth fet's with your uC, and make some intelligent descision on which fet to turn on at power up before any communication happens.MosFET's are relatively fragile though, and especially when connected to external wiring extra protection circuitry is highly advised.I also suspect you're overthinking the whole thing.A common Skottky diode such as the SS34 has a (temperature dependent) voltage drop of 200mV to 300mV at 100mA.

author: jnz
author_rank: Frequent Contributor
timestamp: August 25, 2020, 01:01:26 am
content: Quote from: magic on August 24, 2020, 07:56:11 pmOh, shoot. Yea; I get it. I was thinking about the 11-12V side; but yes your all right, the bigger issue would be the low side offset.Do you have any examples of what you would consider good clamping for this and how that would look?To the others, the 12V here is battery. The same 12V the switched device downstream of the mosfet would be powered with. It would be battery 12V and battery ground, it would be switched with my offset device, so I THINK the device will see normal 12V but my gate voltage will be offset. It’s a big 32A load, so heat sink and I would probably do well with an N-CH for lower RdsOn than P-CH.I’ll get to the other replies as I can process them!

author: jnz
author_rank: Frequent Contributor
timestamp: August 25, 2020, 01:21:17 am
content: Quote from: Ian.M on August 24, 2020, 08:04:10 pmDon’t have LTSpice and on phone for next couple days. Possible to screenshot? Thanks for making!

author: Ian.M
author_rank: Super Contributor
timestamp: August 25, 2020, 12:55:29 pm
content: Quote from: jnz on August 25, 2020, 01:21:17 amAttached.N.B it would *NOT* handle one of the 'ground's rising from 0V to 12V (from a low impedance source) while the other is held at 0V, as there is no circuit to detect current reversal in the associated N-MOSFET and turn it off. If the 'ground' starts at 12V there is no problem as the P-MOSFET will never turn the gate drive on.

author: jnz
author_rank: Frequent Contributor
timestamp: August 25, 2020, 04:01:26 pm
content: I should have been clear with some more of that. It wouldn't ever change during run. It would just depend how the customer wired this up to begin with. So if A or B is ground now, it always will be. I just can't have any external components like jumpers or selectors.

author: ledtester
author_rank: Super Contributor
timestamp: August 25, 2020, 05:06:41 pm
content: What about a relay instead of a switch? The relay coil and control circuitry could be powered by the two-diode idea.Here are some low-voltage latching relays:https://www.mouser.com/Electromechanical/Relays/Low-Signal-Relays-PCB/_/N-5g38?P=1z0z1s3Z1z0x3udZ1z0t3eyZ1z0yxl5Z1z0x3sr

author: jnz
author_rank: Frequent Contributor
timestamp: August 25, 2020, 10:09:36 pm
content: Quote from: ledtester on August 25, 2020, 05:06:41 pmToo big, too expensive. This whole thing is smaller than an typical car relay.I think the answer is here somewhere. Between trying to stay as close as possible to 0V using schotkey or Ian's probably too expensive mosfets, I think I can get it close enough to work. Although there is the idea I just say screw it and add a specific ground wire so I need to deal with none of this. It would be ugly and not at all ideal, but it would be 100% reliable and adds no complexity.