Author Topic: Extending the SPI bus for long-distance communication  (Read 2922 times)

0 Members and 1 Guest are viewing this topic.

Offline ArtoLabsTopic starter

  • Newbie
  • Posts: 3
  • Country: us
Extending the SPI bus for long-distance communication
« on: April 12, 2019, 01:15:18 pm »
Hello everyone and what's up my fellow electro-nerds! This is my first time posting so go easy on me.

Inspired by this Texas Instruments PDF I found with the same title as this post, I am attempting to connect 8 slave devices to a master "hub", each connected through a USB 3.0 connector/cable up to 1 meter away.
https://www.ti.com/lit/an/slyt441/slyt441.pdf

Questions: Can I tie together the outputs of the 74HC245 as I have in my schematic to combine together the MISO lines (will this isolate the individual channels)? Are the slave select pull up resistors on the correct side of the 74HC245 buffer (output side)? Should there be pull-up resistors for the MOSI and clock lines? Am I missing anything about the concepts here or have I chose the wrong parts?

I'm new to using buffers and line drivers, but I decided to use the 74HC245 to buffer the slave select lines and the 74HC125 to transmit the clock signal and MOSI lines. There are four 74HC125s, each acting as a dual buffer (MOSI, clock) with 3-state logic.  I chose USB 3.0 instead of RS-422 due to cost of parts and ease of use. Here is a schematic of the hub:

Master schematic
https://github.com/ArtoLabs/Sensi-pot/blob/master/Soil_Sensor_Hub/Soil_Sensor_Hub.svg

I'm using the 74LVC1G125 tri-state buffer on each slave MISO line which sends the return data when it's requested by the master. Here is a schematic of the slave-sensor:

Slave schematic
https://github.com/ArtoLabs/Sensi-pot/blob/master/Soil_Sensor/soil_sensor_kicad_tht.svg

Thanks in advance for any advice or insights you might have. Any advice you can give will go a long way in helping me ensure my prototypes are functional. I'm very excited to be a new member as I watch the show often. I look forward to interacting with all of you!
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22436
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Extending the SPI bus for long-distance communication
« Reply #1 on: April 12, 2019, 01:41:54 pm »
Why not tie all the MISOs together without anything -- the slaves only assert that pin when selected, right?

If not, it would seem you do not have SPI peripherals, you have SPI-like peripherals that don't play nicely together...

Otherwise, you need an 8-to-1 mux (74HC151?) to do that; wiring a bus buffer's outputs together will just make a uh, an awful lot of heat...  :-BROKE :scared: ;D

What clock rate are you aiming for here?  Noise in the environment?  Total cable length (all channels added together) -- just 1m cables each, no future expansion?

You say you've "chosen USB3", but nothing in here is interfacing to that standard, you're just using the cables and connectors as far as I can tell, is that right? ???

As far as I can tell, it would be more accurate to say you've chosen "CMOS logic level SPI with shielded cables".  Which is fine, as long as the shielding is maintained, and the output drivers are impedance matched (most likely, source terminated).  Indeed, this is what USB 1.1 does (of course, it uses balanced signaling as well, but the individual signals are plain old CMOS.)  On that note, it appears SHIELD and DRAIN pins are unconnected?

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline ArtoLabsTopic starter

  • Newbie
  • Posts: 3
  • Country: us
Re: Extending the SPI bus for long-distance communication
« Reply #2 on: April 12, 2019, 02:06:34 pm »
Tim, thank you for replying.  :-+
Quote
Why not tie all the MISOs together without anything -- the slaves only assert that pin when selected, right?
Well, my fear was that if all MISO lines are connected, and each device is at the end of a 1 meter cable, isn't that 8 meters of cable each device would have as resistance when communicating? I'm rather new, but I'm under the assumption that isolating each line is best.  :-//
Quote
Otherwise, you need an 8-to-1 mux (74HC151?) to do that; wiring a bus buffer's outputs together will just make a uh, an awful lot of heat...
This is indeed my exact reason for coming here after reading something similar in the 74HC245 datasheet:
https://www.ti.com/lit/ds/symlink/sn74hc245.pdf
Quote
This device uses CMOS technology and has balanced output drive. Care should be taken to avoid bus contention because it can drive currents that would exceed maximum limits. Outputs can be combined to produce higher drive but the high drive will also create faster edges into lightloads, so routing and load conditions shouldbe considered to prevent ringing.

A multiplexer makes things a bit more complex, though.
Quote
What clock rate are you aiming for here?  Noise in the environment?  Total cable length (all channels added together) -- just 1m cables each, no future expansion?
Very slow, 1Khz. Fans driven by electric motors may be used near by. I'm designing for 1 meter, but suggesting 0.6 meters. That's 8 meters total, no expansion.
Quote
You say you've "chosen USB3", but nothing in here is interfacing to that standard, you're just using the cables and connectors as far as I can tell, is that right? ???

As far as I can tell, it would be more accurate to say you've chosen "CMOS logic level SPI with shielded cables".  Which is fine, as long as the shielding is maintained, and the output drivers are impedance matched (most likely, source terminated).  Indeed, this is what USB 1.1 does (of course, it uses balanced signaling as well, but the individual signals are plain old CMOS.)  On that note, it appears SHIELD and DRAIN pins are unconnected?
Tim, that's exactly right. "CMOS logic level SPI with shielded cables" is a much better way to explain what I'm after. I may very well be barking up the wrong tree, but my hope was to keep the design, both hardware and software, simple. I'm using SPI because I'm more familiar with it and the arduino libraries. Oops. I did leave the shield and drain pins unconnected. To ground on one end, right?

Thank you once again for your response and do excuse my ignorance as I'm just a self taught newbie!  :scared:
« Last Edit: April 12, 2019, 02:30:13 pm by ArtoLabs »
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22436
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Extending the SPI bus for long-distance communication
« Reply #3 on: April 13, 2019, 02:05:04 am »
Quote
What clock rate are you aiming for here?  Noise in the environment?  Total cable length (all channels added together) -- just 1m cables each, no future expansion?
Very slow, 1Khz. Fans driven by electric motors may be used near by. I'm designing for 1 meter, but suggesting 0.6 meters. That's 8 meters total, no expansion.

Oh, they won't care then, good.  That's plenty of time for signals to settle before clocking, and, you can put a nice slow filter on the CLK line (followed by a Schmitt trigger to sharpen it back up) to prevent noise causing extra clocks.  Probably a 330R in series and 470pF to ground, at the receiver input (~1MHz lowpass).


Quote
Tim, that's exactly right. "CMOS logic level SPI with shielded cables" is a much better way to explain what I'm after. I may very well be barking up the wrong tree, but my hope was to keep the design, both hardware and software, simple. I'm using SPI because I'm more familiar with it and the arduino libraries. Oops. I did leave the shield and drain pins unconnected. To ground on one end, right?

BOTH ends!

If the peripheral doesn't connect to anything, and is physically small, you might be able to get away with it, but it would practically be by coincidence.  Any gap in the shield is a path for noise to get in.  At radio frequencies, a gap in the shield is equivalent to a voltage source in series with the signals, with voltage equal to whatever signal is dropped across the shield, depending on the size and shape of the thing.

The only time you can leave one end off, is when electric (rather than magnetic) field, or ground loop current, is the greater hazard.  This is fairly common in audio circuits, and especially common in ancient (vacuum tube) circuits where the impedance is very high (100s kohms being very typical), so magnetic fields are a tiny hazard there.  Regrettably, it's common advice, and common advice changes painfully slowly when the end users do not understand the situation well enough to correct it -- let alone to define and perform experiments that would prove or disprove the efficacy of that advice.  (Another common but similarly questionable piece of "advice" concerns switching supply loop inductance...)

But, given that -- it IS an *RF* susceptibility concern, and if you can just filter that out entirely, it really doesn't matter much if you use shielded cable at all (mind emissions, though -- you'll want filtering at both ends).  This is how USB HID devices can get away with unshielded cables -- very slow, heavily filtered protocol.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline ArtoLabsTopic starter

  • Newbie
  • Posts: 3
  • Country: us
Re: Extending the SPI bus for long-distance communication
« Reply #4 on: April 15, 2019, 02:15:00 pm »
Tim, thanks again for taking the time to share some wisdom with me. I've taken your advice and updated my schematic with a multiplexer, which wasn't as complicated as I thought.

Quote
BOTH ends!

Well, your explanation is very compelling. All the peripherals are soil sensors, rather small, and will be powered by the hub.

I also found this interesting forum post on Google that has several compelling explanations for why to connect only one end.

http://forums.mrplc.com/index.php?/topic/24493-shielded-cable-ground-both-ends/
Quote
I have worked in the electromagnetic induction field for over 10 years and I can shed some light on this for you. You only ground ONE end. If you ground both you create a physical loop that is essentially an antenna for stray magnetic lines of flux (noise from other surrounding power)
Quote
in an industrial application - probably 95% of time - ground at one end only... sometimes manufacture recommendation will be to ground at both ends as mentioned above... all depends on the grounding of common equipment. exceptions will include audio signal cables - the shield will generally be grounded at both ends and i know that a lot of medical instruments hospitals etc will always be grounded at both ends as well

The wikipedia article on the topic sheds some more light:

https://en.m.wikipedia.org/wiki/Talk:Shielded_cable
Quote
Mr. Larry A. West asserts that a shield grounded at only one end is resonant to RF frequencies at its quarter wavelength and will induce voltage to internal conductors at that frequency. He neglects to mention that a shield grounded at both ends also has resonant frequencies and can induce voltage to its internal conductors. No configuration of grounding results in the shield always being a low-impedance path to ground across its entire length, for anything but DC and low frequencies.

The soil sensors are used to monitor indoor potted plants, and the sensor itself (the metal probes that go into the soil) is connected to ground. Since the hub is the power source, I assume there's no way for me to achieve a balanced ground between the hub and the sensors (peripherals). So wouldn't leaving the sensor end of the shield disconnected make sense? But as you've said, since my clock frequency is slow, I may not have to worry too much about this at all. However I do find this an interesting topic.  :popcorn:
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13216
Re: Extending the SPI bus for long-distance communication
« Reply #5 on: April 15, 2019, 03:02:02 pm »
That's asking for trouble with ground loops and electrolysis.   I hope the sensing electrodes are fully isolated.  If not you are in for a whole world of grief only mitigated by the fact they are indoor pot plants so can be put in plastic trays so the soil in each pot is isolated from true ground.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22436
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Extending the SPI bus for long-distance communication
« Reply #6 on: April 15, 2019, 04:43:10 pm »
Mr. Larry A. West asserts that a shield grounded at only one end is resonant to RF frequencies at its quarter wavelength and will induce voltage to internal conductors at that frequency. He neglects to mention that a shield grounded at both ends also has resonant frequencies and can induce voltage to its internal conductors. No configuration of grounding results in the shield always being a low-impedance path to ground across its entire length, for anything but DC and low frequencies.

Hahahahaha.  Sure, it'll still have resonances (odd multiples of 1/2 wavelength, namely).  He fails to note that those resonant modes DO NOT couple into the signal-to-ground propagation mode.  With an open shield, they do (at odd 1/4 wave multiples).

The impedance of the signal, with respect to the inside of the shield, remains constant when the shield is grounded at both ends.  That's a better way to speak of a "low impedance shield", since there's no such thing as an arbitrarily low impedance anyway, and what we're really concerned with is the impedance being consistent (a stable ~50 ohms or whatever), and the isolation between outside fields (currents running on the outside of the shield, or for balanced line, equal (common mode) currents on the lines) and inside fields (differential currents running inside the shield, between the conductor pair) being good.

Both the impedance and the coupling get all fucked up (the common mode impedance of the whole cable is inserted in series) when ground is broken.

This is a whole lot easier to illustrate with a diagram, but alas I don't have one handy. :(


Quote
The soil sensors are used to monitor indoor potted plants, and the sensor itself (the metal probes that go into the soil) is connected to ground. Since the hub is the power source, I assume there's no way for me to achieve a balanced ground between the hub and the sensors (peripherals). So wouldn't leaving the sensor end of the shield disconnected make sense? But as you've said, since my clock frequency is slow, I may not have to worry too much about this at all. However I do find this an interesting topic.  :popcorn:

If you worry about low frequency (DC and mains, usually) ground loops, a very different circuit is needed, regardless (high impedance differential amplifier? isolator?).

You might not need to connect the cable shield and ground, to soil ground (earth, as it were).  The probe leads can be high impedance (indeed, should be..?), and RF filtering, differential sensing or isolation can be applied there.  That way, the digital signals can be fully shielded (or whatever you wind up doing).

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf