0
\$\begingroup\$

(Question is completely revised after comments from AndyAka)

I want to connect about 15 devices (max) via RS485. However, unlike a normal RS485 cable where stubs/devices are tapped from, I want to connect all stubs together directly via DB9 connectors, so there is no (RS485) cable between the DB9 connectors. Of course internally inside each stub the two DB9 connectors needs to be connected. The distance between the DB9 connectors within each enclosure is max 3 inches. I want preferably high speed (about 1 mbps or faster).

How should I do the wiring of the 'RS485' line(s) within each enclosure (between each 2 DB9 connectors inside an enclosure serving as RS485 'main line')? Should this be twisted paired cable (CAT5?) or can I get away with normal breadboard wire (since the length is not long, max 45", probably smaller).

schematic

simulate this circuit – Schematic created using CircuitLab

This means there will be no visible wires), all wires inside the enclosure, and the terminator are similar as used for DMX (except using DB9 connectors).

\$\endgroup\$
14
  • 1
    \$\begingroup\$ Have you ever examined preferred wiring schemes for RS485 networks? Like this for instance \$\endgroup\$
    – Andy aka
    Commented Aug 8, 2018 at 12:09
  • 1
    \$\begingroup\$ It's shielded twisted pair but the important thing is the way slaves are connected on small stubs thus the main cable (end-to-end) has termination resistors to avoid data reflections and corruptions. Yes you can bypass the "best" method when the speed is low or the cable runs are short but there are no guarantees. \$\endgroup\$
    – Andy aka
    Commented Aug 8, 2018 at 12:18
  • 1
    \$\begingroup\$ The bit about the connectors (in your question) sounds incompatible with RS485 as how I understand it. I guess you should just adopt the closest thing to 485 wiring as you can. For these short differences you might get away without shields but is it that big of a deal to have them? The new picture is good (apart from the Rx/Tx names) and the stubs can be lower quality cable if they are fairly short. The normal names for the "pair" is A and B. \$\endgroup\$
    – Andy aka
    Commented Aug 8, 2018 at 12:40
  • 1
    \$\begingroup\$ OK I understand, the boxes butt up to each other and are "mated" at the DB9s. I think that would work fine dude. \$\endgroup\$
    – Andy aka
    Commented Aug 8, 2018 at 12:59
  • 1
    \$\begingroup\$ Why does the middle box have the A pin connected to GND and not to the A line of the RS485 bus? \$\endgroup\$ Commented Aug 8, 2018 at 13:24

1 Answer 1

1
\$\begingroup\$

Note that if you daisy chain your devices they are not technically "stubs", they are just segments of the same bus.

You don't need any wires in your enclosures. Run two traces in parallel from input to output connector with a stop in between at transceiver pins. Use online impedance calculator like this one for example.

UPDATE

Since you revised the question and mentioned that you want to use wires instead of PCB traces, the answer would be to use short pieces of twisted wire inside, as I already suggested in comments. However the following line in revised question is confusing (and seems not only to me):

main line I mean what normally is a cable that runs along all stubs. I searched for examples, but I can only find RS485 lines where the stubs are 'tapped' from the RS485 (main) line. But mine is only the wires between each two DB9 connectors inside an enclosure

There is a reason you often see connections in the middle shown as "taps" in various RS-485 documents, like in the pictures below. enter image description here

Although electrically this is identical to the schematics in the question, it is done to emphasize actual physical layout. The goal is to minimize stub length, as shown in the middle picture.

If the "main line" between input and output connector is made with PCB traces they should be run straight trough corresponding pins of the transceiver. If the connection is done with twisted pairs they should be joined as a tap as close to transceiver pins as possible. Below are examples for both PCB traces and wire tap.

enter image description here


Now, after all this said, RS-485 is not very well suitable for this application (as in updated question). There is minimum node spacing defined by combined node capacitance per line segment. See #10 in this design guide. By piling up directly connected modules you might quickly exceed this capacitance.

FWIW, I never faced this problem, but on the other hand I haven't seen the designs like this either. Interesting that these questions one, two are still without definite answers.

There are alternatives worth considering. At your distances single-ended UART should work without any problems whatsoever. There was a discussion on similar solution recently. In that case the OP wanted uni-directional bus. If you want bi-directional single-master communication you can design your own protocol to make sure slave nodes will not transmit simultaneously. If you want bi-directional multi-master configuration you can use a simple transistor circuit to convert pull-pull UART output into open-drain, then wire bus with pull-ups, I2C-like.

UPDATE 2

If you want to try SPI then you have to control 15 (per your question) SS lines. This, of course, removes the need in software addressing and collision prevention.

Note, that you don't actually need 15 GPIO pins for this. If you put all your slave modules into same enclosure then a single 74HCT154 demultiplexer and 4 GPIO is all you need.

However if you want the flexibility of modular design then you can route 4 address lines through DB9 connectors and add simple 4-bit address decoder circuits to your modules with DIP switches to set individual addresses. Here is an example of a decoder with two cheap logic chips and 4 positions SPDT switch.

enter image description here

\$\endgroup\$
17
  • 1
    \$\begingroup\$ There is a cross-section image in the link to illustrate how ground is counted in the equation. If you are using protoboard then you basically answering your question yourself - twist the two wires between connectors and pins and it should be sufficient. Just keep them short and same length. The simplest way is to cut a piece of CAT6 and pull out 4 separate pairs, enough for 2 enclosures. See here for lots of useful information. \$\endgroup\$
    – Maple
    Commented Aug 8, 2018 at 21:51
  • 1
    \$\begingroup\$ Yes, that should be OK too. The difference between CAT6 and CAT5 is more turns per meter and plastic separator between pairs. \$\endgroup\$
    – Maple
    Commented Aug 8, 2018 at 22:06
  • 1
    \$\begingroup\$ The need for CS is the reason I never liked SPI much. It is much more application-specific than any other standard. On the other hand when the application is right it is very easy to use. Yes, you can route all DB9 pins as pass-through and add DIP switches on your boards as address selectors. If you use shroud as GND it will give you 6 CS lines. But you will be limited to 6 unique slaves maximum. Interesting that if you use one DIP switch to disconnect MISO line you can have unlimited Write/Only slaves with same address. \$\endgroup\$
    – Maple
    Commented Aug 26, 2018 at 15:29
  • 1
    \$\begingroup\$ DB9 connector has 9 pins + shroud. If you use shroud for GND and 3 pins for MISO, MOSI and SCLK it leaves you with 6 free pins. You can wire them pass-trough so that all modules have same 6 lines. Then you can use 6 positions DIP switch to connect module's SS input to one of those lines. When master activates one of the lines only module(s) that have DIP switch connected to that line will respond. If you want several modules to respond to same command you have to prevent them from MISO collision. Either by not connecting MISO at all or by disconnecting it with DIP switch \$\endgroup\$
    – Maple
    Commented Aug 26, 2018 at 22:24
  • 1
    \$\begingroup\$ SPI is not limited to 6 slaves maximum, it is limited by number of SS wires you can route. While MUXes traditionally used with SPI to increase number of slaves, in your case you'd need a MUX in each module, for 2^6 = 64 addressable slaves. This is cumbersome setup, that is why I suggested UART. Signal-wise there is not much difference, except SPI requires wire connection for addressing while with UART you can implement your own addressing in software protocol. \$\endgroup\$
    – Maple
    Commented Aug 26, 2018 at 22:49

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.