Electronic – Multiplexing TTL serial lines with transistors

serialttl

A master controller talks to multiple slave devices using TTL async serial. Instead of implementing software broadcast codes, slave select codes, etc, I want the slave select to be wired.

I use a shift register (instead of the pins in the circuit), and so I only need 5 lines from the microcontroller to control as many slaves I want.

The attached circuit is tested and works, but is it a valid design? How stable will this be? Am I wrong in assuming the current flows from TX to RX? In that case, what kind of switches could I use? Optocouplers?

TTL circuit

Best Answer

What you want is a digital multiplexer, in this case a 74LS157. The following schematic should give you an idea of how it would work. This would take 3/4 of a single chip.

schematic

simulate this circuit – Schematic created using CircuitLab

In this case, a single bit is used to determine which slave link is active - 0 for Slave 1 and 1 for Slave 2. The only possible change you would need is (perhaps), to set the unused TX multiplexer channels to 1 instead of 0.

With readily available chips, you can increase the number of channels in powers of two up to 8 or 16 easily, but in principle can extend the scheme indefinitely.