USB data connection question

My device is battery powered. The battery supplies a 5V regulator and the output from that is connected via the black/red wires in a hacked USB cable to the USB port on the Arduino and also to the external components in the device. That works fine.

Now I want to add the facility to communicate with the device from a PC over USB while the device is running on battery. Simple I thought. Just connect D+ and D- on a USB socket to the green/white wires in the aforementioned hacked cable and connect the computer to the socket with a standard USB cable.

Doesn't work, the computer and Arduino behave as if neither exist.

Clearly I have to do something with VBUS and GND on the device's USB socket to get this to work. Anyone know what? I want to keep my device and it's external components running from the battery while talking to the computer if at all possible.

If you have a Duemilanove board, you can connect your battery +5V supply to the "+5V" pin on the Duemilanove and the Duemilanove will handle automatically switching between the power sources.

I don't think that is worded correctly. The Arduino automatic voltage switching is between only the on board +5vdc regulator's output via the external voltage source (7-12v, Vin) and the USB +5vdc input. The external power takes priority. The output of the voltage switch becomes the board's Vcc source. Wiring external regulated +5vdc to the +5 pin on the Arduino board will not participate in the switching logic and will result in two voltage sources being wired together if either the USB or external power is active, not a recommended practice, although many do it without negative results.

Lefty

Thanks guys. After some thought I've decided to fit a switch that will allow me to choose between external USB power/data and internal power from the battery. I'll lose power to my external components while the switch is in the USB position but I'm not concerned about that because I only need the USB for reflashing the arduino.

PS. it's an Arduino mega1280 clone.