Reklama

Asynchronous mode Atmega16. Power-save mode.

I decided to write a program to automatically close doors in the unit dormitory after 24:00 microcontroller.
Actually I was faced with a huge number of pitfalls, and since articles in order to remove the stones I found, but only an educated bet and articles on foreign websites reached the correct actions, and now that you describe. The mechanisms work, I will not describe. There is nothing complicated. Most in my opinion difficult for me as a beginner will be described in this article.

Job : To make asynchronous clock, to work from one battery of type CR2032 with the fact that the MC needs to sleep sweet sleep and not to eat honey for us current, and when 0:00 the microcontroller woke up changed the state of the legs (gave impetus to the unit and put in zero to e. castle turned) and in 6:00 am back opened, and went to bed. Watch if this work were not behind not on one dolinecount. Imagine the consequences if the mechanism will operate for years, and in the morning not to go outside.

So let us begin. I have a MK Atmega16a-pu (actually almost the same as Atmega16) and with it, the whole scheme will be managed. To enable asynchronous mode we need not only software code, but bought on the radio market Quartz resonator 32 768 Hz I type “match”, can buy any type. You need to connect it to pins 28 and 29 on the site.
So I marked the pins 12 and 13, for added stability you can connect the quartz 4 MHz. And set the fuse bits for external RC oscillator, but it is according to your taste and need. But the fact that the scheme will become more stable and correct it for sure.

Well, there seems to be all on the technical side. We now go to program.

Such action, we have made meager use of electricity, according to my calculations, a battery with 220mA СR2032 will run one year without replacement and recharging. If you connect another power source, for example two double-a batteries, with 2500 mA then you can imagine how much the scheme will work :)

In my code everything described so, so you saw when he came out of sleep. The signal is not in 24:00 and 6:00, and so that you feel everything is clearly visible. To change the program and make it fully operational need to slightly tweak the code. But I think it will not be difficult.

Good luck ! Hope I helped you !

 
 
Was it used for: Atmel Studio 6.0, khazama avr programmer, programmer - usbasp.

Reklama