Electrical – Multiplexing UART TX/RX line

multiplexeruart

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.

Best Answer

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.

Related Topic