If you have power through a pin - do you need 5V?

I've built projects that still work when you disconnect the 5V. This is because they're getting 5volts though a digital pin.

Some people say it's still 'best practice' to connect to 5 volts. Any opinions on this?

I would say it's decidedly worst practice to rely on getting power via an IO pin. The power is passing through the clamping diode to VCC and therefore probably to the rest of the circuit, if there are a lot of components or capacitors the inrush current could blow the diode.

Thanks Graynomad

Can you elaborate on what the clamping diode and VCC is?

Some people say it's still 'best practice' to connect to 5 volts.

Its not best practice it is absolutely essential if you want your device to have any sort of life before breaking.

clamping diode - a diode from a signal to a power rail to prevent the signal line from going over the supply voltage. Often used inside a chip to protect from mild static discharge. VCC - the power line to a device or regulator. In this case it means +5V.

You should NOT be applying signals to a device that is unpowered.

Thanks Grumpy, I knocked off after my last post.

humanbreadboard: Here's a drawing that may help.

Most pins have diodes as shown, as Grumpy said they are there to protect the chip from electro static discharge (ESD) by shunting it to a low-impedence source ie. the power supply. If there is no PSU then the ESD will appear across the chip and probably blow it.

As for using the pin for power, it will work when removing power as you stated, but if you apply power to a circuit that's been off for a while everything will suck power at once through the clamping diode which will be bad. Although I haven't tried it it's a fair bet that the chip (or at least the diode) would blow.

Apart from all this I see no reason to do this as there's a perfectly good pin already in place for power :)

Hope that helps.

For sake of argument or example, are not "one-wire" devices both powered and communicate on a single pin (+ ground) ?

Lefty

Yes they are but the power doesn’t really come from the IO pin it just looks that way because everything is in the one package.

I haven’t used OWDs but have built entire circuits that get power from a single data line. the Circuit looks looks this.

The data must have a high proportion of 1s as these are used to charge the capacitor via the diode. The + of the cap provides VCC for the circuit. When the data is at 0v the cap keeps the circuit alive, but only for so long. Too many 0s and everything dies.

From what I’ve read OWDs work the same.

Yes they are but the power doesn't really come from the IO pin it just looks that way

I get that the power is isolated from the signal data via the diode and stored in the cap, but the 'power' is definitely coming from the I/O pin. ;)

Lefty

The IO pin is an open collector (on my circuit anyway, presumably something similar on the OWDs or there would be potential for output pin clashes) so when used as an output it can't provide any current. Whatever is on the other end of the data line is active and that's where the power comes from.

Thanks for this guys - Really Useful Stuff!!!! :o

Dallas one-wire is one of very very few designs that relies DATA "high" values in the the I/O stream to charge an internal capacitor to supply parasitic power to the device. This is only possible because the device draws so little current.

Interestingly enough, the original Lego Mindstorms brick used a similar method to read or send data to peripherals.

These solutions were specifically created to behave this way and the AVR was not. Most critical is the fact that the AVR is able to supply only very small currents from the high output status of a pin.

While nobody is saying it's impossible, it is extremely poor practice to design a circuit that gets directly powered by a data pin (exceptions noted above).

So, a data pin should not be considered a "power source", it should be considered to be a "signal" or "status flag".

Most critical is the fact that the AVR is able to supply only very small currents from the high output status of a pin.

That doesn't sound right. A AVR digital output pin has a full complementary (sinks and sources current) output stage that has a +/- 40ma (absolute max) current rating. What do you define as a "very small currents from the high output..." ?

Lefty

This is only possible because the device draws so little current.

True, because the on-board cap has to be really small. In my case I had an ATTiny85 running at 8MHz and about a 100uF cap and you could watch the VCC slowly drop as a data stream was received. It worked well though.

One thing to deal with is the rise time of the VCC, depending on what's at the other end of the data line it can be too slow to reset the uC.