7
\$\begingroup\$

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}
\$\endgroup\$
8
  • \$\begingroup\$ Is the PCB a usb slave? Hence the ID pin being grounded to signal OTG? \$\endgroup\$
    – Passerby
    Commented Feb 28, 2016 at 1:37
  • \$\begingroup\$ The connected PCB acts as the host and powers the bus. \$\endgroup\$
    – DarkKnight
    Commented Feb 28, 2016 at 1:58
  • 2
    \$\begingroup\$ So the pcb is a normal host, like a second computer. This is normally handled with a usb switch ic btw. \$\endgroup\$
    – Passerby
    Commented Feb 28, 2016 at 3:23
  • 1
    \$\begingroup\$ If your embedded device is a host, you should consider trying to get it to support passthrough mode. You can also see if you can run ADB wirelessly to free up the need to switch the USB port. \$\endgroup\$ Commented Feb 28, 2016 at 5:58
  • 1
    \$\begingroup\$ My first suggestion is to not switch the GND. Interconnect all these GND connections and simplify the relay down to a 3PDT. \$\endgroup\$ Commented Feb 28, 2016 at 6:01

3 Answers 3

4
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ If VDD_1 and VDD_2 will be activate both for some reason this will cause a damage on devices because if yes I have to check with a microcontroller the state of Mosfets before activate the other VDD? \$\endgroup\$
    – DarkKnight
    Commented Feb 28, 2016 at 20:10
2
\$\begingroup\$

I would simplify the circuit some so that the relay only needs to be a 3PDT. This can be done by connecting all the GND signals together.

Note that I made a product a few years ago that did almost the same thing you are trying to achieve here. I learned from painful experience that you cannot just use a simple relay switch (or even an integrated circuit based switch IC) to swap USB ports like this. There needs to be a certain minimum amount of time from the time one USB device is disconnected and the other is connected. If you do not provide some time where both devices are disconnected it can confuse the driver software in the various computers/tablets to the point where it is necessary to re-boot them.

For the reason I stated above it is very necessary to provide separate relay or switch controls for each USB connection so that you can control them as to both be "OFF" at the same time. I also learned that it was necessary to switch the 5V power separate from the USB D+ and D- signals. Here is the flow sequence that I coded into a state machine to support the switch type action. Here I show the switch from the A side being active to the B side being active:

  1. Switch off the D+ and D- at the port A sideside
  2. Delay period **
  3. Switch off the 5V at the port A
  4. Delay period **
  5. Switch on the 5V at the port B side
  6. Delay period **
  7. Switch on the D+ and D- at the port B side

** The delay period that I used was 500msec by default but was made programmable in the equipment so it could be changed by the customer if they had reliability problems with the default time.

BTW. My experience is that the amount of dead time needed between side A of the USB being active to side B being active can vary a lot based in part upon the type and manufacturer of the attached USB devices. For example, when I would switch USB thumb drives between two hosts some would always restart reliably when the default time was used. Others would require multiple seconds of delay time.

\$\endgroup\$
8
  • \$\begingroup\$ Michael thanks for the detailed reply. With this way that you suggest (with delays) you think I have to use four relays with schottky diodes in each power (VDD) or two relays for each port D+,D- and two mosfets for each power (VDD_1 & VDD_2)? If for some reason two VDD activate together (parallel) then this will cause a damage on devices or no and consequently diodes are useless? \$\endgroup\$
    – DarkKnight
    Commented Feb 28, 2016 at 14:25
  • \$\begingroup\$ @2X - As has been mentioned elsewhere use a USB switch IC for the D+ and D- lines. There are available USB 2->1 MUX switch parts specifically for this purpose. Get one with both an enable and select pin. You can disable the part to get the condition where both devices are off and use the select pin to change the A or B channel during the time the switch MUX is disabled. Then they make simple USB power switch IC chips that can be very handy to use for use. Use 1 MUX chip and two of the power switch ICs and you will not require any relays or relay coil drives and catch diodes. \$\endgroup\$ Commented Feb 28, 2016 at 15:12
  • \$\begingroup\$ After searching on the net I found the "TS3USB221A" which is a "High-Speed USB 2.0 (480-Mbps) 1:2 Multiplexer and Demultiplexer" with "Select" and "Output Enable" pins. Could you suggest me "USB power switch IC", because I didn't find something, so to switch the two powers (VDD_1 & VDD_2). \$\endgroup\$
    – DarkKnight
    Commented Feb 28, 2016 at 18:18
  • \$\begingroup\$ @2X - In the product that I mentioned in the answer above I used the FSUSB30MUX part number for the switch / mux. For the power switching I used the MIC2026-1YM part. For the power switch you must properly comprehend what is the source of the 5V power and which USB connectors are the "device". If you wire up the pin 5 to GND on a tablet device (likely being an OTG compliant unit) it will most probably make it act as a HOST device and source its own 5V out its micro USB connector. \$\endgroup\$ Commented Feb 28, 2016 at 18:42
  • \$\begingroup\$ @2X - Note that on another product I used the part number AP2152ASG for a USB power switch. It was used in a manner to support a device that had two USB connectors, one of which was always a HOST connector and the other an OTG supporting connector which could play either HOST or DEVICE role. \$\endgroup\$ Commented Feb 28, 2016 at 18:46
0
\$\begingroup\$

Use the three position toggle switch wired so that one of the devices is connected on the corner position and both are disconnected in the middle position. Going through the middle position will provide the necessary delay, and you will be able to control the duration (maybe multiple seconds, maybe none is required, and depends on device).

Best seems to use the three lane switch that could toggle device reliably without any additional electronics. The switch must "break before make".

Relays seem problematic as they have two positions, not three, and cannot stop in between. Combining multiple relays into some logic is difficult as they must engage and disengage in expected predictable order so not to connect both hosts to the device at the same time.

I could not find any exactly requirement that lanes must be connected in particular order.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.