11/24/2016 at 22:08 •
Today I implemented the basic sleep mode of the Atmega8. My basic idea was to periodicly sample the ADC do check if someone stands on the scale. If yes, turn the whole system on and do a "serious" meassurement.
I got it running fine but the current draw is not really at a point where it should be. Currently the whole circuit uses 22mA in running state and 20mA in sleep mode. With a adoption that the AAA Batteries have 600mAh this circuit would only last >30h!
I think the biggest current draw comes from the rather stupid HD44780 display. The next step is to put a Transistor in between to completly cut the power supply of the HD44780 display in standby.https://kilobyte.ch/scale_sleep.mp4
11/23/2016 at 16:27 •
The Atmega 8 can't do an interrupt through the WDT module. It only can do a direct reset of the whole CPU. So this way to wake up the CPU from the sleep isn't practicable. Another way is to run the timer with an external clock in the sleep mode and generate an interrupt through this. I use a 32.768kHz crystal for this job.
Activated the Asynchronous mode of Timer2
ASSR |= (1<<AS2); TCNT2 = 0x00; OCR2 = 32; TCCR2 = (1<<CS20);
And it seems to work!
11/23/2016 at 15:01 •
For the Hackaday 1kB Project I had to optimize the software quite a bit. The "original" test software to test all together had the size of 2.2kB. Not bad (the Atmega8 has 8kB in total) but not good enough for the 1kB Project.
With some general optimizations I got 2.17kB. Still way to heavy. I've used theconvenient "sprintf" function to generate aString consisting of a static string and a long number for displaying on the display. A big error as I now discover. I changed it to a combination of using the display memory and the "iota" function and came to 850Byte! Perfect!