0
\$\begingroup\$

I am connecting my microprocessor to a SPI device through a cable, with the SCK, MOSI, SS and MISO lines, in addition to +3.3V. I was told it is advisable to twist each line cited above, including the +3.3V, with a ground wire. Should the ground wires be grounded on both master and slave sides? Are ground loops a potential issue here?

Parameters:

  • 10Mhz clock speed
  • Cable length: 1m
  • Buffers: NL27WZ17DFT2G x8
  • Shielding: Yes
  • AWG: 26 or 28
  • Series resistor: 33 Ohms
  • Termination resistors: 100 Ohms

Detail on the cable: 5 twisted pairs, a hard find to be honest. Aluminium foil + metal braid connected to chassis ground on both sides via D-SUB connectors. Chassis ground isn't connected to signal ground on sensor side, only on master side.

\$\endgroup\$
10
  • 1
    \$\begingroup\$ Just a guess, so I'm adding a comment, not an answer. I thought one twisted balanced pair signals. Such as the Data+ and Data- of a USB cable. In this way, common noise can be canceled out at the receiver. I don't think there is much if anything to be gained by twisting ground and a signal that changes with respect to that ground. Also, I am sure SPI, I2C and other such chip to chip signals are only designed to travel short distances. As on a circuit board. That said, I have seen them used over longer distances. But special circuits are commonly employed. Still, they are not the best choice. \$\endgroup\$
    – st2000
    Commented May 19 at 15:55
  • 2
    \$\begingroup\$ @st2000 Twisting a signle-ended signal with ground means it has well defined characteristic impedance. Yes OP has been warned about 10 MHz logic level not being the best way to do it, but with proper design it might just work for 1 meter with these buffers. And I2C is successfully used for interfaces like VGA, DVI and HDMI for tens of meters so it can also work if properly designed. \$\endgroup\$
    – Justme
    Commented May 19 at 15:57
  • \$\begingroup\$ What kind of "shielding" are we talking? \$\endgroup\$ Commented May 19 at 18:00
  • \$\begingroup\$ @st2000 FYI -- in fact, USB is a poor example: the SE0 bus state is a common-mode signal. I think a lot of people forget this, and hand-wave that USB is differential, and then lift their shield grounds, and wailing and gnashing of teeth ensues. As for twisting with a signal, consider the limiting case, a signal surrounded by ground wires: you'd have coax. There's certainly nothing wrong with a signal going through a good old coax cable! \$\endgroup\$ Commented May 19 at 18:09
  • \$\begingroup\$ Aluminium foil + metal braid connected to chassis ground on both sides via D-SUB connectors. Chassis ground isn't connected to signal ground on sensor side, only on master side. \$\endgroup\$
    – Tommy95
    Commented May 19 at 18:10

2 Answers 2

3
\$\begingroup\$

Ground loops are not an issue when you intend to connect only two boards together.

In fact, the more ground wires there are, the better.

And yes, that's why you should connect all ground wires to ground on both boards. Leaving all of them disconnected on one board means you don't have a working sensor as you don't even have ground for the supply.

Also, your 33 ohm series resistot and 100 ohm termination resistor may be a problem. That is a voltage divider, and assuming 3.3V is sent out from chip, there is 2.48V at the input chip. There is barely no margin for output impedance of the buffer, and ideally it's going to be a 24mA load, and the chip output is guaranteed to output 24mA with 0.7V drop at 3.0V supply.

\$\endgroup\$
6
  • \$\begingroup\$ "In fact, the more ground wires there are, the better." Just to be clear, it is best to bring all grounds to a common point to avoid current loops. "And yes, that's why you should connect all ground wires to ground on both boards." Most of the time. There are cases where the audio and digital grounds are kept separate. At least until the power supply. \$\endgroup\$
    – st2000
    Commented May 19 at 16:01
  • \$\begingroup\$ Thanks Justme. I thought an alternative might be to connect a single ground wire and to leave the others connected only on the side closest to Earth, but then these unconnected ground wires would act like an antenna... Could you please share why multiple grounds are an advantage when only two boards are connected, and not if more? \$\endgroup\$
    – Tommy95
    Commented May 19 at 16:02
  • 1
    \$\begingroup\$ "Could you please share why multiple grounds are an advantage when only two boards are connected, and not if more?" Going deeper: Ground loops happen when there is larger amounts of current over longer or thinner wires. Grounding in a "star" arrangement (not a loop arrangement) using short thicker wire is a good way to avoid ground loops. Don't use more wires then you need (creating loops!). That said, if these are low current boards, then, likely you shouldn't have a ground loop problem. \$\endgroup\$
    – st2000
    Commented May 19 at 16:07
  • 2
    \$\begingroup\$ @Tommy95 If you connect only board A to board B, no matter how many ground wires you put between them, that's not really making ground loops, that's just bonding the board grounds better, with less inductance and less resistance from the wiring. Also each of the twisted pairs are a transmission line, so you need to make each twisted pair continuous, you can't leave one wire of a transmission line disconnected. \$\endgroup\$
    – Justme
    Commented May 19 at 16:24
  • 1
    \$\begingroup\$ @Tommy95 Yes, or use it for ground and supply. \$\endgroup\$
    – Justme
    Commented May 21 at 22:44
0
\$\begingroup\$

Ground loops are an issue, it's not related to SPI in itself. What you do is a great way to communicate, only it's best to digitally isolate one side - that's about 4-5 additional dollars to BOM, but no voo-doo style issues.

Thinking about ground loops, you should see that every current in the system always goes there and back at the same place - return wire should be right next to the power wire. If you have multiple ground connections, ensuring no unwanted currents in these wires is out of your control.

This is why there is isolation. Ethernet is great in this sense, but with digital isolation you can get SPI too.

\$\endgroup\$
4
  • \$\begingroup\$ This answer misses the whole point, that the SPI sensor board is powered from the MCU board. There is no reason for isolation, as there are no ground loops, unless you count more than one ground wire between MCU and sensor. \$\endgroup\$
    – Justme
    Commented May 19 at 18:28
  • \$\begingroup\$ You know, if you are sure - great. I saw significantly more than one system where the designer was sure there is no other ground connection. And then it takes weeks to even understand what's the hell is going on. In my view the only way to be sure is to make sure - if that's what you do - good for you. If you are not sure - here is my answer. \$\endgroup\$
    – TQQQ
    Commented May 19 at 18:42
  • 1
    \$\begingroup\$ Well, your answer forces the return currents of all data signals and supply through one ground wire, which is inferior to having multiple return wires for lower AC and DC impedance. But yes, the return paths of any system must be designed well based on what's best for each system, there is no one true answer for all the different scenarios you might run into. \$\endgroup\$
    – Justme
    Commented May 19 at 19:13
  • \$\begingroup\$ No, that's not what my answer is about. \$\endgroup\$
    – TQQQ
    Commented May 19 at 21:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.