both USB and 5v external power

I have build a flashlight with a Arduino duemilanove.
Something I'am not sure of is how to use the USB and the switching 5v voltage regulator connected to 5v pin on Arduino.
If I not plug in the LiPo battery, and plug in the USB, I get a pop-up "power surge, device exeeded max power limit".
Then the USB device is disconnected.
I'am not 100% sure why this happends, maybe because of a 330uF capacitor thats used by the switching 5v voltage regulator?
That may cause a peak load? There is not allot more thats draining 5v.
(leds of the flashlight are not powered by 5v)
I understand when you connect a external power supply to Vin or plug, it automatically uses that, but in my situation I use a 5v regulator on 5v pin.
Is it posible to use the external 5v supply and still be able to use USB, without draining power from the USB?

Thanks for all your help!

maybe because of a 330uF capacitor thats used by the switching 5v voltage regulator?

Yes that would do it. You could put a diode in series with the external supply capacitor to prevent this from happening.

I'am not expert, but, put one diode on the positive output of the capacitor.
But are those diodes not causing a voltage drop, so I would go from 5v to 4,9v for example?
That would be bad, I also monitor LiPo voltage, so if 5v reference is off...

If I need to plug-in a LiPo, thats fine with me, but is that posible?
A diode is also fine, but only when there is no voltage drop.

A diode is also fine, but only when there is no voltage drop.

Ok then you have no solution then.

So the main question stays...

I understand when you connect a external power supply to Vin or plug, it automatically uses that, but in my situation I use a 5v regulator on 5v pin.
Is it posible to use the external 5v supply and still be able to use USB, without draining power from the USB?
Can this be dangarous to test?

Is it posible to use the external 5v supply and still be able to use USB, without draining power from the USB?

With a stonking great capacitor on the end of your supply the answer is no it is not possible.

Can this be dangarous to test?

Yes

Just to make it clear...

when I use an external 5v power supply on the 5v pin (works that way, tested it, arduino runs fine).
But Than I also plug in the USB cable, thats dangerous to test?
USB alone gives to much of a current to be handled by the USB port, but with a external 5v power supply on the 5v pin, it can't be worst.
I only hope the USB current is not used, the external 5v power supply on the 5v pin should be used.
Will the load be on both power supplies paralel, or detect the arduino it already has power on 5v pin, and don't use USB power?
Or will they both power, but when the external supply is turned on first, and charge the capacitor, the USB can handle it?

mwhens:
Just to make it clear...

when I use an external 5v power supply on the 5v pin (works that way, tested it, arduino runs fine).
But Than I also plug in the USB cable, thats dangerous to test?
USB alone gives to much of a current to be handled by the USB port, but with a external 5v power supply on the 5v pin, it can't be worst.
I only hope the USB current is not used, the external 5v power supply on the 5v pin should be used.
Will the load be on both power supplies paralel, or detect the arduino it already has power on 5v pin, and don't use USB power?
Or will they both power, but when the external supply is turned on first, and charge the capacitor, the USB can handle it?

That is the problem with having both USB power and external +5vdc power wired together, and not a practice recommended by any regulator manufacture. That is undefined operation, and the regulator with the slightly higher voltage will be the one supplying the current. While it does work and many do it, it's still not a good engineering practice to have two regulators hardwired together.

Lefty

To get round this problem I tried two different approaches on my Megas.

On one board I but the +5v track from the USB connector.

For another board I modified the USB lead, cutting the +5v (red) lead.

I am using a PC power supply to power the Arduino Mega and found that if I connected the USB / PSU in the wrong order the PC power supply fan would stall. The two voltages were out by 0.07v but that was enough. I can't remember which order caused the problem. One way worked and the other didn't. After the modifications everything was fine.

Is it posible to cut the pin 1 of the USB VCC 5v+ but still be able to use the arduino normally?
pin 2 D-, pin3 D+ and GND are enough for communication?

Yes if you are supplying 5V externally.

Is it posible to cut the pin 1 of the USB VCC 5v+ but still be able to use the arduino normally?
pin 2 D-, pin3 D+ and GND are enough for communication?

I believe USB is differential and therefore only D- & D+ are required for communication. I may have removed both =5v and GND from my cable but without taking my cable apart I can't tell.

Iain

It might be differential but without a ground it has no reference so it will not work.
Just disconnect the 5V and leave the ground connected.

Than thats a posible solution.
I made an extension cable for the arduino anyway, so easy to disconnect the 5v+.
The LiPo battery needs to be on for uploading, but at least I don't have to open the flashlight to disconnect the voltage regulator every time.

In the future I want to build a house automation system. I have one 5v power supply 20A.
I want to wire that to all arduino's, sensors, and control leds.
It would be strange if I could not use USB to monitor or upload.
So I just have to cut all usb 5v+ wires.

Yes ether in the cable or on the arduino board.

It works, I can upload without problems on the LiPo battery when the 5v+ is cut on the usb.

Another "problem".
When the Arduino starts, my powerleds are on full power for 2 sec, and also when I upload.
Is it posible to solves this with a resistor between the PWM pin and ground?

When the Arduino starts, my powerleds are on full power for 2 sec, and also when I upload.
Is it posible to solves this with a resistor between the PWM pin and ground?

It seems more likely that you could solve this with proper code, setting pin mode first, for example. We'd need to see what code you have, though, to make any real suggestions.

There is no where near a two second delay between the reset button release and setup() being called.

The delay is not in the code, even if I use a 3 line code to define pins and analogwrite the pin, no change at power up.
It's not the reset button I use.
I power up the flashlight, the led drivers and arduino power up at the same time. But the arduino needs to start up I gues.
Durring this time (around 2-3 sec) the led drivers do not get a signal, and go full power, thinking they don't have a dim pin in use.
The powerleds are also going full power during upload (up to 4-5 sec) and connecting to the pc (1-2 sec).
They are verry bright, and covering my eyes every time I test new code, get anoying, and LiPo runs out of juice.

I'am not installing a resistor before I know it works. (need to open the flashlight).
But I gues if I use a 10K or 100K resistor between PWM pin 9 and GND, when the arduino gives no signal, the signal is low.
I hope that when the arduino gives a PWM signal, it won't stay low.

The delay is caused by the bootloader looking for some serial communications. During this time all the pins are set to inputs (following the reset) and so they float. This can cause trouble with outputs. One way round this is to use a pull down resistor.
However there is a bug in the arduino code where by if a pin had been used as a PWM output it gives one pulse before this delay, there was a thread about this a few months back.

Ok, good to know.
Can I use a 10K or 100K resistor for this?