Extending the SPI bus for long-distance communication - Page 1
Forum section: electronics / projects

author: ArtoLabs
author_rank: Newbie
timestamp: April 12, 2019, 01:15:18 pm
content: 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.pdfQuestions: 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 schematichttps://github.com/ArtoLabs/Sensi-pot/blob/master/Soil_Sensor_Hub/Soil_Sensor_Hub.svgI'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 schematichttps://github.com/ArtoLabs/Sensi-pot/blob/master/Soil_Sensor/soil_sensor_kicad_tht.svgThanks 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!

author: T3sl4co1l
author_rank: Super Contributor
timestamp: April 12, 2019, 01:41:54 pm
content: 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...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

author: ArtoLabs
author_rank: Newbie
timestamp: April 12, 2019, 02:06:34 pm
content: Tim, thank you for replying.QuoteWell, 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.QuoteThis is indeed my exact reason for coming here after reading something similar in the 74HC245 datasheet:https://www.ti.com/lit/ds/symlink/sn74hc245.pdfQuoteA multiplexer makes things a bit more complex, though.QuoteVery 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.QuoteTim, 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!

author: T3sl4co1l
author_rank: Super Contributor
timestamp: April 13, 2019, 02:05:04 am
content: Quote from: ArtoLabs on April 12, 2019, 02:06:34 pmOh, 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).QuoteBOTH 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

author: ArtoLabs
author_rank: Newbie
timestamp: April 15, 2019, 02:15:00 pm
content: 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.QuoteWell, 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/QuoteQuoteThe wikipedia article on the topic sheds some more light:https://en.m.wikipedia.org/wiki/Talk:Shielded_cableQuoteThe 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.

author: Ian.M
author_rank: Super Contributor
timestamp: April 15, 2019, 03:02:02 pm
content: 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.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: April 15, 2019, 04:43:10 pm
content: Quote from: ArtoLabs on April 15, 2019, 02:15:00 pmHahahahaha. Sure, it'll still have resonances (odd multiples of 1/2 wavelength, namely). He fails to note thatthose 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.QuoteIf 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