Voltage regulation on Attiny85

Hi all,

First of all, im rather a noob when it comes to electronics, but I like playing with it. So forgive my stupid questions. :slight_smile:

Last time I asked a question about powering my attiny85 with a battery and power consumption.

In a meanwhile I've created a project where my Tiny is connected to 2 rechargeable AAA batteries giving me ~2.5 but it will drop when the batteries become empty and the tiny is going to be unstable.

Heres my question; how can I regulate my voltage in such way, its always between 1.8-2.5 (or something)?

What are you advising / using?

Thanks!

Hi,

KiwiFreaK:
...it will drop when the batteries become empty and the tiny is going to be unstable.

So? Does it matter?

Lol!
XD

I would like to turn it off, when the voltage become too low.
Ideally i would like to flash a small LED when the battery is almost empty.

Is that possible?

KiwiFreaK:
Lol!
XD

I would like to turn it off, when the voltage become too low.
Ideally i would like to flash a small LED when the battery is almost empty.

Is that possible?

A Tiny 85 has analog inputs, so, yes... just measure the battery voltage.

nb. You don't even need to use an external pin - you can select Vcc as input to the ADC converter. You also have internal voltage references to compare the value against. See the ADC section of the datasheet.

nb. If you're worried about battery life, remember to switch off the ADC after use as it draws a lot of power (same for timer1, etc.)

KiwiFreaK:
I would like to turn it off, when the voltage become too low.

Set the BOD (Brown Out Detector) to 1.8V.

Ideally i would like to flash a small LED when the battery is almost empty.

http://forum.arduino.cc/index.php?topic=38119.0

I tested measuring the VCC voltage on the ATtiny85 using the bandgap voltage reference.

http://forum.arduino.cc/index.php?topic=156118.msg1175786#msg1175786

If you're not already aware, there are two types of ATtiny85, a "plain" type and a "V" type. I'd be sure to have the "V" part to run on low voltage. From the datasheet:

Speed Grade
– ATtiny25V/45V/85V: 0 – 4 MHz @ 1.8 - 5.5V, 0 - 10 MHz @ 2.7 - 5.5V
– ATtiny25/45/85: 0 – 10 MHz @ 2.7 - 5.5V, 0 - 20 MHz @ 4.5 - 5.5V

Hi guys! Thanks for your replies!

I tested measuring the VCC voltage on the ATtiny85 using the bandgap voltage reference

Im going to try that. Sounds good. So i dont need an extra pin of my Tiny?

Does bandgap measuring cost extra power?

there are two types

It looks like my tiny is working such low voltage. Should that V be printed on the chip itself (or a serial)?

KiwiFreaK:
Does bandgap measuring cost extra power?

The ADC needs power, yes. Luckily for us Atmel thought of that and you can turn parts of the chip on/off on demand.

The AVR standard library has functions for this:

http://www.nongnu.org/avr-libc/user-manual/group__avr__power.html

If you're using batteries you should turn off the parts of the chip you're not using. The ADC converter and Timer1 are the worst power gobblers (see datasheet).

KiwiFreaK:
It looks like my tiny is working such low voltage.

Don't ever depend on "it seems to work". It might be right on the edge of failure and start giving random errors a week from now when the battery voltage drops by 0.01V.

KiwiFreaK:
It looks like my tiny is working such low voltage. Should that V be printed on the chip itself (or a serial)?

It should say "ATtiny85V" on the chip.

Thanks! Tonight I hope to play around with this ADC thing... :slight_smile:

It should say "ATtiny85V" on the chip.

I think I don't have the Attiny85V,... My chip says: "1304 Attiny85 20PU". Without a "V". So I think I've to add an extra battery. I'll hope this will solve my instability...

Set the BOD (Brown Out Detector) to 1.8V.

What can I achive with the BOD?

KiwiFreaK:
Set the BOD (Brown Out Detector) to 1.8V.

First, a correction... The cutoff voltage will have to be higher for the non-V processor.

What can I achive with the BOD?

When the voltage is below the cutoff, the processor is held in reset. You haven't said anything about your project so it's impossible to know if using the BOD is or is not appropriate.

He said he wanted to flash a LED when it was getting close to death.

fungus:
He said he wanted to flash a LED when it was getting close to death.

Is there some part of this you did not understand...

KiwiFreaK:
I would like to turn it off, when the voltage become too low.

The BOD would be used to keep the device off "after death" (once the battery level is too low for the device to operate reliably).

Thanks for responses. Let me clarify it a little bit.

About my project; its rather simple:
I read analog values (on a tiny85 without V), set some leds via a shift register depending on those analog values. I run the project on batteries. Ive hooked some small solar cells to my batteries. what is working fine.

The issue comes here, when the batteries are becoming empty (under a certain voltage) my leds starts to flash randomly and it stops working (stable).

A solution for me could be to measure the internal tiny voltage and light up a small led that indicates the power is (almost) down. So the rest of the project features should be turned off. When there is power again, the project should continue and the battery led should switched off.

So, i want to avoid a state of...starting, resetting,failing directly because of the power.

BOD would be used to keep the device off

How can I program to turn it on again when there is power?

KiwiFreaK:

BOD would be used to keep the device off

How can I program to turn it on again when there is power?

Not necessary. Once the voltage is higher then the cutoff (with some hysteresis) reset is released and the processor runs.

Sounds good. When I understood right; With the BOD i should be able to turn my tiny off. My Board name (in arduino) says "BOD disabled" does that matter?

How can I set the BOD? Do you have a code sample?

Last question; what do you suggest as the lowest 'good' voltage?

KiwiFreaK:
Last question; what do you suggest as the lowest 'good' voltage?

Do you want to run the processor within the Atmel specifications?

What clock speed will you be using? 1 MHz? 8 MHz? 16 MHz?

im running 8Mhz

I will assume the answer to the first question is "yes".

According to the datasheet, at 8 MHz you can run the non-V processor down to the minimum voltage of 2.7. According to the Engbedded fuse calculator... AVR® Fuse Calculator – The Engbedded Blog ...the BOD can be configured for 2.7 volts. Perfect. You can use a BOD setting of 2.7 volts.

From the boards.txt file... Google Code Archive - Long-term storage for Google Code Project Hosting. ...the ATtiny85 @ 8 MHz (internal oscillator; BOD disabled) board has fuses of E2, D7, FF. Plug those into the fuse calculator, change the BOD option to 2.7, and we get... E2, D5, FF. You need a board entry with those fuse settings.

Locate and open boards.txt using a text editor. Locate, select, and copy the ATtiny85 @ 8 MHz (internal oscillator; BOD disabled) board entry. Navigate to the bottom of boards.txt and paste. Change the board name from attiny85at8 to something unique; I'll use KiwiFreaKBoard1. Change the name to something descriptive; I'll use ATtiny85 @ 8 MHz (internal oscillator; 2.7 V BOD). Change the fuses to the values above. Save and close boards.txt. Close and reopen the Arduino IDE. Select the new board. Execute Tools / Burn Bootloader to change the fuses. Enjoy.

###########################################################################

KiwiFreaKBoard1.name=ATtiny85 @ 8 MHz (internal oscillator; 2.7V BOD)

# The following do NOT work...
# KiwiFreaKBoard1.upload.using=avrispv2
# KiwiFreaKBoard1.upload.using=Pololu USB AVR Programmer

# The following DO work (pick one)...
KiwiFreaKBoard1.upload.using=arduino:arduinoisp
# KiwiFreaKBoard1.upload.protocol=avrispv2
# KiwiFreaKBoard1.upload.using=pololu

KiwiFreaKBoard1.upload.maximum_size=8192

# Default clock (slowly rising power; long delay to clock; 8 MHz internal)
# Int. RC Osc. 8 MHz; Start-up time PWRDWN/RESET: 6 CK/14 CK + 64 ms; [CKSEL=0010 SUT=10]; default value
# Brown-out detection level at VCC=2.7 V; [BODLEVEL=101]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

KiwiFreaKBoard1.bootloader.low_fuses=0xE2
KiwiFreaKBoard1.bootloader.high_fuses=0xD5
KiwiFreaKBoard1.bootloader.extended_fuses=0xFF
KiwiFreaKBoard1.bootloader.path=empty
KiwiFreaKBoard1.bootloader.file=empty85at8.hex

KiwiFreaKBoard1.build.mcu=attiny85
KiwiFreaKBoard1.build.f_cpu=8000000L
KiwiFreaKBoard1.build.core=tiny

###########################################################################

Edit: Corrected for the ATtiny85

Thanks for the reply!!

Do you want to run the processor within the Atmel specifications?

I will assume the answer to the first question is "yes".

...uh, yes.

ATtiny84 @ 8 MHz (internal oscillator; BOD disabled)

Right now I'm working with the ATtiny85. Does that matter? I know it's just the name there...

and we get... E2, D5, FF

Where do you get those hex-fuse settings? They don't change in my browser:

  1. Attiny85
  2. Int. RC Osc. 8Mhz (default)
  3. BOD VCC=2.7V (level 101)
  4. SPI enabled
    I get: 62 DD FF. Is this correct?

(maybe off topic)
Currently I'm also using the sleep mode of the Tiny and waking it with a WDT. Do I need to select it also at the feature configuration?