Need help understanding ground loops in digital design. Am I over thinking? - Page 1
Forum section: electronics / beginners

author: byte
author_rank: Contributor
timestamp: October 29, 2021, 09:31:07 pm
content: Edit:Just to be clear, I want to learn the correct theory and approach, even if one can get away with causing a ground loop in my particular application as described below.Hello all!First, I'm not "new" to electronics - but I don't have formal education in it either. Just on/off hobby for years with FPGAs eval boards, TTL logic, 555 timers, Arduino, I2C devices, etc.Somehow, I never realized ground loops were a thing in digital electronics. I thought they were just about audio stuff. I now understand the basic consideration of ground loops better, but I can't find a source that clearly states when a ground loop is something to be worried about for multiple connections between 2 digital devices, and how to mitigate them except for: 1. don't create a ground loop, and 2. isolate everything.This came about because I am designing a PCB for a PS/2 keyboard mouse emulator using an Arduino module. I have two PS/2 cables running from a computer to my Arduino board. Now, I decided that I it's not a wise idea to tie the +5v from the PS/2 connectors together because they could have different voltage potentials. So I am powering my device off only 1 PS/2 port. But I'm tying all grounds together, which was what I thought I should do because somehow I've gotten the idea (taught) over the years that one should always tie grounds together so none of the power/IO signals are floating.Most of the explanations out there talk about ground loops for devices in different enclosures (like audio equipment). But I've read quite a bit about ground loops in PCB design and come to the realization it's not just about connective different enclosures together. So with thebasic definition I'm operating on: that a ground loop is a condition where current can find more than one path to ground, the above sure seems like I've introduced a ground loop in my design - even though the circuit appears to work fine.But how to mitigate this from a purist point of view? Do I really need to put opto-isolators on each of my PS/2 ports, and detach the GNDs from each other?And this gets me thinking about all other kind of situations. Like connecting power supplies in parallel:I hope I understand correctly that putting twofloatingpower supplies in parallel will not create a ground loop. But if the negative posts on those power supplies are grounded, that's going to create a ground loop right?One other thing that I can't quite figure out, is whether ground loops apply only to AC. Most articles on ground loops out there are about audio, and so talk about ground loops regarding analog. But I also see quite a few articles (especially talking about PCB design) that refer to ground loops for digital design (but it's confusing, because many of those are mixed signal applications).I feel like I am going a bit bit mad. I'm starting to see potential ground loops everywhere. I may be way off track though, so I can use some insight.Thanks in advance!

author: bob91343
author_rank: Super Contributor
timestamp: October 29, 2021, 10:10:50 pm
content: Maybe I can help. Or add to the confusion.Ground loop is perhaps a not very good name for this. Basically what you want is to define the entire path of a signal. We tend to think of signals 'relative to ground' but there is no one ground. So looking at a signal as it exits a point in a circuit, it travels along a path until it reaches its intended load. However, the current flows farther. It goes into the load and out the load return, often called ground. It continues along whatever path to reach the original source, also called ground, until it reaches the starting point.The object here is to avoid mixing that signal with other signals going their own path. Using a common 'ground' is unwise because there is no single place for it. If there is a common impedance with another signal, some of that signal appears in the circuit, as well as some of the signal under consideration appearing in other circuits.Brute force grounds only reduce the problem; they don't eliminate it. The way to eliminate it is to force each signal to remain in one path only and not combine with others, and vice versa.A ground plane should have no intended current flow. It's a shield, not a current path.Whether the curcuit is analog or digital is only important in that usually a digital signal is somewhat noise immune, since a threshold needs to be crossed for interference to occur. With analog, the very least interference may cause a problem.The details of how to accomplish this immunity are somewhat of a black art. Realize that the circuit path usually includes a power supply or two or three, and so there lies a possible common impedance.

author: james_s
author_rank: Super Contributor
timestamp: October 29, 2021, 10:12:16 pm
content: Digital design on a hardware level fundamentally is analog design. Ground loops become a bigger issue at higher currents, higher speeds, and greater impedance between parts of the circuit. For simple low speed stuff you don't usually have to spend much time thinking about it, but you should always aim to follow good grounding practices.

author: byte
author_rank: Contributor
timestamp: October 29, 2021, 11:13:05 pm
content: Thanks for the replies so far. But to be clear, I want to learn the correct theory and approach, even if I could get away with not worrying about a ground loop in my specific application.That being said:Quote from: bob91343 on October 29, 2021, 10:10:50 pmYeah, I'm not so sure this is helping.Quote from: bob91343 on October 29, 2021, 10:10:50 pmThis is the opposite of what I've been reading lately in PCB grounding design. What I've read is the ICs should have a via down to the ground plane as close as possible to the ground pin. Doesn't this mean then that the ground plane is a current path?Quote from: james_s on October 29, 2021, 10:12:16 pmAnd that's the reason for my questions. I want to make sure I understand the theory correctly in my application, even if it is a low-speed, low-current design. But I am unclear if I am understanding the theory correctly as applied to my particular application - since as I said most reading out there on ground loops are focused on audio or mixed signal applications.Quote from: edavid on October 29, 2021, 10:20:29 pmOne would expect so, but it can't be guaranteed out in the wild. This is why I want to design for the worst case. As I said, my circuit works just fine now, but if just stopped there, I'm not going to know how to correctly deal with ground loops when it really does matter.Thanks all!

author: bob91343
author_rank: Super Contributor
timestamp: October 30, 2021, 01:33:18 am
content: I reiterate that there should be no current in a ground plane. If a circuit needs a 'ground' that connection ideally should go, not to a plane, but via a separate path to the intended point.As I said or implied, ground is not a place for everyone to use. The so-called star pattern means that only one point is really ground and every signal and power return must go to it. That does make for a large ball of solder so the alternative is to route each signal independent of any other signal. If a circuit goes to a ground plane at one point, its current is 'leaked' into other circuits connected at other points on the plane. So having currents in the ground plane results in voltage drops therein, destroying its equipotential characteristics.Exacerbating all of this is the radiation between circuits, also destroying isolation. But that isn't the topic.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 30, 2021, 01:43:02 am
content: Well, a few things:0. Avoid the loop entirely.There are sometimes combo ports, with both devices in one shell. Just get an extension cord and you're set!Obviously, this only works if your host happens to have one (or you have a compact combiner cord to do effectively the same thing).1. Keep the loop area small.Presumably, you only intend to pair this with a single host at a time, and the two cables can be bundled together. This keeps the loop area small, so that if the cable should be exposed to an AC magnetic field, the induction is proportionally small. (Bonus points for twisting them together, so the induction tends to cancel out overall.)2. Keep the ground loop offset small, if you can.If you do intend to use this with multiple hosts at a time, then there are fewer assumptions we can make about their common mode voltages (grounds with respect to your box), or the loop area between them. This may be a case where anything from ferrite beads (helps by opening up the loop at HF), to common mode chokes (CMCs) (extending to MF or LF), to differential sensors (you could bake your own logic translator that allows a modest offset (down to DC), say a couple volts), to total isolation (thousands of volts). You'll typically employ a combination of these; the translator probably won't have great CMRR at HF, so CMCs might be used to address that. Isolation is usually good enough not to need much filtering, but it depends on requirements (don't forget emissions -- and this will not be insignificant as you will need a DC-DC converter across that isolation gap, and it will produce some emissions).Note that CMCs saturate under modest DC (or other low frequency e.g. mains) current flow, so if more than a little offset is expected (in that frequency range), they may prove ineffective, and another method becomes attractive.So, if the loop voltage is small, a simpler method can be used.3. Break the loop.This is the level translator or isolator option listed above. Guess I shouldn't jump the shark on my numbered list here, but listing the methods together above, also illustrates they lie on a continuum of solutions -- applicable for different frequency ranges, and amplitudes. Some can be combined, others are, well, I suppose you could put an isolator after a translator, but that'd just be weird, y'know...Quote from: byte on October 29, 2021, 11:13:05 pmThe theory is a bit of a mind-bend on what "ground" means.For argument's sake, we can still define a reference plane; for EMC purposes, this might be the floor of a test chamber, or a metal table, etc. There can still be voltage drops along this plane, it's not a true reference -- there can be no such thing -- but to the extent we can mostly avoid inducing currents into it (and thus causing those voltage drops), this is alright. (We actually solve this in a little bit, by using local voltage measurements -- ports.)Suppose you have a system of two PCs and your box. Obviously, it doesn't need to be PS/2, or PCs or whatever -- it could be any combination of ports or other cables connecting multiple systems together. But I appreciate the concrete example, it's something we can work with (and bend, to some extent -- I'm guessing you don't intend the ports to connect to different machines, but it could happen, and it might be interesting to reason about that situation, eh?).Suppose the two PCs and box, are sitting above the reference plane, say on an insulating table. They have power cords going back to a common power strip let's say, and, I suppose your box is bus powered so you don't care too much about how it's connected. And maybe it's standalone, no cables, just a, if not a headless macro generator and that's it, then maybe with a touchscreen, keypad, whatever, that sort of thing. But nothing with electrical connection; and no, we don't generally worry about the proximity of flesh-bags to things, so we're pretty much done with our setup here.Suppose one PC generates mains emissions. We might also include the case where it's mains or DC, so that, although the ground wire is grounded to the reference plane at the outlet, the chassis ends up at some voltage with respect to it. We have an equivalent circuit with ground, a length of wire, a voltage source, and the machine "ground". At DC, we aren't too interested about the wire being wire (it's little more than resistance), so this is equivalent to having a source at the outlet itself. The more common case is, the earth connection itself has some offset (typically due to magnetic induction from nearby power lines, or leakage current through maybe-faulty devices).Whatever the case, given an offset voltage, we can connect the affected machine to any number of other,isolateddevices, and no current flows, there's no return path, it's fine. When we have another machine in that chain, which is grounded, and doesn't have an identical ground offset voltage, then we have the problem that a current flows between cables, dropping some voltage across them, affecting signal levels.So that's one way to get hum in an audio system, or slowly rolling horizontal bars in NTSC video (mostly an anachronism these days, fortunately, heh; but the audio case is still quite common!).At AC, the power cord wire has significant impedance. This has two consequences: one, it reduces the ground loop current relative to the DC case; and two, it may break symmetry, so that we can't draw an equivalent circuit so easily -- that is, for source at the receptacle vs. machine inlet. A third (which is really the flip-side of the first) possibility: the source can be the wire itself, due to magnetic induction. Which I already mentioned can happen before the outlet, in house wiring or whatever; mains frequency being so low, it's unlikely that much inductive voltage drop occurs over the length of a power cord, but it can add up over longer routes like this.So, whether we consider it a "wire" source, "machine emission" source, or an "outlet" source, is generally irrelevant (they are equivalent) at low frequencies, and may not be equivalent at high frequencies. To the extent that they are equivalent, in a given situation, we can use this property to simplify things.Conversely, say we want to measure that ground voltage ourselves. Note that any meter we connect between machine ground and reference plane, necessarily traces some path through space, and thus through the fields also around the power and port cables, etc.We cannot know this voltage, in an unambiguous, absolute sense.Voltage is a local difference only, and is path-dependent through space.(There is a semi-famous argument about this:as I recall, the arguments are equivalent (as they must), being two different interpretations of the same phenomenon, due to how the reference is defined; or something like that.)So again, at DC it works, but at AC, we have to mind the path.Enter: ports.The best way to define a path, is to use the paths already implicit in our system!We define a port, as a point-like location where voltage and current can be measured. The reference isspecified.If we have a local ground (to the extent that we can usefully call it "ground"), that's fine, but in general, we use a local reference.For radio and EMC purposes, these are basically anywhere along a transmission line or cable or PCB trace; connectors, component pins, etc.We can conceptually divide a cable in half lengthwise, and probe the voltage and current flowing at that point. The inner and outer conductors are our reference nodes. A transmission line is a pair of conductors with consistent cross-section and some length; the length is continuously variable, so we can make this division anywhere along the line, and the measurements will vary continuously. (They need not be equal, along the length -- Kirchoff doesn't apply to all points of a TL at once -- but they will vary in a predictable manner.)Note that a generic cable need not be a very well-behaved transmission line; it might not be shielded, it might have randomly arranged wires or twists; or something like a wiring harness, might have many wires coming and going in a branching topology. A transmission line is a more idealized model, and can be used to describe situations like these -- usually as a matter of approximation, slapping together finitely many elements to get within some degree of accuracy.Anyway, ports.Say we take device ground as our local reference plane. Then, any connections entering the device, can be treated as ports: there is a point-like location where we can measure the voltage and current through that connection. As long as we can make this assumption, we can define a perimeter, and set up defenses along it, while maintaining the assumption of zero voltage drop across our reference plane. And we don't need to know what device ground is, in relation to anything else around it -- only the connections relative to itself.So, what is "point-like"-ness? A distance between measurement points, short enough that the path-dependency of our probes is negligible. A length which is inversely proportional to frequency. The conversion factor of which is (drumroll..) the speed of light; or rather, a fair fraction of it (say 1/20th or something) so that our approximation holds.This situation applies, in a very real way, to transmission lines themselves -- whereas a point is ideally zero-dimensional, a TL is ideally one-dimensional; but at very high frequencies, real ones cease to be, and we must account for the distances between conductors; it becomes 3D, meaning we get extra modes in the fields. (For most coax in the lab, this is well into the 10s of GHz. So it's quite well behaved at practical frequencies, and we can comfortably make these sorts of assumptions.)We can also have 2D transmission lines, such as ground plane pairs in multilayer boards -- these are not usually so interesting for signal propagation purposes, as a signal expands radially from a point (such as vias connecting into those planes), and so the transient impedance drops as time goes on (the wavefront gets wider, but remains the same height). But that's quite useful to us as a well-bypassed power supply in high speed circuitry.QuoteI can't speak for Bob exactly; but this is, I think, just a poorly phrased statement, or an incomplete one -- indeed I used similar language above, in relation to our assumptions about a reference plane, and when it can actually be, well, referential. It's... one of the downsides of language, we conceive of ideas as clusters of relationships, and, sometimes it can be equivalent to discuss just one or a few of those connections, and you'll get the rest; but other times it's a whole bunch of disparate-seeming ideas, or relationships, or goals (depending on the ways we might happen to use that idea), and it's very hard to discuss them concisely.Which, as you can see... I'm taking the opposite approach here, probably givingtoo muchinformation instead; but at least, given time to study and refine the ideas covered here, one can gain a more complete picture of those ideas, and their relationships. Hopefully.Anyway, regarding ground planes specifically -- we want to minimize voltage drops across them, so that, when we have ports in different locations on them (such as components around a PCB, or various cables in a larger system), we don't incur significant voltage drops, that is, interference coupling between local current flows, and signals connecting between regions. Sometimes those currents must flow some distance, and we can't avoid the voltage drop; in that case, we at least want to avoid the region, keeping signals away, or even adding slots to the plane to constrain current flow. (Which must be done very carefully, as we are then, necessarily, allowing extra voltage drop across that slot!)For the ground plane as a shield, this serves both against external interference, and internally between signals, or signals themselves (their own self-induction). This is an equivalent fact; it's not so much that we're concerned with the magnitude of current flow, or corresponding voltage drop; just that the paths taken are well away from our signals, so they don't couple in and interfere.This is an excellent reason to place connectors around the edge of a board: high-frequency currents preferentially flow on the surface of conductors, and around the edges of plates. Currents from a cable into the board, or out to ground connections, or to other connectors, can flow in these exterior paths, while signals are routed inside.The corollary for transmission lines is, there are two separate current paths on the shield (as with coax for example): the inside carries the image current of the signal; the outside carries a separate, exterior, shield current corresponding to exterior fields. Note this is inconsistent with the DC case, where the shield is simply a resistive conductor! How can these be so different? The change occurs as a crossover filter, the cutoff frequency depending on the skin depth of the shield (which varies as 1/sqrt(f), so shielding generally gets better at higher frequencies, though not proportionally so -- sqrt is sub-linear). At low frequencies, resistance dominates; at intermediate frequencies, some mixing of interior and exterior fields occurs, and some induction reaches the signal (independent of the shield); at high frequencies, the fields are well separated and shielding is excellent.The same occurs on PCBs, for the same reasons; at low frequencies, the return current from a trace takes a straight-line path (well, it's a fat, fuzzy path because the current spreads out inbetween, but it's along that direction anyways); at high frequencies, the return current follows close under the trace (hence, "image current").And anything near that path (within the "image"), will pick up some signal from the trace; so to get good isolation between signal traces, at high frequency, it suffices to space them out moderately well, maybe put some extra ground inbetween them or something, and that'll do.Quote from: james_s on October 29, 2021, 10:12:16 pmTo put it another way, digital is a subset of analog; namely that we've applied rules defining what a '1' and '0' are, and what the propagation delays seem to be. This works when the logic levels are met consistently; and ground bounce/loop, signal reflections, EMI, etc. all contribute to possible violations of those assumptions, and thus corruption of digital data.Edit:Quote from: bob91343 on October 30, 2021, 01:33:18 amOk, now I'm not so sure Bob had image currents in mind...(For point of reference -- there is a method by which star grounding can be executed, that satisfies both DC and AC conditions for good signal isolation, good immunity, low emissions, all that. It is most definitely NOT the way you will see it done in most audio designs!)Tim

author: byte
author_rank: Contributor
timestamp: October 30, 2021, 02:20:06 pm
content: Quote from: T3sl4co1l on October 30, 2021, 01:43:02 amYes, I appreciate the time you put into your reply and going into extra depth - even if some of what you said seems (to me) tangential and not directly related to my question. Nevertheless, it's giving me new things to learn and think about!Quote from: T3sl4co1l on October 30, 2021, 01:43:02 amI think this is something key I needed to hear. Most (all?) of the materials I've read about ground loops turn it into an absolute argument: avoid them at all costs and that a design should absolutely never allow a ground loop.But it seems that you are saying there are degrees of acceptability that can be tolerated in a design. Which makes sense to me, as I was already aware that bigger the ground loop, generally bigger the problems. But no reading I have found (yet) describe this as formulaic consideration/relationship. E.g. If your design has X requirements or Y characteristics, ensure ground loops are never >Z in area.And because of the lack of a formulaic approach, I still don't feel I have a solid grasp on exactly what I need to be designing for.So I am still trying to figure out the relationship between the following in ground loop considerations:AC vs DCFrequencyGround loop areaProbably other factors I'm not even awareQuote from: T3sl4co1l on October 30, 2021, 01:43:02 amI am aware of this approach for differential signal pairs, but it did not occur to me for the ground loops. I think your statement makes me realize I have been focusing only one of the problems with ground loops.So, correct me if I am wrong, but the problems introduced with ground loops are:current flowing in unintended paths - which can raise the ground reference potential for other devices and unintentially couple themreduced EMI rejectionAnd increased EM radiationMy understanding is the EM aspects are because the loop is effectively creating an antenna. So the smaller the loop, the higher the frequency response. And higher frequencies have greater attenuation in most cases hence better EM characteristics?Quote from: T3sl4co1l on October 30, 2021, 01:43:02 amYes, fully cognizant of this. Which is why I am trying to test my fundamental assumptions, but no one has yet said whether I am right or wrong in my current understandings yet:Open questions for me:Is my fundamental understanding I've read, that any situation where current has multiple paths to flow to ground, it's a ground loop? Or is only when you have multiple current sources sharing common ground? (see next figure)Is what I describe in my application actually a ground loop if I connect the grounds together between the host port and the device ports at a common point before the digital logic?Is the parallel power supply scenario where neg posts are tied to ground, also a ground loop?If it's true that just having parallel conductors to ground, causes a ground loop, then this is a bit surprising to me in practice (but not surprising based on that definition of a ground loop above). Lots of things use parallel conductors to increase current capacity. So why then aren't ground loop problems happening all over the place in the real world? I'm starting to think, that 1. it is because the conductors are typically run close to each other making the loop small, 2. the application just doesn't matter such as power delivery, which typically have additional regulation and will filter out any EMI from the conductors, 3. It just doesn't matter for relatively slow transients (think I am using the right word there).Anyhow, reading the Wikipedia article on the topic, it certainly seems that all these scenarios I've described are indeed ground loop:https://en.wikipedia.org/wiki/Ground_loop_%28electricity%29QuoteQuoteAnd interestingly enough, counter to Bob's previous point:Quote

author: dtmouton
author_rank: Contributor
timestamp: October 30, 2021, 04:07:06 pm
content: The main problem with ground loops is that time-varying magnetic fields can couple into them and induce voltages as explained on Wikipedia. The idea is to keep the loops small so that their isn't much room for magnetics to couple into them. That's why twisting the wires helps. A lot of high-frequency current can flow in the ground plane of a board. You should also avoid slits in the ground plane in order for high-frequency currents to follow the shortest possible path, inducing the smallest possible voltage difference in the ground plane. It is also a good idea to put all your connectors on one side of the board. The high-frequency components of the ground potential can be different at different sides (edges) can be different and cause further EMI problems if you have connectors on different edges of the board.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 30, 2021, 04:33:53 pm
content: Quote from: byte on October 30, 2021, 02:20:06 pmThat's no accident: electronics is the domain of the continuum. It's... if not real numbers, then at least, large enough rational numbers, plus random noise. Noise sets the equivalent resolution, which depends on bandwidth, since noise can be averaged over time. (So it's more than just S-D converters that have accuracy-bandwidth tradeoff.)Mostly what we have in design, is inequalities -- getting those numbers in the right ranges, satisfying however many optimization problems together.What works for, say, FCC Class A emissions, and 3V conducted and 3V/m radiated immunity, might not work for EN 55022 class B, or various other standards. It's never going to be perfect, it just needs to be good enough to pass. The standards are set to be "more than good enough", generally.So, change the environment, change the requirements -- it's no accident if it fails!For say audio ground loop purposes, we simply need that noise is less than so-and-so, in such-and-such environment. Maybe some fraction of a mV, under presence of say 100 A/m magnetic field at 50/60Hz, using standard methods (typically something like a 1m Helmholtz coil in three orientations).You'd probably not encounter ground loop in the test lab, testing mainly being done one piece at a time, but if you wanted to set up a system, you could. The equivalent circuit is pretty obvious, you're simply making an air-core transformer, in whatever plane the wires lie in. Translating that to a signal source, you can do it at the bench without much or any special equipment.QuoteWell, antennas don't need loops, though that's certainly a thing. For the case of a two-device chain, one plugged into the wall, the other on some length of cable: if the first device emits some noise from either port, the "equal and opposite reaction" puts the opposite phase onto the other port. So for this arrangement, it acts as an electrically short antenna (monopole) at low frequencies, so may radiate a significant amount (read: near or above testing threshold) if the source is strong enough.Because, an electrically-short antenna emits roughly proportional to frequency. For a given applied voltage or current, a 1m wire might be insignificant at 30kHz, but it's a fair fraction of the wavelength at 30MHz.Let alone at frequencies where the cables become resonant, and so not only is there strong coupling to radiated fields, but the impedance changes rapidly as well (peaks and dips due to anti/resonances).Resonance can exacerbate EMI problems, because you can have, for example, a situation where your ground loop isn't quite right on-board. Say you have a DC-DC converter a bit too close between two connectors: the currents flowing in the inner switching loop, couple weakly into the ground-to-ground potential of the two connectors. This is a low impedance, because the grounds are shorted together by ample copper. Normally the low impedance would match poorly to the ~100 ohm radiation resistance of good antennas. But there might be a resonant mode where the impedance is very low, and that small voltage gets multiplied up by the Q of the system.A simple cure in such a case, would be a ferrite bead on one or more cables, near the device (EUT, equipment under test). The ferrite bead increases the impedance, and adds resistance, absorbing energy, damping resonances, keeping the impedance more stable.This is an emission scenario, but the same is true of immunity, when such a system is blasted with external fields: in general, the EMI environment obeys reciprocity, and these are equivalent cases. We just might have different design solutions for dealing with emissions versus immunity.So, in your above list, the last two points are really the same, and that probably felt like the case and now it is made explicit. And you could probably argue that the first is another case of the same: it's all about coupling between environment (common mode) and signal (differential mode), and maintaining the separation between them, or understanding how much coupling there is, how much is tolerable, what to do about it, etc.QuoteWell, going back to ports -- everything is differential. We just use the convenience of an apparently global and ideal "ground", when certain assumptions are met -- namely that the voltage drop across it, really is low enough to ignore. So, for concrete examples: maybe that drop should be fractional mV, as with the audio example above; maybe it's up to a whopping fractional-volt for digital logic signals. Or for the "wide-offset receiver" case, maybe tens of volts is acceptable -- this is the case for signaling standards like RS422/485, boasting a 10V common mode immunity. You can get away with such networks without shared grounds (relying on safety ground (earth) instead), in some cases! But, woe is you, if you happen to get noise a few volts outside of that range, and now all your data gets corrupted...Conversely, we can draw the equivalent circuit of ground itself, when it's non-ideal. For your diagram, shall I assume those return currents, represent current paths from devices? So in the first case, there are two devices, at (in general) two different ground (CM) voltages; and the second case, there is only one, so there is no second device to form a loop with respect to?And yeah, we don't count parallel paths, that's kind of absurd/trivial, like for the case of current flowing between two points on a plane -- okay, this is a diversion here, so you are warned.One way to calculate the resistance between points in a resistive plane, is by integrating over all possible paths. This was one of Richard Feynman's favorite tricks: the principle of least action. A given electron can go anywhere it likes in the plane, but the most likely path is, approximately, a straight line. But note that, for every electron taking that path, there's a tiny voltage drop, which somewhat discourages that route, and some will flow beside it; and depending on the radius of the point contacts (they're not actually points, you'll find that's impossible on doing the analysis, actually), voltage drop builds up around the contacts as well. So you even have the case where electrons flow in completely the wrong direction (backwards), and it's actually a worthwhile route.One must be careful not to take rules of thumb, too literally. The most obvious, mechanistic representation we could formulate, for the saying "current takes the path of least resistance", is that the current flow finds some infinitesimal, narrow, straight-line (or maybe it's actually jagged or circuitous, who knows) path between points, and just all the current flows that way, period.But that's obviously stupid, it violates all the rules of electricity. If a material exhibits this behavior, it must not be ohmic, at least.(And indeed, what does a spark look like? A narrow path through an otherwise-insulating medium. Ionization causes gas to become suddenly, and locally, very conductive. The conductivity depends on electric field strength and past history (i.e., prior ionization or heating), decidedly non-ohmic.)So if we do the calculation, we find it's more like a continuum of probability, for an electron to take any particular path; with straight-line paths being more probable, but off-line paths being also quite common. Or, notice we don't need electrons to express this, they only manifest as a rubber duck to think about; they aren't at all descriptive in this situation, and we're perfectly happy with the classical fields, having some continuous voltage drop and current flow pattern through this plane.Anyway!So for your second case, or for currents in a plane, we only care to the extent that something is sensing that voltage drop.Going back to ports. Say we have a signal source port, with its ground reference tied with the ground symbol. Say this is some ideal signal source from outside the system. Say we have a receiver port, with its ground reference tied with the DC- connection. Now we have a loop, where DC current flows through the ground-return network, and we have some voltage offset between the ports. Finally, we connect the signal side of the two ports together: little signal current flows, and in any case it's independent of the ground current, so it certainly doesn't have a voltage drop that would cancel out the ground voltage. Thus, we have the receiver reading a voltage Vsrc + Vgnd, and ground loop interference has occurred.If we do the same thing at AC, we can represent the equivalent circuit as having inductances. Say we have the ports wired as before, but we also extend a ground wire between ports directly, and say that ground couples strongly with the signal -- that is, the signal and signal-ground wires form an ideal transformer. Now the sig-gnd wire acts as a sensor for the ground-loop voltage, and by transformer action, exactly couples it in series with the signal: now the receiver port reads Vsrc + Vgnd - Vgnd = Vsrc and we have a good signal again!How exactly the signal pair is arranged, isn't so important -- the two most common cases are fully balanced, and fully unbalanced. The former is two symmetrical wires through space, with equal impedances to each wire (so, true-differential should be drawn a bit differently than here, the negative wire wouldn't be hard-grounded), and any interference couples with them equally, contributing to a CM voltage, but not coupling to the signal; and unbalanced has one enclosing the other, as with coax, so that the inner wire cannot see any fields but from the shield.Note that, since these are impedances rather than tiny resistances, we can expect some play between them; no one path acts like an ideal voltage source. Conversely, we can't effectively short out any loop, because we'll have some voltage drop along that path, too. So, while we aren't likely to get bullied along any particular path, we still need good coupling to get good CMRR.So, regarding your points:1. It seems your perspective is off; it's not so much about paths and currents, that's just whatever. It's where those paths affect signals referenced with respect to them, that problems arise. After all, who cares about power, that's just a thing. It's signal quality we care about!2. For your situation, there is likely no significant ground loop for the case of two ports on the same machine. They'll be grounded to the same plane on the motherboard, and the 5V will be from the same source. That leaves the area between cables, which is under your control, to some extent -- and only vulnerable to fields, not connections between other devices.3. For the two-machines case, there may be some ground offset between them, and so you already have to worry about ground loop, no matter how you arrange the cables. The 5V will likely be different as well, and it would be a bad idea to hard-wire them in parallel -- the most extreme case being with one machine turned off, trying to power up through your connection! Probably you'd be fine, powering your circuit from a diode from each source (wired-OR). Maybe keep the port pull-up/receiver referenced to its local supply, then translate to internal levels, not a big deal. (And maybe you use 3.3V inside for the MCU anyway, so don't care about the diode drop.)Tim

author: bob91343
author_rank: Super Contributor
timestamp: October 30, 2021, 05:34:33 pm
content: Tim, your diagram is worth 1000 words. That is what I had been trying to convey in words. The injection of an unwanted signal into a so-called ground is what is commonly referred to as a ground loop (which is a poor description of it).

author: dtmouton
author_rank: Contributor
timestamp: October 31, 2021, 03:04:00 pm
content: You could also try a few other things:(Not necessarily all about ground loops)1. Limit the bandwidth of your incoming signals by placing RC low pass filters on the receiving end. This will filter out unnecessary high-frequency noise. Just make sure that the cutoff-frequency of your filters is much higher than the rate at which data is transmitted.2. Try placing a large ferrite bead around the bundle of wires. The ferrite bead is made from a lossy magnetic material and will attenuate high-frequency common-mode noise.3. If you do a new design then go with a fully differential layout. The one big disadvantage of an unbalanced design is that common-mode noise gets converted differential mode noise.4. At high frequencies you also have to look at impedance matching and proper termination to prevent reflections.

author: radiolistener
author_rank: Super Contributor
timestamp: October 31, 2021, 04:05:28 pm
content: Quote from: byte on October 29, 2021, 09:31:07 pmthere is no ground loop on that picture, because all GND (for device A, device B, Earth) connected in a single pointQuote from: byte on October 30, 2021, 02:20:06 pmYes, both circuits have ground loops, because there are several path for current on ground line.But for DC current ground loops are not an issue. It become to an issue for AC, especially for RF (high frequency). At very high frequency such loop turns into resonant LC circuit or microwave cavity, because there is inductance of wires and there is capacitance between wires and there is a space between them.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 31, 2021, 04:19:43 pm
content: Well are we talking about loops with current flows, or loops with magnetic fields (the dot-circles represent magnetic field through the image plane)?Tim

author: bob91343
author_rank: Super Contributor
timestamp: October 31, 2021, 05:39:16 pm
content: Current flows. Magnetic and electromagnetic problems are an entirely different subject.

author: dtmouton
author_rank: Contributor
timestamp: November 01, 2021, 03:08:23 pm
content: According to Ampere's law every current generates a magnetic field. According to Faraday's law any time-varying magnetic field generates a voltage.

author: byte
author_rank: Contributor
timestamp: November 01, 2021, 03:30:16 pm
content: Quote from: T3sl4co1l on October 30, 2021, 04:33:53 pmBut isn't that what I said?I said for power delivery/distribution it doesn't matter because there is typically going to be lots of filtering. I also said that ground loops are a problem because they can cause devices to reference different ground potentials.Quote from: radiolistener on October 31, 2021, 04:05:28 pmAre you sure about that? There seems to be tons of articles out there that say it is a ground loop. They even have nearly identical diagrams:Wikipedia article:https://en.wikipedia.org/wiki/Ground_loop_(electricity)https://en.wikipedia.org/wiki/Ground_loop_(electricity)#/media/File:Ground_loop_-_leakage_currents.svgOthers:https://www.sunpower-uk.com/glossary/what-is-a-ground-loop/https://hackaday.com/2017/03/09/wtf-are-ground-loops/https://www.circuitbread.com/ee-faq/what-is-a-ground-loophttps://www.cablinginstall.com/connectivity/article/16465354/ground-noise-is-a-misunderstood-problem-of-data-networkshttp://www.radioworks.com/nbgnd.htmlI have hard time believingallthese sources are wrong.Quote from: radiolistener on October 31, 2021, 04:05:28 pmThat doesn't seem correct either to say it doesn't matter in DC. If a ground loop increases EMI susceptibility, then transient voltages are definitely a problem in digital designs, especially high-speed design where switching voltage thresholds can be very small.

author: bob91343
author_rank: Super Contributor
timestamp: November 01, 2021, 05:13:17 pm
content: "Gound loops" are definitely a problem at dc. As an example, thermocouple signals are easily corrupted by extraneous currents.

author: fordem
author_rank: Regular Contributor
timestamp: November 01, 2021, 05:50:30 pm
content: Are we talking just two devices connected to each other?May I suggest you take a look at a SCSI cable (anyone remember those?) - depending on whether you were running 8 or 16 bit SCSI you had cables up to a maximum of 12 meters in length with either 50 or 68 wires, half of which were "grounds" - so that it's clear I'm not talking about devices internal to a computer, SCSI can be used as both an internal and an external bus, so you can (or should I say could have had) multiple different devices, each with it's own power source, connected via the same SCSI bus - time proven technology, once considered the ultimate in highspeed, reliable, digital communications.By the way - your PS/2 host does in fact use not only a common ground on the keyboard & mouse ports, but also a common 5V supply, and for what it's worth that common ground is also common to every other port on the host.

author: byte
author_rank: Contributor
timestamp: November 01, 2021, 08:40:02 pm
content: Quote from: fordem on November 01, 2021, 05:50:30 pmYeah, I remember parallel SCSI. Rather, I remember hearing of it. No way I could afford SCSI hardware when it was still in use.I did some quick googling, and came across a few scsi pinouts, but the one that jumped out was the VHDCI (Very High Density Connector Interface) apparently used in SCSI-4.https://www.ni.com/en-us/support/documentation/supplemental/06/interfacing-to-the-digital-pattern-instrument-or-digital-wavefor.htmlHoly hell! Why did they need so many grounds? I assume the signal/grounds are twisted pairs*, or that each signal has it's own ground shield? But why not just handle that in the connector itself to a single ground pin (or the connector housing) and cut the number of pins needed in half?* I can't find clear documentation on the cable construction, but I did find reference to them being twisted pairs:https://www.cablewholesale.com/products/ide-scsi/vhdci68-scsi-cables/product-10n3-14106.phpWhat's even stranger, is their design recommendation says to tie all the ground pins into the same ground plane. Which means these can't be acting as differential pairs:Quote from: fordem on November 01, 2021, 05:50:30 pmBut "highspeed" is relative:https://storage.microsemi.com/nr/rdonlyres/4c6419b2-b4e6-42a7-96c9-d37d2bd21d71/0/abc_scsi.pdfApparently the 68-pin Ultra SCSI 320 was limited to 320MB/s. For 32 data channels in the cable, that's 10 MB/s or 80Mb/s, which assuming that's the line rate it would need a clock of 80Mhz, yes? Per the above, this seems to be before differential signaling used in high-speed serial today. But as discussed earlier in this thread, the multiple ground paths probably don't cause a problem as a ground loop even at 80Mhz (ignoring the frequency components in the rise/fall times), because the ground loop area is so small with all the grounds are right next to each other in the cable.What is not clear is how they were handing the larger ground loops between multiple devices. But I assume that came down to all the mitigations we've discussed so far.Quote from: fordem on November 01, 2021, 05:50:30 pmSomeone else said this too, but are such assumptions a good design practice? It's like saying that you don't expect someone to swap DC polarity, but sure enough people do it all the time. That's why you build reverse current protection into your design to be resilient. I don't see why assuming PS/2 ports have a common ground and common 5v is an iron-clad assumption.Thanks

author: T3sl4co1l
author_rank: Super Contributor
timestamp: November 02, 2021, 12:44:11 am
content: Quote from: byte on November 01, 2021, 08:40:02 pmSame reason parallel port or GPIB has half grounds (well, a bit less), or for another contemporary example, the ribbon cables used for the old ST-506 HDD interface. Or a slightly more recent example, floppy (but not so much IDE(!)).ST-506 is maybe a good example, because it combines two methods that are very accessible and still relevant today:The control signals were plain old TTL level, chained to one or two drives. The last drive in the group had a terminator resistor installed. This was a divider array, something like 390 pullup, 150 pulldown, for an equivalent around 100 ohms (the impedance of ribbon cable with every other wire grounded), and the off-center Thevenin voltage is well suited to TTL (which pulls down stronger than it pulls up, so the signal level was only about 2Vpp this way).The data signals however, were RS-422, on a dedicated (point-to-point) cable. Again with a fair number of grounds, but with differential pairs for data RX and TX (to the head amplifier -- there was very little decoding on the drive itself, just level detection, I believe?). This has a balanced driver source (basically a somewhat beefier TTL output per pin) and a termination at the load (hard wired, since a point-to-point link).Note that ribbon cable isn't coaxial. A wavefront propagating down one wire, forms an impedance divider with its neighbors, and to free space. The signal wire goes up, and the neighboring ground wires go up somewhat in return -- the average is upward, so there is CM coupling. So the CMRR and emissions aren't great. By driving complementary pairs, the nearby grounds aren't particularly well-balanced themselves (this can be alleviated with twisted-pair ribbon), but overall it's not too bad. The important parts are:1. Digital signals have reasonably wide thresholds, so the ~20% loss/interference expected during the propagation time, isn't enough to exceed thresholds, and2. it's inside a shielded metal box, so the emissions aren't a big deal.Unless it's not, of course, which happens from time to time. There have been (are?) plastic-case PCs. Or of course, various chassis mods, but that's another matter as far as EMC goes...IDE is a crappy thing, it lacks enough grounds -- they must've struggled with that as it was pushed way past its original purpose, which was already rather marginal (an extension of the 8MHz or so ISA bus). UDMA (66, 100MB/s) prefers 80-wire cables where all the grounds are bused together, inside the connectors -- the signals can be twisted pair to maintain modest signal quality, while everything necks down and kind of sucks at the connectors. It was enough to get the job done, evidently, but not ideal.SATA of course is enclosed in shield, and pushes the bitrate far higher (gigs), only needing a couple serial lanes to do a modern job. Much easier for the rest of us, just tosses all the complexity into the interfaces.But yeah, imagine what the cable looks like to external fields. One signal twisted with one ground, will leak some (couple CM/DM) depending on length, so over short distances and relatively slow risetimes, it can be reasonable. And the margin of horribleness is fairly modest for digital signal quality purposes (but more stringent for EMC purposes, depending on length and environment). A signal well surrounded by grounds, has less opportunity to leak, up to the coax case where fields are completely separated. And a signal quite distant from ground, has all the space in the world to couple to fields.Multiconductor and ribbon cables are much cheaper than arrays of coax, so it pays when you can get away with this sort of hackery!Take note of ways the environment could improve. Suppose you had a multiconductor cable, half allocated to grounds, and instead of being separate, they were cross-linked from time to time, forming some sort of loose mesh or foam ground, that the signals are embedded in. Like, imagine the grounds were bare, and just from the natural twist of the build, say, they happen to overlap and connect from time to time. Or maybe more intentionally by weaving or something. There would be little opportunity for ground voltage to develop between pairs; it would look a lot more like a bundle of coax, except maybe not so well shielded between signals (and different properties at frequencies corresponding to the average distance between ground joins). Especially, the overall field of the cable -- external fields are shorted out by the cross-links. Especially so, if there's a braided shield that they contact from time to time.Tim

author: I wanted a rude username
author_rank: Frequent Contributor
timestamp: November 02, 2021, 02:52:12 am
content: Quote from: byte on November 01, 2021, 08:40:02 pmThat's the "wide SCSI" connector, which was used pretty early ... maybe as soon as wide SCSI launched, although I seem to recall a hilariously huge 68-pin Centronix.In SCSI-2 and SCSI-3 it was not differential, but the same connector was used in the later Ultra modes, which were. They had to go to differential because the speeds were getting too high, so there were ridiculous cable length limits without it ... keep in mind that SCSI was often chained from the server tomultiplestorage units.There had already been differential modes for earlier (narrow) SCSI versions, but they needed special interface cards which were rare. The designers would have anticipated this and reserved those grounds for differential and specified they be twisted pairs as you say.

author: Terry Bites
author_rank: Super Contributor
timestamp: November 02, 2021, 04:44:02 pm
content: Ground or earth is often poorly a defined idea. It can be the return current path for the PSU, a referrence point for anlog and digtal inputs, an electrostatic shield a protective condutor or mix of the above and probably something I've forgotten.Ground loops cause local variations in ground potenial. This can be caused by extenal and internal elecrtic fields, magnetic fields and the ground impedances. The current in the ground casues potential differences to arrise. V=IR(Z). The higher I or R(Z) the bigger the potential differrence will be.Best practice is to keep the high current paths separate from low curent and signal grounds. Commonly encounterd as a split ground plane. (Controversy exists). So for instance, line the drivers an reivers need some level of ground separation. You need to route the high current and low current or interferrance sensitive circuitry separately and return them to a common point at the PSU. Loops in the power and ground are an antenna for all kinds of crap. This also generates differences in local ground potentials. It all gets worse with increasing speed of course.So not you are not over thinking it, but you need to be aware of the sources of problems and remedies.BTW analog ground and digital grounds on an IC (an ADC maybe) should be tied together and not conected to separate grounds.