1
\$\begingroup\$

I am working on an electronics project where I need a two way switch, that can be controlled using an arduino and can be soldered by hand. I tried to Google for it, but without luck. Does anyone know of such a component?

EDIT: for clarity: I need to switch between two usb lines coming from a phone. I need also to switch the id line. So usb line from phone -> (usb line 1 OR usb line 2). (USB micro has 5 lines, so I need a five pole, double throw)

Here is a diagram of what I mean: Switching Diagram

\$\endgroup\$
  • \$\begingroup\$ Is a relay (relais) your idea of a 'controlled switch'? Or maybe an analog switch chip? If you tell us what you want to switch we might make a more educated guess. \$\endgroup\$ – Wouter van Ooijen Nov 16 '12 at 8:25
  • \$\begingroup\$ Please see my edit. Sorry for not being clear. \$\endgroup\$ – Siebe Nov 16 '12 at 8:30
  • 3
    \$\begingroup\$ You want to connect a uC to either one or the other USB interface, both on your phone? You can can probably leave the ground lines connected permamently, so a four-pole relais would do. (Not four throw, that would mean four different positions.) But I am not sure the USB stacks, especially the one on the uC, will respond correctly to such fast switching. \$\endgroup\$ – Wouter van Ooijen Nov 16 '12 at 8:43
  • 1
    \$\begingroup\$ I want to see if the high frequency signaling reaches the other end of the relay switch. Especially for USB 2.0 \$\endgroup\$ – jippie Nov 16 '12 at 8:54
  • \$\begingroup\$ In my situation, the phone can act both as host or slave. If it is a host it has to connect to a usb female, and if it is a host it connects to a male. The micro contoller is used to control the whole thing, because I want to control more than just this. I think the following image displays what I mean: dropbox.com/s/ncxvqu5rdxq4xdk/usb-switch.png \$\endgroup\$ – Siebe Nov 16 '12 at 9:11
7
\$\begingroup\$

USB Micro has the following lines:

  • VBUS (+5v)
  • Data+
  • Data-
  • ID
  • Ground

Of these, ID is generally not carried over a cable: It is either shorted to signal ground (host device) or left open (slave device). It does not carry any data.

Both VBus and Ground can be left connected to both endpoints in the scheme, thus reducing the switching requirement to 2 lines, D+ and D-. (Another line for ID if it must be carried across, but never seen that done). This is why USB multiplexer ICs typically carry just 2 channels.

There are several USB 2.0 multiplexer ICs that would do the job, for instance Intersil ISL54200, Maxim MAX4906/4907, or Texas Instruments TS3USB221E.

A TTL-controlled bidirectional analog multiplexer/demultiplexer like the HC4053 may be less expensive but will not work for this purpose, due to data speed requirements and capacitance matching issues.

As noted by others in the comments, USB does not take kindly to endpoints being switched. The USB protocol is not a basic TTL logic connection, it involves identification of the USB device and negotiation of speed (and also current limits). Until this handshake is done, the connection is not done.

\$\endgroup\$
  • \$\begingroup\$ First: thanks for your answer. However, I don't switch endpoints while the phone is connected. The sequence is select mode (which endpoint) and then connect the phone. The id pin needs to be carried to usb 1, because you can insert an 110kOhm resistor between Id and Ground. If you do so, the phone won't give power, so it can act as host and charge at the same time. Also, would it be dangerous if the phone and usb 2 give both power on Vbus? \$\endgroup\$ – Siebe Nov 17 '12 at 13:40
  • \$\begingroup\$ If the USB connection is to be established after link is switched, that part is all good. On connecting ID through: I'm not sure I understand - is the intent to switch a voltage or signal around, or to switch a resistance in and out? Regarding connecting two power rails, if one can safely assume that ground is well-connected, and neither side will be off the nominal 5 Volts by more than a diode-drop (0.7 volts or so), then an interconnect is not a disaster: I've used two parallel back to back diodes to connect occasionally off-by-half-volt power rails together. \$\endgroup\$ – Anindo Ghosh Nov 17 '12 at 14:48
  • \$\begingroup\$ I updated my image to make clear what I want. When connected to usb 1, the phone acts as host, and I can chose if the phone gives power. When connected to usb 2, ID is connected to nothing. \$\endgroup\$ – Siebe Nov 17 '12 at 15:45
  • \$\begingroup\$ @Swiizard For switching the resistor-to-ground connection in and out, a simple logic level N MOSFET as a switch would work fine - Wire a resistor from the sense line to drain, connect source to ground, set the gate high to connect the resistor to ground through the typically small RdsOn of the MOSFET. Set gate low and the MOSFET behaves as an open circuit. The MOSFET gate can be ganged with the USB Multiplexer, or independent, as required. \$\endgroup\$ – Anindo Ghosh Nov 17 '12 at 17:09
  • \$\begingroup\$ I just tried this with the ubiquitous 2n7000 MOSFET which isn't even rated as a logic level MOSFET, and it works fine with my phone. My earlier solution for ID resistor (now updated) was unnecessarily complex :-) \$\endgroup\$ – Anindo Ghosh Nov 17 '12 at 17:12
1
\$\begingroup\$

You can't put USB over phone line and expect any signal integrity at rated speed.

USB is universal but a short-haul solution. (1~2m) Not to mention you will have other interface issues... What is your overall objective?

\$\endgroup\$

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.