0
\$\begingroup\$

Is it possible to program some chip that can switch between USB host and slave mode over an single micro USB cable talking to an Android device?

It would be OK if there was a slight pause between the switch if we have to reconfigure the chip to reconnect to the Android.

I don't need to be connected in both modes at the same time.

Background:

I have a Android device that supports USB file transfer mode so I can pull files from my GNU/Linux laptop, so you connected to it from the PC where the android device is in slave mode. And you can attach to it with an OTG cable and the device is in master mode so I can attach a external keyboard. I can switch between it by pulling out the cable and switching between them.

Even better would be to able to have both master and slave connected at the same time via the same cable. Ideally I could connect to a RasPI or some other programmable micro controller like Arduino. But I am not sure exactly.

Possible Solution

I found this note that uses a FTDI Vinculum II controller https://www.ftdichip.com/Support/Documents/AppNotes/AN_323_VNC2_Host_to_Android_Open_Accessory_and_FT232.pdf but I don't understand it all yet. Does this look like a possible solution?

Any simple devices like rasberry pi that could be used?

\$\endgroup\$
  • 3
    \$\begingroup\$ Most devices which can function in either role do the switching ultimately under software control (even if the software normally looks at an ID pin). But it is not clear how that will help you, and you can only be in one role on a given interface at a time. \$\endgroup\$ – Chris Stratton Feb 24 at 8:24
  • \$\begingroup\$ Thanks @ChrisStratton . That would be fine for my needs. So I am wondering what the best device would be to do that? Rasberry PI, Arduino, etc , and dev board that would be easy to use? \$\endgroup\$ – Jim Dupont Feb 24 at 8:56
  • \$\begingroup\$ host/slave is moderated by the on-the-go pin, \$\endgroup\$ – Jasen Feb 24 at 9:12
  • \$\begingroup\$ Using a bluetooth keyboard would elimitate one cable connection. Seems a lot simpler... \$\endgroup\$ – Turbo J Feb 24 at 10:24
  • \$\begingroup\$ @TurboJ yes, except for my case that is not possible but it is a good idea. \$\endgroup\$ – Jim Dupont Feb 24 at 11:14
1
\$\begingroup\$

Just like the chip in your phone, many (if not even most) of microcontrollers with USB interface can be programmed to be a host or a device, and could hypothetically even switch these roles. Exactly as your phone does!

A USB bus can't have multiple masters, so the "optional" goal of letting the phone be device to a PC and host to a keyboard is impossible to achieve on the same bus.

You really just want a bus switch compatible with USB signalling levels and speeds.

Since USB is such a large market, these things are produced by many IC manufacturers, for example Texas Instruments has a whole range of USB2 and USB3 switches; take the TS3USB30E as an example of a USB2 switch. Octopart tells me it can be had for little more than 1€.

functional diagram

So, you'd just wire up your connector going to your phone to the D+ / D- lines, the one going to your PC to the D1+ and D1- lines, and the one going to your keyboard to the D2+ / D2- lines.

To let the phone know that it's supposed to be in host mode, you will have to pull down its "ID pin" to ground (that's the fifth pin in a micro-USB connector). You can do that by means of yet another simple analog make-or-break switch (example).

\$\endgroup\$
  • \$\begingroup\$ Thank you, I have accepted this answer and will run with it. \$\endgroup\$ – Jim Dupont Feb 24 at 11:15
  • \$\begingroup\$ und vielen herzlichen Dank nochmals! \$\endgroup\$ – Jim Dupont Feb 24 at 20:54

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.