I have 3 devices that communicate via a serial port. Let's call them Device 1, Device 2, and Bluetooth (BT to serial adapter). The BT is used to communicate with a computer, but it can be treated just like a 3rd device for the purposes of the question. There are 3 modes I need this setup to function in. Mode A would have Device 1 be connected to the Bluetooth, Mode B would have Device 2 be connected to the Bluetooth, and Mode C would have Device 1 and Device 2 connected to each other. Please see attached image for a diagram to make things clear.

Connection Modes

I can switch between modes with a 3 way switch or a button. What I am looking for is a way to switch between these 3 modes. I have considered just using a mechanical switch, but given the number of connections, and considering that my final project needs to be very small, this is impractical.

My ideal solution would be to use some kind of IC that would allow me to foreword a serial signal from one pin to another, depending on the mode selected, or a set of transistors that would allow me to switch between different modes. But I am completely open to any other, better, solution.

Any help or pointers in the right direction would be very appreciated. Thank you!

  • \$\begingroup\$ Depending on the transfer rate you can use MOSFETs with some additional selection logic (multiplexer). \$\endgroup\$ – d3L Feb 19 '16 at 22:47
  • \$\begingroup\$ How are you wanting the mode-selection 'decision' to be made? Are you trying to make an 'autonomous' switch, a switch that responds to remote switching signals, or one that responds to manual switching signals? If manual/remote switching signals, are you wanting 1 signal for each 'mode,' or a single momentary switch that switches your devices to 'next mode' every time it is pulsed? \$\endgroup\$ – Robherc KV5ROB Feb 19 '16 at 22:51
  • \$\begingroup\$ @Robherc KV5ROB Switching between modes could be done by a button or a switch, manually. Either button or a switch solution would work equally well. \$\endgroup\$ – Bogdan Feb 19 '16 at 22:55
  • \$\begingroup\$ @d3l The rate I am looking for is at least 56700. Would that work? \$\endgroup\$ – Bogdan Feb 19 '16 at 22:55
  • \$\begingroup\$ @Bogdan Yes that should work but make sure to check the maximum switching frequency of your MOSFET in the data sheet. \$\endgroup\$ – d3L Feb 19 '16 at 22:59

In the general case, you need a 2:1 multiplexer in front of each RX input.

If you know the unconnected device will not be lowering its TX output (I'm assuming the line idle level is high), then just a 2-input AND gate in front of each RX input will do it.

Or, you can use the AND gate trick with a OR gate on each TX output. That explicitly masks off the unused device by forcing the OR output high when that device is not in use. The extra input to each OR gate enables that device when low and disables it when high.


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.