Re: Wire Shielding

by adafruit_support_mike on Fri Feb 14, 2020 7:46 am

Generally speaking, you don't have to worry about shielding for things like I2C or SPI signals.

Shielding becomes an issue when you can no longer use a set of simplifying assumptions called the 'lumped element model' of electronics.

The actual physics of electromagnetic systems is described by Maxwell's Equations, which involve 3-dimensional calculus with symbols you don't learn until about 4 semesters into a college math program. They're just about impossible to calculate exactly for any real system, and even the simplified versions are a pain.

Back in 1845, a college student names Gustav Kirchoff proved that you can make the math much easier if you're willing to accept a certain amount of inaccuracy in the results. He also showed that you can make those errors vanishingly small if you can assume a few things are true.

Maxwell's equations define two things you can do with electromagnetic energy: store it in a fixed electric field, store it in a magnetic field. Georg Ohm also proved that you can convert electrical energy to heat, but most heat can't be converted back to a useful electrical signal. All of the full-blown equations for those principles are defined in terms of 'surfaces' around the charged particles or electromagnetic field. For the sake of casual discussion, a surface is just something with an inside and an outside, and you can't go from one to the other without going through the surface.

Kirchoff proved that if you make the surfaces small enough, and move them far enough apart, they have almost no effect on each other. If we also assume that one of the three possible things happens to energy inside a surface, we get three kinds of objects called 'ideal components':

- Surfaces that enclose a fixed electric field are called capacitors

- Surfaces that enclose a magnetic field are called inductors

- Surfaces that convert electromagnetic energy to heat are called resistors

Then we can extend the idea of things not interacting with each other by applying a sort of 'what happens in Vegas stays in Vegas' principle: if the surface around one of those three things is sufficiently far away from the process inside it, there's practically no interaction between the space inside the surface and the space outside the surface. The only interaction a component can have with the outside world is for charged particles to pass through the surface.

If the world inside the surface and the world outside the surface have almost no effect on each other, we can simplify all of the 'calculate the three dimensional integral of flux normal to the surface' stuff in Maxwell's equations to 'pick two points on the surface. Call them A and B. Everything that goes into the surface goes in through point A, and everything that comes out of the surface comes out through point B'. Charged particles going in and out through those points are called 'current', and the energy moving them through the surface is called 'voltage'.

We can simplify things even more by saying 'if current goes in at point A, the same amount of current comes out at point B'. In other words, components can't make current appear or disappear.

The final piece necessary to describe circuits is a way of getting current from one component to another, using a fourth kind of surface called a 'node'. Nodes can't do anything to the current that passes through them, but they can have multiple points where current comes in or goes out. The voltage between any two points on a node is always 0V, and the amount of current going into any single node equals the total amount of current going out of all the other nodes.

With all of those rules in place, we can describe everything about a circuit in terms of the current and voltage at the A/B points of the components, and most of the math is simple enough that you can do it on the back of an envelope.

The trick is that you have to maintain all those simplifying assumptions. In general, that means the length of the longest current path through a circuit has to be much smaller than the wavelength of the fastest signal going through that path. Light moves at 300 million meters per second, so the wavelength of a 10MHz signal is 30m. If the longest connection in a circuit is a couple of centimeters, the 'much smaller' rule applies well. The wavelength of a 5GHz cellular signal is about 6cm though, so a couple centimeters of wire length would be large by comparison.

We also have to maintain all of those 'no interaction between the surfaces' rules, but any loop of current has a magnetic field, and any two conductors near each other act like a capacitor. Once again, we have to apply the 'much smaller than the signal of interest' idea to see whether those parasitic components will cause problems. The problems get worse at higher frequencies, higher currents, and higher voltages because they all have more energy.

You can reduce the problems of parasitic inductance and parasitic capacitance without shielding, but the solutions are in direct opposition to each other.

Capacitors get stronger as the charged surfaces get closer together. To reduce the effects of parasitic capacitance, you can move the surfaces farther apart.

Inductors get stronger in proportion to the area enclosed by the current loop. To reduce the effects of parasitic inductance, you can move the sides of the loop closer together.

You can't do both at the same time, but fortunately capacitors and inductors respond to different kinds of electromagnetic energy. The amount of energy in a capacitor is proportional to the voltage across it, and the amount of energy in an inductor is proportional to the amount of current going through it. If you have signals that use very little current but change voltage quickly, you have a chance of problems from parasitic capacitance. Move those wires as far apart as reasonably possible. If you have signals that carry a lot of current, you have a chance for problems with parasitic inductance. Move those wires as close together as possible.

If you have the option to run wire in three dimensions, you can solve problems of parasitic capacitance by running wires perpendicular to each other. That makes the region where the two surfaces are close together as small as possible. You can solve problems of parasitic inductance by using twisted pair cables. Two interlocked helices share the same axis, which makes them a reasonable approximation of 'exactly the same path' for magnetic purposes. If all of the current flowing through one wire in a twisted pair flows back through the other wire, you get an average current of zero flowing along a single line whose loop area is zero, and thus no magnetic field.

That only works for two wires though. If you twist more than two wires into interlocked helices, you get a transformer. Any two wires with current flowing the same direction are magnetically 'the same wire' and will do their best to carry exactly the same signal.

Shielding is what you use when you can't solve your parasitic capacitance and inductance problems with distance or geometry. High frequency signals combine the worst parasitic effects of high voltage and high current, and sometimes you just don't have room to move things far enough apart.

Digital signals usually don't need shielding unless they're very fast and very close together. Digital protocols are specifically designed to be as immune to external noise as possible. They have well-defined high and low voltage thresholds and a 'don't go there' region between them that makes it possible to calculate the probability of reading a 1 as a 0 or vice versa. It's called the protocol's 'bit-error rate', and is usually down in the 'once every hundred years' range.

The signals that most commonly need shielding are RF signals, whose whole job is to radiate and be picked up somewhere else. They explicitly violate the assumptions of the lumped element model and need to be handled the hard way. You shield those to protect the rest of the world from them.

Signals that travel through long wires also need shielding because they tend to violate the 'much smaller than the wavelength of the fastest signal' principle. You shield those to protect them from the large chunk of world around them.

Shielding can be useful in conditions where small changes create unacceptable problems. If you're using a 20-bit ADC on a 5V signal, the smallest voltage you can resolve is 5uV.. you'll want shielding to be one of the many noise reduction measures you use to keep that signal clean. Signals that go into a high-gain amplifier can usually benefit from shielding.. most people build their first accidental radio by connecting an unshielded input to an amp whose gain is higher than 100. You shield signals like those to protect them from the world close to them.

The rest of the time, you use shielding after you've discovered a noise problem and can't solve it geometrically. Some people who've built our PiGrrl game console have experienced noise in the audio signals because the data signals that control the display couple through the LiPo pack flat up against the cable. That's a parasitic capacitance problem, and wrapping the LiPo in a grounded foil shield tends to help.