Electrical – Turning a USB drive on/off w/out unplugging it

arduinoswitchesusb

I have a camera that uses a USB flash drive to store images. The startup sequence for the camera requires that the USB drives NOT be plugged in on startup… only after the camera boards have initialized. I am triggering the camera with an arduino, but would also like to be able to power-cycle the camera via the arduino in case something goes wrong during operation (I'll be monitoring the camera remotely).

The power situation is manageable via a relay and hacking into the shutdown switch on the camera; where I get stuck is the USB drives. I need to be able to "unplug" the USB flash drives while the camera goes through its startup sequence. My current idea is to put a short male-to-female USB cable between the flash drive and the port on the camera, then tap into the power wire in that cable. If I run that through a transistor or opto-isolator and break the power circuit, will the camera think that the USB is unplugged?

I'd love any thoughts on how to get this right!

Best Answer

I have dealt with a similar problem where a USB thumb drive had to be "disconnected" from a laptop during a test procedure. There was a problem with the computer always trying to assign a new drive letter to the USB drive that made the test sequences break. (Note that the USB drive was part of the unit being tested and looked like a new drive with each UUT. The problem being the fact that the scripts of the test sequence had a fixed understanding of the USB drive letter. And on top of that the laptop test computer would quickly run out of drive letters after testing a couple dozen units.

Solving the problem took several steps. The first one was disconnecting the USB drive. In the test station electronics I used a USB power switch IC of the type that are used in USB hubs. This gave a logic level signal to turn the USB power on and off. For the D- and D+ lines I used a USB signal line switch IC from Fairchild Semiconductor. (Not that components like these are available from a wide selection in the market place). The switch also offered a logic level signal to switch the D+ and D- lines off/on.

The second part of the solution was that the test script on the laptop had to remove the assigned drive letter from the Windows OS. That took some deep research to learn how to do that programmatically via the Windows API. Note that the USB drive had to be disconnected before killing the drive letter assignment.

Interesting additional detail

Note that at another time I had an almost like case of a USB Serial Chip embedded inside a device being tested. Each time a new UUT came along the test computer would try to assign a new virtual COMM port number to the USB serial port. The solution to that was almost identical to that described above.

Related Topic