# Using BILATERAL SWITCH properly?

Summery: I am trying to figure out if I can use a bilateral switch as if it was a tiny relay capable of communicating UART signal, or are there things I am missing. Now, the long explanation.

So, I never used a bilateral switch before. The problem I am trying to solve involves having 2 devices which have one UART port each share one UART output port. Basically I have a UAV drone with a Flight Controller (FC) and an On Screen Display (OSD) units. During flight I want the FC to talk to OSD via the UART. However, on the ground, on occasion, I need to connect to either the FC or the OSD via their respective UART ports to update software, etc.

So basically I am shooting for the following states:

• S1: FC <-> External Port
• S2: OSD <-> External Port
• S3: FC <-> OSD

To do this I figured I could use 8 bilateral switches in this kind of arrangement:

I want to use the Texas-Instruments CD4066BPWR (Datasheet: ti.com/lit/ds/symlink/cd4066b.pdf). And this is the way I would like to connect it up:

What my question boils down to is do I properly understand how bilateral switches in general and this particular IC in particular work. If I substitute the bilateral switches with tiny relays my diagram should work just fine. But with bilateral switches are there any catches I am not seeing, such as for instance if they do not work at high frequencies? I don't need them to switch quickly, but I do need them to communicate high frequency data signals (standard serial speeds).

Also, I can't figure out if I need a set of resistors to pull the control pins low to disconnect the connection? And when disconnected, will the IN/OUT pins just float with circuit potential or will they be pulled low or high, or stay in the last known state or something strange like that? I am treating these bilateral switches as if they were relays basically, but am I wrong to do so?

• Um what is the IC name? The link seems to be blocked for me. – Bradman175 May 2 '16 at 23:38
• Texas-Instruments CD4066BPWR, Datasheet: ti.com/lit/ds/symlink/cd4066b.pdf. Thanks for checking it out, would appreciate any help. – Bogdan May 2 '16 at 23:41
• Well if you look at the circuit, it is really switching with a MOSFET. – Bradman175 May 2 '16 at 23:57
• Might seem daft, but a simpler way would be to put two UART headers next to each other and simply place a pair of jumpers over the connectors when in flight mode. – Tom Carpenter May 3 '16 at 0:13
• I think you'll be fine for switching UART signals. The difference between these switches and relays is that they can't handle much voltage or current and their resistance is significant (125ohms at 15V), but for UART it should be OK, maybe not at high speeds. BTW, I don't think you need 2 chips for that - a single 4-channel switch should be enough - connect FC to ports A and B, OSD to ports C and D and on the other side the "source" to A&C and B&D. And you will need pull up/down resistors on the control pins (don't leave them floating). At least you can safely try, nothing will blow up :) – Mishony May 3 '16 at 0:16

You should be able to do it the way you propose, but you can also get away with just one IC:

I believe this is also the method @Mishony mentions in the comments (just noticed it as I am posting this).

Both inputs would be pulled high by resistor (e.g. 10k - 100k). In this state all switches would be closed and your FC and OSD are connected TX to RX.

When you pull down either X or Y it will disconnect one or other of the devices. For example if Y is low then the FC is disconnected. In this state you can then plug on a debug device or programming device or something like to configure the OSD. When you pull X low the OSD is disconnected and you can now configure the FC.

Just remember to reverse the TX and RX signals when swapping between which device you are debugging. It shouldn't matter too much if you forget because the switch has typically around $470\Omega$ on resistance for a 5V supply. This should mean if you connect TX to TX the switch itself will protect your devices from shorting out the TX pins. The current flowing as a result of shorting them out would be limited to about $10\mathrm{mA}$ which is within the operating limits of the switch. Best to avoid doing so, but shouldn't hurt.

Also that on resistance won't be an issue. I frequently use 1k resistors between two UART devices at speeds of 115200 Baud without issue. It's a useful thing to have as I say because it avoids the risk of damage from TX/RX reversal.

Another option which actually wouldn't take up too much space would be something like this:

You put jumpers over the connectors when in flight mode, and then when you need to configure it you can simply connect on your debug to the corresponding pins. You can move one of the ground pins to the other side to make the connector for the debug rotationally symmetrical.

• Thank you for the help! The jumper solution would be the simplest to implement, but the PCB that connects all of the components is inside the plastic shell of the drone I am designing. It's racing drone with a full aerodynamic enclosure, with just a jst-sh 5 pin port sticking out and a little dip switch. I'll go with either a one (as suggested) or 2 chip solution, and I'll add the pull up or down resistors (depending on the path I take) as per recommendation. – Bogdan May 3 '16 at 2:36