Electronic – Switch two USB ports via relay

usbusb device

I hava a tablet where I plug a PCB (with a microcontroller) on it. Because the tablet has only one USB port I have to connent and disconnect all the time the PCB, bacause I have to connect the computer with the tablet in order to transfer the Android program from the PC to the tablet. I designed a circuit with a relay with four contacts in order to avoid to disconnect and connect USB cables on tablet. I add one schottky diode on USB connector of the PC and one on the USB connector of the PCB so to avoid a short circuit between the two powers where in instance the VCC_1 contact of the relay will be stay close for some reason and the contact of the GND_2 will be open and as a result the VCC_1 will have different positive reference power. Please, tell me if this senario is wrong and the schottky diodes are not necessary or if the relay circuit needs something more.

I changed the USB micro connector to USB type A in order the tablet will be the slave.
Schematic circuit

Sample code of control USB ports – MIC2026-1YM – TS3USB221A:

Select(S)=0, OutputEnable(OE)=0
if (Second_Chip_FLB=0)
{
Switch off the D+ and D- at the port A sideside --> OutputEnable(OE)=1
Delay 500mS

First_Chip_ENA=0
Switch off the 5V at the port A
Delay 500mS
}

if (First_Chip_FLA=0)
{
Second_Chip_ENB=1
Switch on the 5V at the port B side

Delay 500mS
Switch on the D+ and D- at the port B side --> Select(S)=1, OutputEnable(OE)=0
}
else
{error}

Best Answer

There is some room for improvement in your circuit.

First of all, as suggested in the comments you can tie all grounds together and get rid of one of the switches.

You also probably want to disconnect and connect pins in a given order, usually power is the first to come and the last to leave, this is enforced in (apparently not all) USB connectors by making gnd and Vdd pins longer.

I would go with a small P mos for the Vdd rail, something in the 10V Vsd 1V Vth 5V Vsg max range. Drain on the slave, and you need two of them of course.

For the diff pair the story is somewhat different. You need a passgate, it must be fast, and so on. But luckily enough somebody had your need before you, search for 'usb switch ic' and you will get many ready made chips that do just what you need, and are designed for that.

To get the power sequence right either you throw a small micro on it (nice side project - yay!) or you can probably get away with RC delays and a bit of luck.

Related Topic