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
-
\$\begingroup\$ What's wrong with using a `125? \$\endgroup\$Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2014年05月22日 21:20:56 +00:00Commented May 22, 2014 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 'speff' Pefhany– Spehro 'speff' Pefhany2014年05月22日 21:30:35 +00:00Commented May 22, 2014 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ø– Pål Thingbø2014年05月22日 22:03:18 +00:00Commented May 22, 2014 at 22:03
1 Answer 1
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.
-
\$\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ø– Pål Thingbø2014年05月23日 00:03:48 +00:00Commented May 23, 2014 at 0:03
-
\$\begingroup\$ Oops, you're right. I've edited. \$\endgroup\$WhatRoughBeast– WhatRoughBeast2014年05月23日 00:05:26 +00:00Commented May 23, 2014 at 0:05
-
\$\begingroup\$ I wouldn't use LS with modern MCUs; too much to go wrong. \$\endgroup\$Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2014年05月23日 00:13:11 +00:00Commented May 23, 2014 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ø– Pål Thingbø2014年05月23日 06:34:23 +00:00Commented May 23, 2014 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ø– Pål Thingbø2014年05月23日 06:39:40 +00:00Commented May 23, 2014 at 6:39