1
\$\begingroup\$

I would like to make a USB flash drive easy to disconnect (rather than plug it in, unplug it).

To do this, in lieu of breaking the connection on all four pins, could I simply remove the +5vDC pin (SPST on this pin itself)?

The thought here is that I could have several of these behind a hub, and use buttons to (from an EE perspective) mount and unmount the device.

\$\endgroup\$
5
  • \$\begingroup\$ you might want to explain why you want to do that. \$\endgroup\$ Commented Mar 6, 2017 at 20:28
  • 1
    \$\begingroup\$ Unmounting is a software thing. There are already hubs that have what you describe. It does not solve the problem of stopping communication on the device before the power is shut down. If you pull the power during a read or write operation, you may corrupt the memory, thats why you unmount first, to stop the software from talking (and to sleep the device sometimes) \$\endgroup\$
    – Voltage Spike
    Commented Mar 6, 2017 at 20:40
  • \$\begingroup\$ @laptop2d -- Indeed, I was speaking metaphorically. I would for sure mount/unmount in software, I wasn't trying to emulate a forced-removal situation... Just wanted to have the device sit plugged in, but be otherwise unmountable/detectable in software. \$\endgroup\$ Commented Mar 6, 2017 at 20:55
  • 2
    \$\begingroup\$ @laptop2d , This procedure is called "surprise disconnect". Modern USB software hosts and USB mass storage class have a mechanism to handle the surprise disconnect without unmounting USB drives first. This hassle has ended with Windows XP. Otherwise billions of users would have really bad USB experiences. \$\endgroup\$ Commented Mar 6, 2017 at 20:59
  • 1
    \$\begingroup\$ Possible duplicate of Which TWO wires to disconnect to disable USB mouse \$\endgroup\$ Commented Mar 8, 2017 at 12:02

2 Answers 2

0
\$\begingroup\$

Yes, you can emulate a device disconnect by removing VBUS. This will work 100% with VBUS-powered devices like pen drives. The situation might be somewhat different if the device is self-powered. There are badly designed USB devices who might ignore VBUS and maintain functionality of serial interface. As a matter of fact, power cycling is the only way to force device disconnect (in embedded situations you usually can't mechanically remove the device). When VBUS is removed, the device UFP must turn off HS termination and remove D+ pullup.

Your second proposition will also work provided that each pen drive is connected to a different USB port. But if you plan to use all pen drives on the same data lines, data signal integrity will be compromised, and you will likely suffer from unstable functionality.

\$\endgroup\$
1
  • \$\begingroup\$ Ali -- thank you for the information. I "+1"'d your question, but my lack of rep here precludes me from that showing -- yet. Good comparison with embedded systems, I didn't think about that. \$\endgroup\$ Commented Mar 7, 2017 at 4:14
0
\$\begingroup\$

That sounds like it'd work, but be bad idea – you simply "brown out" the device, and neither the device (which you don't seem to care about) nor the hub will know what happened, and the behavior of the device while the power is failing slowly (due to residual charge in the capacitors on-device) will be erratical, leading to the hub having to re-enumerate the bus, which might/will lead to a short stop in USB functionality on the other devices. That might or might not be a bad thing. I'd generally avoid it.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ When device power is lost, the host will ether sense a port disconnect (hardware has a mechanism to sense unterminated data lines), or the device will fail to respond to transaction and cause transaction errors (if power gets down gradually, and bad devices do not have brown-out reset implemented). In latter case this is a normal expected behavior. The host will try to recover the link by resetting the port few times, it will fail, and host driver will mark this port as disconnected. No other ports will be affected. New VBUS will generate new connect event, and everything will be fine. \$\endgroup\$ Commented Mar 6, 2017 at 20:46

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