2
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ What's wrong with using a `125? \$\endgroup\$ – Ignacio Vazquez-Abrams May 22 '14 at 21:20
  • \$\begingroup\$ What does The attached circuit works mean? Why not use 1/2 74HC4066 for each channel (assuming TTL or CMOS levels and CMOS inputs, and pull-down resistors on each input)? \$\endgroup\$ – Spehro Pefhany May 22 '14 at 21:30
  • \$\begingroup\$ I didn't know about 74HC4066. What do I gain using this, except for a little less soldering? \$\endgroup\$ – Pål Thingbø May 22 '14 at 22:03
3
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Those are all NPN's in the schematic. Your design seems fine unless you have more than two slaves. Painting the same component (the slaves) twice in a schematic is bad design. Just sayin. \$\endgroup\$ – Pål Thingbø May 23 '14 at 0:03
  • \$\begingroup\$ Oops, you're right. I've edited. \$\endgroup\$ – WhatRoughBeast May 23 '14 at 0:05
  • \$\begingroup\$ I wouldn't use LS with modern MCUs; too much to go wrong. \$\endgroup\$ – Ignacio Vazquez-Abrams May 23 '14 at 0:13
  • \$\begingroup\$ This is funny. On the MCU supplier's forum, people were trying to convince me to use software slave select (so you could have a single wire between all devices). I find that to be very complex when you have just 2 slaves, nevermind 10 in my plan. Also, if something goes wrong, you get a debugging hell, to say the least. Thanks for pointing me to the muxes, I'm implementing 74HC4066's. \$\endgroup\$ – Pål Thingbø May 23 '14 at 6:34
  • \$\begingroup\$ About the current direction. The TX line is a driver, so my design is ok. You can even use CD4066 for this (<10mA) because MCU's have high impendance on the inputs. \$\endgroup\$ – Pål Thingbø May 23 '14 at 6:39

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.