ATtiny10/9/5/4- source and sink current

I've recently started learning about the babies of the Atmel family- the ATtiny10/9/5/4, with a special interest in the ATtiny4. They're big as a grain of rice, and has memory capacity accordingly: 512b flash/ 30 b RAM for the ATtiny4. They're programmed not via the ISP, but through something called Tiny Programming Interface, which is an SPI- like communication method. Hackaday had an article about programming them using an Uno.

But I'm not a very experienced reader of datasheets. I'm trying to power the little bugger from a CR2032 (3V) coin cell and have it blink an led or two. To choose the right led I'm trying to find out how much current it can source, but I can't really understand this table:

What is Low Voltage and High Voltage? Do I understand it right if the chip can source aprox 5 mA of current per pin?

Would it be better for me (or even possible?) to connect the anode of the led directly to the coin cell and then sink current from the cathode into the ATtiny4? How do you do that, if you want the led to fade up and down? Or even blink?

Here's the datasheet for the chips. If anyone is interested.

You have focused on the correct part of the data sheet.

For a Vcc of 3 volts, which is what you plan to use, the data sheet says that a LOW will be between 0 and 0.5 volts for a load of 5 mA, and that a HIGH will be between 2.5 and 3 volts for a load of 5 mA (except the reset pin, which has different rules).

Supplemental unasked-for information: Thus, for a load of 5 mA, you can expect the difference between a HIGH and a LOW to be from 2.0 to 3.0 volts for a Vcc of 3.0 volts.

You should use a resistor in combination with your LED to avoid excessive current. The resistor will have a value calculated from R=(Vcc-VLED)/I. R is the resistance in ohms, Vcc is the worst-case voltage of 3.0 volts, VLED is the forward voltage drop across your LED at 5 mA, and I is the current in amps (about 5 mA which is 1/200 Amps).

R is likely to be in the range of 200 to 600 ohms. You may want to adjust R so that you get 5 mA through your LED.

You could connect the LED anode to the plus side of the coin cell and still make blinking and fading work, but for you it will be easier to connect the cathode of the LED to the minus side of the coin cell (also known as ground), one end of the resistor to the anode of the LED, and the other end of the resistor to an output pin of the ATtiny.

A HIGH on this pin will turn the LED on. A LOW on this pin will turn the LED off. A PWM output of 50% on this pin will make the LED appear to be roughly half brightness.

Wow, perfect answer! Thank you! Karma, most def. So the Low Voltage/High Voltage is the pin beeing HIGH or LOW? I see.

Just one thing makes me confused. When I prototyped this circuit using an ATtiny25 and a standard through-hole 3 mm LED, but no resistor... it shone very dimly. On the breadboard with the ATtiny powered through the Arduino/USB 5V, (still no resistor) it shone just enough. But with the coin cell I'd say the light was too weak- and that's without the resistor even.

Another question: I can't really see how much current a pin can source. Where can I find that in the datasheet? I've searched and searched, but I guess the language is a little bit too advanced for me.

I am not sure that there is such a thing as a standard LED, 3mm through-hole or other. You need the data sheet for your LED, or you will have to do your own experiments to determine voltage versus current. Warning: some LEDs have a built-in resistor which can affect the results.

The battery will act as if it has a resistor inside in series with the 3 volt source that is inside. Looking at the Energizer data sheet at http://data.energizer.com/pdfs/cr2032.pdf, this could be 10 to 40 ohms for a fresh battery. I would expect it to be even more for a partially used or used battery.

You may not be able to use your LED on a single CR2032.

The current that a pin can source or sink is not well described in the data sheet. In addition to the portion that you posted, there is also the graph (Figure 18-20) which should be considered typical and not worst case, and the Absolute Maximum Ratings on page 159. Be sure to read the note and try to stay a long way away from the Absolute Maximum Ratings. Notice that Figure 18-20 shows that there is a trade-off between current and voltage at a pin.

I have a lot of experience reading electrical data sheets. I agree that they can be challenging to read.

What colour is the LED? Some colours need a higher voltage than others. You should never use an LED without some form of current limiter.

Since I'm using a 3V battery, I will use red LEDs. And if the current from the battery might be unsufficient to drive the LED, why should I use a current limiter? It doesn't make sense.

It doesn't make sense.

That is only because you know so little.
Electronics is about being in control of what happens, without something to limit the current you are not. Sure it might not immediately be apparent to you but the current will change with temperature and with ageing of the LED. So you have to consider that. Without an LED current limiting device your circuit is a accident waiting to happen.

But one thing I do know: if I put a resistor in series with the led, it won't glow at all. I know this because I tried. So in choosing between having a circuit doing nothing and one that is "an accident waiting to happen", I choose the option where something actually happens :slight_smile:

But I am very aware of how little I know. So I google around like crazy, and in doing so I found the excellent LED tutorial Sparkfun offers. And in that text I find the following piece of information:

Another way to light up an LED is to just connect it to a coin cell battery! Since the coin cell can’t source enough current to damage the LED, you can connect them directly together!

I would very much like to learn why this, in your opinion, is not true? What temperatures or circumstances is it you are referring to in which the current from a coin cell reaches a magnitude where it poses a threat to the LED?

But I am very aware of how little I know.

Doesn't sound like it.

So I google around like crazy,.....

And totally misunderstood what you read.

I would very much like to learn why this, in your opinion, is not true?

Woo get you. Aggression is not going to win you many friends and coupled with ignorance doesn't get you very far with me either.

if I put a resistor in series with the led, it won't glow at all.

Read what I said, I did not say you needed a resistor, I said Without an LED current limiting device

So best of luck trying to find a sucker to help you with an attitude like that.

Grumpy_Mike:
...

Translated to polite language: it is not possible to drain enough current from (normal?) coin battery to do some harm. But if you don't know what you are doing you risk a disaster. There are rechargable coin batteries. It is possible those may supply more current than the LED survives because their internal chemistry is different (I don't know). Long time later you may forget you didn't use current limiting, and kill the LED by more powerful battery.

To see how much current you can get look at 19.6 Typical Characteristics - Pin Driver Strength. It should help you.

I am curious: why you want to use those? On eBay they are hard to find and on Aliexpress they are more expensive than more powerful ATTiny13a.

Smajdalf:
I am curious: why you want to use those? On eBay they are hard to find and on Aliexpress they are more expensive than more powerful ATTiny13a.

Probably because those don't come in a SOT23-6 package.

Grumpy_Mike:
So best of luck trying to find a sucker to help you with an attitude like that.

Ok, gotcha. I'm so happy though that you are here to teach me important lessons about attitudes.

Smajdalf:
Translated to polite language: it is not possible to drain enough current from (normal?) coin battery to do some harm.

Thank you!

Smajdalf:
I am curious: why you want to use those? On eBay they are hard to find and on Aliexpress they are more expensive than more powerful ATTiny13a.

Valid question, but I'm not looking to buy from eBay or Aliexpress. I'm designing something that might actually end up in large-scale production in the tens of thousands, and if you search the real vendor sites like Arrow or DigiKey, the prices are different. There they are extremely cheap, with prizes like $0,29-$0,32 for larger orders.
I once did the mistake of designing a prototype with no-name components from eBay, and the work it took to replace them with components actually suitable and available for mass production was extremely frustrating. So since then, I only have use brand name components while prototyping potentially commercial projects. It's much easier to go the other way.

You should be very careful when you want massproduce something like this. Even if the coin battery would be replaced for one with slightly higher voltage and much lesser internal resistance the ATTiny should safely drive a LED - provided the LED will survive much higher current than expected (you should check how much current you can get).
Also draining more current from coin battery will drop supply voltage for the ATTiny. You should be sure it won't affect its functionality.

Smajdalf:
You should be very careful when you want massproduce something like this. Even if the coin battery would be replaced for one with slightly higher voltage and much lesser internal resistance the ATTiny should safely drive a LED - provided the LED will survive much higher current than expected (you should check how much current you can get).
Also draining more current from coin battery will drop supply voltage for the ATTiny. You should be sure it won't affect its functionality.

Yes, I am cautious. But not to worry, there are people down the line who will correct any mistakes I might have done in the preliminary design, and there will be proper prototypes produced. Also, the battery will be non-replaceable, so I'm in full control of the type that will be used.

I'm just a happy hobbyist and a good salesman :). But I really want to understand stuff anyway, that's why I'm asking here. And thank you so much for your excellent answers!