How to make a low-voltage cutoff w/ ATtiny85

Thread Starter

LikeTheSandwich

Joined Feb 22, 2021
164
I'm going to use an ATtiny85 for a project running from a lithium battery. It's a relatively high-power project (up to 4A at times) so I was going to use a MOSFET as a switch, and have the ATtiny control the MOSFET. I want it to shut off at a certain voltage for low-voltage protection on the battery. I've seen on the 85's spec sheet is has Vcc, or internal reference voltages of 2.56 (needs 3V minimum for this), or 1.1V. I want it to turn off at 2.5V~2.6V for the batteries I have (they say they're safe to 2.4V, but just want to be a little safer). Would the best way be to accomplish this be to use a voltage divider of appx 40% against the internal 1.1V, and then when it drops below saturation it would know the voltage must be low? Or is there a better way to accomplish this task?
 

BobaMosfet

Joined Jul 1, 2009
2,113
have you looked at the Brown-Out-Detection capabilities...? Section 21.6 in the datasheet. Perhaps there is something there you can rely on internally to the chip, rather than additional circuitry.
 

Thread Starter

LikeTheSandwich

Joined Feb 22, 2021
164
have you looked at the Brown-Out-Detection capabilities...? Section 21.6 in the datasheet. Perhaps there is something there you can rely on internally to the chip, rather than additional circuitry.
That is a really interesting concept, but after reading a little about it, it looks a little complex and over my head at the moment.
 

DickCappels

Joined Aug 21, 2008
10,169
I highly recommend using the internal Brownout Detector because whatever it is that seems to be a little much for you will provide you with a great learning experience. Operation of the Brownout Detector is not exotic and incorporates techniques you will find very useful when using microcontrollers.
 

Thread Starter

LikeTheSandwich

Joined Feb 22, 2021
164
I've read more about it and it's not as daunting as I thought, but I still just don't want to go that route. The closest it has is 2.7V, but I don't want to leave that much room for my application. 2.5 or 2.6V at the most for my application. The other option I thought of would be using a Zener diode with a breakdown voltage of ~2.6V, so when the pin no longer is receiving a voltage that would mean it's below the breakdown and needs to shut off.
 

DickCappels

Joined Aug 21, 2008
10,169
I would not consider a discreet Zener for a battery powered application, but that's me. Discreet Zeners that need less than 5 or 10 ma to reach the specified voltage are rare. I tmight be better to use a resistive divider and connect the bottom of the divider to a rare (on the ATTNY85) I/O pin that is left floating (that will cost a few microamps) and ground several microseconds before taking the measurement.

I just checked an old project. The relevant part of the write-up says"
The "M" command causes the reference voltage measured against VDD to be displayed. If you take off the cover and measure VDD and then execute the "M" command to measure the bandgap using VDD as the reference, you can calculate the bandgap reference voltage. Knowing the bandgap reference voltage, the result of the "M" command can be use to calculate VDD in the future. this makes it possible to see how well the battery is holding up without opening the box.

First find the bandgap voltage (Vref). Measure VDD and measure the bandgap reference with respect to VDD using the "M" command..
Vref = (VDD/255) x Count

Thereafter, the VDD can be calculated by:
VDD = (255 Vref)/Count

In this case VDD is the battery voltage in an ATMEGA48, and the battery was used as the refence voltage, and the bandgap reference was measured to determine the battery voltage, which can be found on the chart below.
1634836268161.png

The cost in terms of battery current for using this technique is a couple hundred microamps for the bandgap reference which is turned on at the time of measurement.
 

Thread Starter

LikeTheSandwich

Joined Feb 22, 2021
164
I would not consider a discreet Zener for a battery powered application, but that's me. Discreet Zeners that need less than 5 or 10 ma to reach the specified voltage are rare. I tmight be better to use a resistive divider and connect the bottom of the divider to a rare (on the ATTNY85) I/O pin that is left floating (that will cost a few microamps) and ground several microseconds before taking the measurement.

I just checked an old project. The relevant part of the write-up says"
The "M" command causes the reference voltage measured against VDD to be displayed. If you take off the cover and measure VDD and then execute the "M" command to measure the bandgap using VDD as the reference, you can calculate the bandgap reference voltage. Knowing the bandgap reference voltage, the result of the "M" command can be use to calculate VDD in the future. this makes it possible to see how well the battery is holding up without opening the box.

First find the bandgap voltage (Vref). Measure VDD and measure the bandgap reference with respect to VDD using the "M" command..
Vref = (VDD/255) x Count

Thereafter, the VDD can be calculated by:
VDD = (255 Vref)/Count

In this case VDD is the battery voltage in an ATMEGA48, and the battery was used as the refence voltage, and the bandgap reference was measured to determine the battery voltage, which can be found on the chart below.
View attachment 250782

The cost in terms of battery current for using this technique is a couple hundred microamps for the bandgap reference which is turned on at the time of measurement.
I do not understand most of what you've said here. Good to know a Zener would cost several mA though, thanks. As for "bandgap," I've not heard that term before today. How would using this method function better than a voltage divider and internal reference compared against battery voltage?
 

DickCappels

Joined Aug 21, 2008
10,169
All
These are the features of a discreet bandgap voltage reference. It works like a Zener but its operating current can be as little as 10 microamps.
1634908336322.png

Similar circuits are used inside many AVR controllers these days.


Further optional reading:
Bandgap Voltage Reference

 

Thread Starter

LikeTheSandwich

Joined Feb 22, 2021
164
All
These are the features of a discreet bandgap voltage reference. It works like a Zener but its operating current can be as little as 10 microamps.
View attachment 250836

Similar circuits are used inside many AVR controllers these days.


Further optional reading:
Bandgap Voltage Reference
So I still don't understand how I could use that exactly, nor how it would be superior to internal Vref and a high resistance voltage divider. I can get the voltage divider current real low using Mohm resistors.
 

DickCappels

Joined Aug 21, 2008
10,169
If you can use the power supply as your reference for the ADC and then measure the bandgap and with respect to that you can determine whether your battery is too low or not.
 

Thread Starter

LikeTheSandwich

Joined Feb 22, 2021
164
If you can use the power supply as your reference for the ADC and then measure the bandgap and with respec to that you can determine whether your battery is too low or not.
Ok, I see. Interesting. I think still I'm better off just using some resistors in the M-ohm range, since I already have them. But thanks for helping me to understand, bandgap is a neat concept.
 

absf

Joined Dec 29, 2010
1,968
I never know what the brownout was for until @DickCappels enlighten me with all the info in this discussion.

Could the TL7757 chip by TI be used as an alternative hardware substitute for the brownout function in mcu?

 

DickCappels

Joined Aug 21, 2008
10,169
Chips like the TL7757 are sometimes called supervisor chips and they do exactly what you referred to. Other brands have a wide variety of threshold voltages available and are very easy to use.

Many microcontrollers have in-built brownout detector circuits saving component count and I/O pins.
 
Top