Electronic – Sensing a USB device plugged in without having to supply 5 volt power all the time

battery-operatedpicusb

I am designing a device using the PIC32MX795 processor that will act as a USB host. Since it is a battery operating device, I would prefer to not supply 5 volts all of the time on the USB port (the device will operate off a 3.7v Poly-Lithium battery and use a DC-DC boost converter to generate the 5 volts).

I would like to keep the device powered down as much as possible whenever there is nothing plugged into the USB connector. Is there some way of waking up when someone plugs in a USB device into the connector?

Even if I have to wake up once every second or so for a few milliseconds, that might be acceptable but I would prefer not to have to power up the 5 volts each time.

EDIT: After a device is plugged in, and I get data from it, then after some delay I would like to power it off so that it is not drawing current any more. This will force the user to unplug the device and plug it back in again to read the data again, which is okay.

Best Answer

You can't count on what a device will do when it doesn't receive valid USB power. For example, it might not even turn on its pull up/down resistors to indicate the speed until it thinks it's plugged into a USB, which it might detect by looking at the bus power voltage.

If you can tolerate a little lag when a device is plugged in, wake up periodically and turn on the USB power for a little while. One problem is that devices might themselves take a little time to come up once power is applied. Some of my PIC programmers, for example, have deliberate waits of a few 100 ms after they run before turning on the USB. This is to make sure everything is truly stable before talking to the host. There is no guarantee how long you need to wait for a device to want to talk to the host after being powered by the USB. A half second is probably good enough for most cases, but you can't know that for sure.

A more reliable strategy would be to make a converter that takes very little power when no current is drawn from its 5V output. That shouldn't be too hard. If done properly, the drain on a 5V output with nothing connected can be a few microamps or less.

USB is optimized for light weight devices at the expense of more burden on the host. There is no free lunch.

Related Topic