Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
helloworld5
PostPosted: May 16, 2012 - 06:54 PM
Wannabe


Joined: Jun 23, 2011
Posts: 65


Hello everyone,

I am currently trying to make a backup battery for this design (see attachment) which uses the ATmega8. The circuit is not done so please ignore any wiring that seems odd. I programmed the ATmega8 so that it lights up the LEDs in a certain pattern and the circuit in the attachment seemed to work when I tested it out on a breadboard (took off the main 5V source) but I am just wondering if this is a bad design to use the 5V battery as a backup power source (and if it is, please give me some suggestions). The reason why I need a backup battery is because I will be adding a real time clock on the ATmega8 and I would hate to reconfigure to the right time over and over again.


Thank you.
 
 View user's profile Send private message  
Reply with quote Back to top
Jepael
PostPosted: May 16, 2012 - 07:34 PM
Raving lunatic


Joined: May 24, 2004
Posts: 5994
Location: Tampere, Finland

Well a real solution would be to put a separate real time clock chip that has battery backup pin.

I don't know what your 5V backup battery source really is. But you combine main +5V through diode to AVR VCC, and battery through 100R to AVR VCC. A diode will have a voltage drop, about 0.7V depending on current consumption. To me that looks like the battery is used as the power source when AVR consumes little current, less than 5mA. When AVR consumes more current, more than 10mA, the 100R won't allow that much current and the diode starts to conduct current from main supply.

That, and your AVR does not have all the power supply and ground pins conneted, so it may be fried already.
 
 View user's profile Send private message  
Reply with quote Back to top
helloworld5
PostPosted: May 16, 2012 - 08:04 PM
Wannabe


Joined: Jun 23, 2011
Posts: 65


I guess I can get a tiny series and use UART but I was hoping I could create a circuit so I only use one microcontroller.

As for the backup battery, it will be the small round ones.

I don't quite understand what you mean by the ground pins are not connected. The only ground not connected from the diagram is pin 14 which I haven't finished.

I will check, when I get home, how much current is flowing from the battery when both main and battery source are connected.
 
 View user's profile Send private message  
Reply with quote Back to top
Jepael
PostPosted: May 16, 2012 - 08:48 PM
Raving lunatic


Joined: May 24, 2004
Posts: 5994
Location: Tampere, Finland

helloworld5 wrote:
I guess I can get a tiny series and use UART but I was hoping I could create a circuit so I only use one microcontroller.


I did not mean another microcontroller, I meant a separate dedicated real time clock chip. Those have I2C or SPI bus.

helloworld5 wrote:

As for the backup battery, it will be the small round ones.


There still is no such thing as a 5 volt battery. What kind of batteries and how many?

helloworld5 wrote:

I don't quite understand what you mean by the ground pins are not connected. The only ground not connected from the diagram is pin 14 which I haven't finished.


The AGND and AVCC pins are not connected and it won't work correctly because not all ground and supply pins are properly connected. If you have already built a circuit like in your schematic, the AVR may already be damaged since it did not have all supply pins properly connected.

helloworld5 wrote:

I will check, when I get home, how much current is flowing from the battery when both main and battery source are connected.


OK. You might also need some kind of system to sense if main 5V supply is on or off, so you can go into some kind of battery backup mode where LEDs are kept off and the AVR sleeps a lot, instead of consuming batteries while blazing at full 16 MHz, blinking a lot of LEDs.
 
 View user's profile Send private message  
Reply with quote Back to top
larryvc
PostPosted: May 16, 2012 - 09:44 PM
Raving lunatic


Joined: Dec 06, 2007
Posts: 2512
Location: Redmond, WA USA

Here you go:

http://datasheets.maxim-ic.com/en/ds/DS3231.pdf

_________________
Larry

Those afraid to embrace the future will quickly fade into the past. - larryvc
 
 View user's profile Send private message  
Reply with quote Back to top
helloworld5
PostPosted: May 17, 2012 - 06:15 AM
Wannabe


Joined: Jun 23, 2011
Posts: 65


Wow, never seen one of those but that's pretty cool Very Happy

Anyways, I checked the currents and the main source provides 24 mA and 30 mA (there are 4 LEDs at the moment and when 3 LEDs are used, it uses 24 mA and 30 mA is used when 4 LEDs are on) and the battery source is always at 4.5 mA.

As for the battery, I guess I will be using 2 of the 3 V round batteries.

As for sensing if the main source is on, I was going to hook up a MOSFET to the main source which will be connected to an input pin of the ATmega8 so if it's off, the LEDs will all shut off.


EDIT: Okay, I just realized what you were talking about for AVCC and AGND. I never knew these pins were so important because I never used in any of my projects and never ran into problems with it. What exactly is the disadvantage if you don't use them? And, I'm guessing you just directly connect the AVCC and AGND without any components connected to them. Also, my microcontroller is still programmable and works fine from what I'm seeing.
 
 View user's profile Send private message  
Reply with quote Back to top
JohanEkdahl
PostPosted: May 17, 2012 - 07:44 AM
10k+ Postman


Joined: Mar 27, 2002
Posts: 18545
Location: Lund, Sweden

AVCC is often (always?) the supply for the port where the ADC channels are. Even if the port pins are working as digital I/O pins. More in the data sheet of your controller.

Short advice: Always connect AVCC and AGND, even if the ADC is not used.

(If the ADC is used, and accuracy of the conversions is important, then follow the advice on filtering AVCC etc in the data sheet. If you are sure that you will never use the actual ADC then just connect AVCC to VCC and AGND to GND.)
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
Jepael
PostPosted: May 17, 2012 - 07:53 AM
Raving lunatic


Joined: May 24, 2004
Posts: 5994
Location: Tampere, Finland

helloworld5 wrote:

As for the battery, I guess I will be using 2 of the 3 V round batteries.


That's 6.0 volts. With fresh batteries, even more. The AVR has absolute maximum rating of 6.0V which it does not have to survive. It is specified to work properly up to 5.5V. So between the range of 5.5V to 6.0V, it does not break, but it does not have to work properly.

helloworld5 wrote:

EDIT: Okay, I just realized what you were talking about for AVCC and AGND. I never knew these pins were so important because I never used in any of my projects and never ran into problems with it. What exactly is the disadvantage if you don't use them? And, I'm guessing you just directly connect the AVCC and AGND without any components connected to them. Also, my microcontroller is still programmable and works fine from what I'm seeing.


Disadvantage? It is a miracle it even works at all. And all power pin pairs should have a bypass capacitor connected to them, but on a small hobby system one 100nF per chip might be enough. You don't have any capacitors over any AVR power pins at all!

What might have saved you is that on Mega8, there is a rumour that there is an internal bug and actually AVCC is connected to VCC. Still, it is unwise not to follow datasheet suggestions how to connect pins.

Different power pins may power different internal blocks. On many AVR models the AVCC pin is used to power the IO port where the analog IO pins are (your LEDs), among other things. Leaving AVCC unconnected would result into that port and its IO pins not working at all, and it might even break if too much currents flow through internal silicon structures.

Same thing as overclocking. Not specified to work, but it might.
 
 View user's profile Send private message  
Reply with quote Back to top
helloworld5
PostPosted: May 17, 2012 - 08:32 AM
Wannabe


Joined: Jun 23, 2011
Posts: 65


Jepael wrote:


Disadvantage? It is a miracle it even works at all.




LOL, omg I'm sorry but this just made me laugh haha.

But on a more serious note, I will go over the ATmega8 data sheet because I haven't read any of it other than ADC and PWM registers. I'm still quite new to microcontrollers and I didn't have any time to tinker with them due to finishing my second year in electrical engineering. Feels like I know nothing about electronics even after finishing my second year, lmao.

Also, I will be trying to learn how to use the RTC IC mentioned above instead of using the two round batteries.


Thank you everyone.
 
 View user's profile Send private message  
Reply with quote Back to top
JohanEkdahl
PostPosted: May 17, 2012 - 08:48 AM
10k+ Postman


Joined: Mar 27, 2002
Posts: 18545
Location: Lund, Sweden

Somewhere in my vaults I have a sketch of how to set up a battery backup for an AVR from an ancient discussion here at 'freaks. IIRC it involves two zener-diodes and some other stuff. I'll try to dig it out.

Quote:
Feels like I know nothing about electronics even after finishing my second year, lmao.

I've been programming for some 30+ years. Sometimes it feels like I don't know anything about it. Wink
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
Jepael
PostPosted: May 17, 2012 - 09:21 AM
Raving lunatic


Joined: May 24, 2004
Posts: 5994
Location: Tampere, Finland

helloworld5 wrote:
Feels like I know nothing about electronics even after finishing my second year, lmao.

Thank you everyone.


Heh, my second year in electronics was about ten years ago, and I still feel like I know nothing. Well maybe something about something though Smile

Thank you and best of luck for your projects. From the questions you asked, you seem to be genuinely interested and therefore learn quickly Smile
 
 View user's profile Send private message  
Reply with quote Back to top
Kartman
PostPosted: May 17, 2012 - 02:23 PM
Raving lunatic


Joined: Dec 30, 2004
Posts: 8764
Location: Melbourne,Australia

3v round batteries - that's hardly a precise description! Are we talking about button cells like a CR3025 or similar? Or a cylindrical cell like a 16450 ? with engineering, you want to be precise and read the datasheet.

Your circuit would've been charging the battery when powered externally. Primary lithium cells don't like this.
 
 View user's profile Send private message  
Reply with quote Back to top
larryvc
PostPosted: May 17, 2012 - 05:24 PM
Raving lunatic


Joined: Dec 06, 2007
Posts: 2512
Location: Redmond, WA USA

JohanEkdahl wrote:
I've been programming for some 30+ years. Sometimes it feels like I don't know anything about it. Wink

Sometimes it sounds like it too. Laughing Wink

_________________
Larry

Those afraid to embrace the future will quickly fade into the past. - larryvc
 
 View user's profile Send private message  
Reply with quote Back to top
nleahcim
PostPosted: May 17, 2012 - 05:35 PM
Raving lunatic


Joined: Feb 19, 2003
Posts: 2233
Location: Seattle, WA

On a recent design I had a 5V LDO and a 3V battery as my power sources. I dioded the two supplies together (anode 1 connected to 5V, anode 2 connected to 3V, both cathodes tied to my AVR's supply voltage. During normal operation the device was powered through the diode by 5V. But when the 5V dies the battery kicks in.

I don't see any good reason to pay extra for a Maxim RTC for most applications - doing it onboard the microcontroller is pretty easy.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
clawson
PostPosted: May 17, 2012 - 05:44 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62281
Location: (using avr-gcc in) Finchingfield, Essex, England

I gotta ask. If you are making an AVR design that may need to run from battery why on earth would you use a mega8 and not a mega88PA?

(the P in that stands for PicoPower)

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
JohanEkdahl
PostPosted: May 17, 2012 - 06:39 PM
10k+ Postman


Joined: Mar 27, 2002
Posts: 18545
Location: Lund, Sweden

Quote:
Sometimes it sounds like it too.

Right. I'll be looking out for your next slip, and then it is going to come down hard on you.. Wink

-----

Re the circuit I just plowed though the external disk with all the photos, and found it. Dual supply circuit, battery backup when main supply goes out. With sense on when that happens (on PORTD2 in this case), so that you can take all low-power consumptions you can/need. Sorry, no part numbers for the zeners and transistor.

[EDIT: Uploaded correct picture, with the 1K resistor between transistor and GND... Now, about that shaded pull-up, I really don't know for sure, but probably as an alternative to an internal pull-up.)


Last edited by JohanEkdahl on May 17, 2012 - 06:48 PM; edited 2 times in total
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
larryvc
PostPosted: May 17, 2012 - 06:41 PM
Raving lunatic


Joined: Dec 06, 2007
Posts: 2512
Location: Redmond, WA USA

JohanEkdahl wrote:
Quote:
Sometimes it sounds like it too.

Right. I'll be looking out for your next slip, and then it is going to come down hard on you.. Wink

-----

Re the

That's OK, I can take it too. Very Happy

_________________
Larry

Those afraid to embrace the future will quickly fade into the past. - larryvc
 
 View user's profile Send private message  
Reply with quote Back to top
theusch
PostPosted: May 17, 2012 - 08:14 PM
10k+ Postman


Joined: Feb 19, 2001
Posts: 25904
Location: Wisconsin USA

Quote:

I guess I can get a tiny series and use UART but I was hoping I could create a circuit so I only use one microcontroller.

??? OK, I'll bite--what does that statement have to do with anything said before that?

If power draw is important, why did you start with an older-generation AVR model that is going to be much less power efficient than a replacement e.g. ATmega88PA?
 
 View user's profile Send private message  
Reply with quote Back to top
helloworld5
PostPosted: May 17, 2012 - 08:36 PM
Wannabe


Joined: Jun 23, 2011
Posts: 65


clawson wrote:
I gotta ask. If you are making an AVR design that may need to run from battery why on earth would you use a mega8 and not a mega88PA?

(the P in that stands for PicoPower)


I never really used any other series other than the ATmega8 so I am quite unfamiliar with the other series' characteristics but I'll give it a go once I learn everything about ATmega8.


Kartman wrote:
3v round batteries - that's hardly a precise description! Are we talking about button cells like a CR3025 or similar? Or a cylindrical cell like a 16450 ? with engineering, you want to be precise and read the datasheet.


Sorry for not indicating well but yes, I was going to use the button cell.


nleahcim wrote:
On a recent design I had a 5V LDO and a 3V battery as my power sources. I dioded the two supplies together (anode 1 connected to 5V, anode 2 connected to 3V, both cathodes tied to my AVR's supply voltage. During normal operation the device was powered through the diode by 5V. But when the 5V dies the battery kicks in.

I don't see any good reason to pay extra for a Maxim RTC for most applications - doing it onboard the microcontroller is pretty easy.


That is an interesting design, I'll definitely try this out. But, it seems pretty much like what I was doing before except using a lower voltage battery.


JohanEkdahl wrote:
Re the circuit I just plowed though the external disk with all the photos, and found it. Dual supply circuit, battery backup when main supply goes out. With sense on when that happens (on PORTD2 in this case), so that you can take all low-power consumptions you can/need. Sorry, no part numbers for the zeners and transistor.

[EDIT: Uploaded correct picture, with the 1K resistor between transistor and GND... Now, about that shaded pull-up, I really don't know for sure, but probably as an alternative to an internal pull-up.)


I'll try this out too when I get my hands on some zeners and learn more about them.


theusch wrote:
Quote:

I guess I can get a tiny series and use UART but I was hoping I could create a circuit so I only use one microcontroller.

??? OK, I'll bite--what does that statement have to do with anything said before that?

If power draw is important, why did you start with an older-generation AVR model that is going to be much less power efficient than a replacement e.g. ATmega88PA?


Oh, that was because I was going to have one dedicated ATtiny that had RTC constantly running after the ATmega8 turned off until the other people showed me the RTC IC.

Again, I had no idea about other series' characteristics because I only worked with Atmega8. I knew about tiny series only because my friend showed me how to use UART on it but other than that, I am a total noob with microcontrollers.
 
 View user's profile Send private message  
Reply with quote Back to top
larryvc
PostPosted: May 17, 2012 - 08:44 PM
Raving lunatic


Joined: Dec 06, 2007
Posts: 2512
Location: Redmond, WA USA

helloworld5 wrote:
...but other than that, I am a total noob with microcontrollers.

Welcome to the hobby!!! Smile

_________________
Larry

Those afraid to embrace the future will quickly fade into the past. - larryvc
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits