Hello,
I am using some shift registers to sequence some RGB LEDs. Since the LEDs require some current, I am powering the LEDs and circuitry (shift registers and ULN's) with a 5V regulated wall adapter. I have Arduino ground and external power ground connected.
The circuit works fine when both USB and external power are applied. However, I saw some very strange behavior when I unplug the external power wall wart. It seems that the USB is trying to power the entire circuit! (the LEDs dimly light).
This stumped me at first, but after some diagnosis, I found what was happening. When my external circuitry is unpowered and the Arduino is sending the clock pulse to the shift register (74HC595), I see the VCC line of that chip goes high. It seems that turning on an input to the (unpowered) shift register places 5v on its VCC line, which in turn then tries to power my entire circuit!
Maybe the recommendation is to always unplug USB before unplugging external power. I wonder if there is a better answer? Thoughts?
The shift register has clamp diodes on the inputs to prevent them from going above Vcc or below ground (if there is enough current limiting to prevent blowing up the chip). In your case the clock signal goes through the diode to Vcc of the shift register. The output drive of the processor pin limits the current.
Do you actually need to run the Arduino while the other stuff is powered down? If not, you might be able to power everything from the wall adapter, including the Arduino. What Arduino are you using?
Yes, phantom power can be kinda spooky, and potentially can do some damage. I once flashed new firmware to an MSP430 MCU without connecting power. It actually worked, but is not a recommended practice.
The project will normally fully run on standard power including the Arduino (UNO). The problem I described only occurs during program development where I need to both power the light display externally and have a USB connection to the Arduino in order to program it.
I plan on adding different lighting schemes over time, so every now and then I will need to power the display with external power, while I'm programming the Arduino via USB and that's when the problem occurs.
Yes, this is a problem with the Uno because it switches in USB power unless there's a high voltage on Vin (I believe) and doesn't pay any attention to what's on the 5V pin. But if you use a Nano, you can have both supplying power at the same time, and there will be no conflict. That's because the Nano has a Schottky diode between the USB power pin and the 5V pin. So if 5V external power is connected to the 5V pin, it will always supply the circuit. The diode will be reverse-biased. But USB communications will still work.
So I think my best option would be to hack a USB cable so that it has signal only, but no power and then power everything externally in both "development" and "release" mode. I think that would work.
Would you agree?
Isn't that always the case? I am concerned that the rest of the hardware is trying to pull too much current from the usb. If I always unplug the USB prior to shutting off external power, then I think I am OK.
I think the hacked USB cable would work fine. Or you could temporarily remove the fuse from the Uno, or maybe just cut the trace in a way that you could re-solder it when needed.
Have made a cable with the 5V wire cut, I have bought both ends out to terminals so you can jumper them together if you need USB power, or insert an Ammeter to measure current.
Yes, I have heard of them and I agree it's a nicer single package solution. It's just that 595's and ULN's are what I currently happen to have.
But I don't have the "5V" pin connected when this occurs. The USB power is the problem as it's "bleeding" through to Vcc in my circuit and trying to power the rest of my project by just sending an output to the chip. I can avoid it by unplugging USB first before unplugging external power.
Do you have experience with this particular model? In the reviews I've seen, most of these things do well measuring voltage, but not so well measuring current. How about this one?
They just give me an idea of when my phone/ tablet is charging, or what a project is doing. But particularly useful combined with the "dummy load" module for seeing whether USB power supplies are "up to scratch".
The point of division should be at the shift register. As it requires minimal current, it should be connected to the "5V" pin of the Arduino while the LEDs drawing major current should be powered from the "external" supply, so to program via USB, you disconnect the Arduino and shift register 5 V from the LED supply.
The major limitation of the ULN is that it loses well over a Volt which may matter for things requiring 5 V.
Yes, I think that will resolve the problem. It does mean that I will need to disconnect my external power from the chips when in programming mode since I don't want my external power to compete with the USB power. So when switching between standalone and programming mode, a connection needs to be broken in order for this to occur. Not a big deal, but something that one has to be mindful of. Probably the simplest solution is to always use the 5v pin to power logic, then when switching to standalone mode, plug external power into the barrel jack to power the UNO. That way, no wiring from the UNO to my custom board has to change.
I wasn't aware of that until you mentioned it, I guess I should fully read the datasheet. It may not be a problem in my application since LEDs are current driven, however it may mean that I can reduce the values of the current limiting resistors by 20% in order to compensate.
It is a necessary consequence of the use of Darlington transistor pairs.
Before you panic, measure the current to see if it is what you want and recall that a 20% difference in LED brightness would in any case be quite difficult to detect visually.
Oh, right it would go through the regulator in that case which is definitely NOT what I want to feed my already regulated 5v supply into. I think my only real option is that I'm stuck using the 5v pin. So I'm back to a rewire situation when switching back and forth from programming to standalone use. I will have to at least connect and disconnect external power to the 5v pin depending on the use case.
programming - UNO provides power to logic via 5v pin
standalone - external power provided to UNO via 5v pin
It seems my only option to avoid this is to always use a hacked USB cable and always power everything externally.
Right, the output transistor of a Darlington cannot saturate and is subject to Vce drop. I measured .63v, so it's not too bad. As you point out, I don't know if compensating for that will make a visible difference, I suppose it depends where on the "knee" I'm at. I'll have to experiment and see.