Instructables

Does the method of powering arduino matters?

I ran into a small problem, and was wondering if my assumption was correct and if my solution was right too.

When it comes to electronics I am pretty green, so please forgive me.

Today I was reading an instructable dealing with Shift Register ([url]http://www.instructables.com/id/The-74HC164-Shift-Register-and-your-Arduino/?ALLSTEPS[/url] ), and came upon a problem. I had problems shifting out different patterns of LEDs. At first I though I had a defective chip. After changing the chip the problem persisted. Next I noticed that if I reset the Arduino a couple of times I would get a correct pattern displayed. I tought that maybe it might be something to do with my power source. I was running my Arduino from the USB. I tried connecting Arduino via my 5v power supply (http://www.sparkfun.com/tutorials/57), and everything started to run smoothly.

So the question is. Is the USB power not clean? and that is why I wasnt able to displayed a correct patter or was it something else?

Would it be possible to solve this with some other method?
Any links on the subject matter would be greatly appreciated.


Thank you.

verence3 years ago
+1 for what the others said.

The USB voltage (under normal circumstances) is clean. Otherwise you would see problems with the host computer.

But... and now speak after me (or better write it down a hundred times):
"A USB port is not a power supply"

A USB port without negotiation (that is without setting up a special handshake between µC and PC) _should_ supply 100mA (if it does depends on how good the designers of your PC's USB did their work).

So, if you drive 5 LEDs with 20mA each, there is no power left for the µC. Of course, in real life, the voltage will drop, the LEDs will get less than 20mA, but - and that's the problem - the µC will get less than the expected 5V (even if just for a short time) that can be enough to trigger any kind of strange behaviour. In the best case, it will stop to work at all, in the worst case, it will function normally most of the time and just misfunction if it yields the most nasty/expensive/uncomfortable effect possible.

So, play it safe. Put a 100nF ceramic capacitor (they look like little drops of paint) as short as possible from the positive to the negative terminal of any active chip. If the chip has a bipolar supply (plus and minus voltage), use one between plus and ground and one between minus and ground. It might cost a few cent more, but it's just good engineering.

Never trust a power supply you can't measure or might overuse. If you have an oscilloscope, you can monitor the supply line. Even small (downward) spikes an the supply line are problematic as they might trigger a µC's reset circuit.

If you want a stable operation, calculate/estimate the needed current and choose a power supply than can deliver at least the current (and better 20% more). You remember what I said earlier? "A USB port is not a power supply"!
Okay, it might be, but just if you need maximum (even for the tiniest moments) about 80mA (or around 400mA [yes, 800mA for USB3] if you can negotiate this with the host) .

So, if you have a regulated, stable and trustworthy power supply (your sparkfun one looks good) - well, use it. If you have to use (for whatever reason) the USB port, make sure, you use a good deal less than 100mA. You can increase the resistors to decrease the LED current for example.

Whatever you do, don't forget the 100nF ceramic caps at the chips.

And don't forget: "A USB port is not a power supply" ;-)
It depends on the LED patterns, but its quite possible you've exceeded the limit for the USB port - they can only source 100mA without explicit permission.

Steve
rickharris3 years ago
Pics in general are notoriously pray to power supply interference and need to have decoupling capacitors close to the pic chip itself.

One way to conform is to make up a battery pack and run from that to see of the problem continues.

As above your LEDS may well be drawing more current than the USB is happy with. Go for a battery or regulated wall wart PSU.
frollard3 years ago
Not clean: unlikely
Not enough current: likely.

I've personally run the arduino and 30+leds at 20ma on shift registers before with no problems - shift registers were connected to the 5v and ground output pins - I was straining it, but not hurting it.

Did you try changing which pins you use to hook up the 595 and in code? There might be something wrong with your atmega chip, although again, unlikely.