Switching USB on and off

Is it possible to place a switch on the Arduino USB connection? More speciffically, I'm trying to block USB power to the Arduino if there is no power coming from the DC jack.

I though about placing 4/5 mosfets on the USB power and data lines, with their gates tied to the 5V pin on the Arduino. Thus the USB connection woud only be seen if there was power on the 5V pin, which would only happen if there was power coming from the the DC jack.

Would this work though? Or would the mosfets somehow compromise USB communication when conducting?

I think that would cause issues on the data lines. Those are high speed and terminated at the chip interface.
Try opening a USB cable and justing putting a switch in series with the 5V line.

I think the Arduino Duemilanove and the Arduino UNO check if voltage is being supplied via VIN (DC jack) and if it is, it switches a MOSFET that kills power from the 5V+ rail from the USB connection. In other words, the Arduino is powered by the DC jack if you are supplying power to that jack even while the USB is connected. If you unplug the DC jack while the USB is still connected, the MOSFET switches so that power is supplied by USB.

There's a little more detail about it here:
http://forum.arduino.cc/index.php?topic=148541.0

Xpendable:
If you unplug the DC jack while the USB is still connected, the MOSFET switches so that power is supplied by USB.

I think the intent here is to prevent that - so that the project will never be powered by USB.

When Vin/2 is >3.3V, then Vin is used with the regulator for power.
If USB is connected, USB is used if Vin/2 is < 3.3V.

What would happen if you simply cut the 5V line? It would certainly never draw power from USB, but the data lines would still be there.

The question I can't answer myself is if the Arduino or computer would ignore the data in the absence of the 5V line.

joaocandre:
Is it possible to place a switch on the Arduino USB connection? More specifically, I'm trying to block USB power to the Arduino if there is no power coming from the DC jack.

Why?

Not only is it more satisfying for those of us who are inclined to make suggestions, if you explain what it is you really want to do, but you are more likely to get the most useful recommendation, not necessarily to the exact question you asked.

Paul__B:

joaocandre:
Is it possible to place a switch on the Arduino USB connection? More specifically, I'm trying to block USB power to the Arduino if there is no power coming from the DC jack.

Why?

Not only is it more satisfying for those of us who are inclined to make suggestions, if you explain what it is you really want to do, but you are more likely to get the most useful recommendation, not necessarily to the exact question you asked.

You're right about that, I just assumed it was a general issue without many constraints to the board itself.

The fact is that I'm using an Intel Galileo, that supposedly can be powered by USB, but Intel strongly suggests agaist that, advising users to always plug the DC jack before USB, and claiming one could brick or damage the board otherwise.

I've been careful with this until now, but one can always get distracted and since I'm also working with an UNO I wanted to devise a more idiot-proof way to protect the board.

but Intel strongly suggests agaist that, advising users to always plug the DC jack before USB, and claiming one could brick or damage the board otherwise.

Gee, that statement along would make by shy-away from a Galileo. I still remember the Intel motherboards (we were permitted in the old days of computing to use sexist words to describe computer parts) that had the design problem... something about POR, I think. Anyway, the Galileo board was supposed to be a joint collaboration between Intel and Arduino and if the caution from Intel is true, this is inexcusable.

Ray

mrburnette:

but Intel strongly suggests agaist that, advising users to always plug the DC jack before USB, and claiming one could brick or damage the board otherwise.

Gee, that statement along would make by shy-away from a Galileo. I still remember the Intel motherboards (we were permitted in the old days of computing to use sexist words to describe computer parts) that had the design problem... something about POR, I think. Anyway, the Galileo board was supposed to be a joint collaboration between Intel and Arduino and if the caution from Intel is true, this is inexcusable.

Ray

I've seen many "bad" experiences with the Galileo, and my own experience is not really that good. Amazingly slow I/O frequencies, quite inconsistent ADC behaviour, etc. I'll be using it anyway, but I' stay away from it while it is so "green". Being able to run Linux is certainly an awesome feature, but at this stage there are still some issues with the board.

I've come across, among others, the TS3USB30E IC from Texas (datasheet: http://www.ti.com/lit/ds/symlink/ts3usb30e.pdf). Could this part be used to get a somewhat robust logic for switching the USB on and off?

How about using an FTDI cable to make the USB link between the PC and the Rx TX pins on the Arduino?

...R

Is the serial interface on Rx/Tx pins directly compatible with USB? Or do I need some kind of USB to FTDI conversion?

No, the serial RX & TX pins on the Arduino / ATMega is NOT directly USB compatible. You must use something to interface between them. The FTDI232RL is a popular chip that will do that.

joaocandre:
Or do I need some kind of USB to FTDI conversion?

The FTDI cable that I mentioned is a USB to TTL converter.

...R

That might indeed be the best option. But it seems I would need additional drivers to use it? Would I still be able to use the IDE?

joaocandre:
That might indeed be the best option. But it seems I would need additional drivers to use it? Would I still be able to use the IDE?

As far as I know the IDE won't know or care - it will just see a Com port.
Having said that I haven't tested it for uploading code to an Uno (only to a breadboard Atmega328). You might need to use the regular USB connection to upload code.

The beauty of Linux is that the drivers are already in place.

...R

The FTDI-based chips, cables, and related solutions use a certified USB driver... Windows 7 seems to download and install this automatically -- at least it did on my computer. You can also download the driver directly from FTDI's website. Once it's installed, you shouldn't ever have to install it again. As the other person said, the IDE won't need to know anything about the driver - the IDE just uses a COM for communication, which is what the FTDI driver provides. And yes, you can upload your sketches this way.