I need to connect UART devices in a master to multiple slaves configuration.

I need to isolate the desired slave while I'm transmitting, so others will not receive, non-selected slaves must have its RX line High. These devices only answer when asked, no transmission without a request.

I cannot change the slave devices, this is how they operate, I cannot create slave addresses or something to address this "isolation" in software.

Another issue is that they are isolated by an Optocoupler, PC817, so I cannot create some kind of resistor network to keep the RX line of the slave High while not selected.

This is the slave RX equivalent of the slaves:

RX Line

This is what I came up with:

enter image description here

The BAT43 is to isolate the TX from slaves. I already used this kind of solution, works great when the slaves don't write to line simultaneously, the pull-up keeps line High if nothing is transmitted, If a slave transmits, only the Low pass through the BAT43.

The doubt is with the TX from the master. In this schematic, I used a 74HC32(OR gates) to keep TX line high(This is a must), even if the slave is not selected, to select a slave, TXx_EN goes Low, others goes High. I don't know if the 74HC32 can drive the PC817 high, in the datasheet it says max 25ma, so I believe it could.

I need to keep RX from slaves high while not selected because otherwise, it would see a "start bit" when de-selected.

Would this solution be a good one? I could use a dual transistor solution(One from TX and another from VCC), but too cumbersome.

EDIT: I'm using STM32F103 as Micro, 3.3v. The R2 resistor is a 470ohms.

  • 1
    \$\begingroup\$ It's probably saner to use SPI-to-UART ICs here, e.g. two SC16IS752. \$\endgroup\$ – Simon Richter Apr 26 '19 at 14:14
  • \$\begingroup\$ what's your value for R1? \$\endgroup\$ – pm101 Apr 26 '19 at 14:28
  • \$\begingroup\$ @Simon, I checked some ICs , but they are hard to find(I'm in Brazil) and too expensive, one from. Maxim is 14 USD on Mouser. \$\endgroup\$ – 0x3333 Apr 27 '19 at 16:19
  • \$\begingroup\$ @pm101 it's 10K. \$\endgroup\$ – 0x3333 Apr 27 '19 at 16:19
  • \$\begingroup\$ Are the other pins free, or just not used yet? The STM32F103 should be fast enough for a soft UART, especially if you don't need to keep the receive loop running if you're not expecting a message — that way, you need no external components. \$\endgroup\$ – Simon Richter Apr 28 '19 at 18:18

Your solution is correct, but your enable pin will be inverse-logic (low for enable), which isn't obvious in the schematic.

In general, the way to solve this sort of thing is to write out a truth table for the desired system. In this case, treat each slave TX in isolation. You want the slave's TX line to be high whenever the slave enable line is high (to make it an inverse enable line, put a "!" in the name, so "!TXn_EN." EAGLE will put a bar over the name), and you want it to follow the TX line whenever the enable line is low.

I don't know how to make a table in this editor, but if you make one up with that description, you'll find that it's a simple OR gate.

| improve this answer | |
  • 1
    \$\begingroup\$ The 74HC32 is an OR gate, as the OP said. They appear to be using the European logic symbols from the Eagle libraries. I don't know why that particular symbol is used or what standard defines it. \$\endgroup\$ – Elliot Alderson Apr 26 '19 at 14:22
  • \$\begingroup\$ You're right. I've changed the answer to reflect that. \$\endgroup\$ – nsayer Apr 27 '19 at 16:15
  • \$\begingroup\$ @nsayer I know that it is a simple OR logic. That's why I'm using an OR gate IC. I also know that the logic is negated. The question is regarding the solution, if would work... \$\endgroup\$ – 0x3333 Apr 27 '19 at 16:26
  • \$\begingroup\$ The symbol in Eagle is weird, but it is an OR gate! :) \$\endgroup\$ – 0x3333 Apr 27 '19 at 16:27
  • \$\begingroup\$ I've adjusted the answer - I do think it will work. Incidentally, I use EAGLE too, and you can get the correct OR symbol. If I remember properly, there is a different library for the same set of parts that uses "us" symbols. \$\endgroup\$ – nsayer Apr 27 '19 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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