"It ain't over till it's over"... After a week of very cloudy days and mostly no charge, I found out that I needed to save more power and provide some late "adjustments".
The findings and solutions were:
- having a status output every watchdog reset was too much, too often (once every 8 seconds). A more reasonable status output is twice every minute. Displaying the status spent about 0.5% of the total battery capacity, but after an almost full discharge the lamp would only operate for another 2 or 3 days without recharging (i.e. a week of cloudy days was "deadly").
- even during the status display the CPU could be put to sleep during the status output (without using a timer but the watchdog).
- the detection of an external supply had to be changed from above 4.2V to above 4.0V, my external adapter would "kneel" to this voltage when the batteries were depleted.
- the output power levels function of the battery voltage also had to be adapted, even at the lowest level (around 200mA output) the battery voltage "kneels" quite deeply. So in order to take the most of the batteries I reduced the power output once the batteries are in the lowest charge (below 1.1V per element).
- another finding (with no solution as of yet) was that with AVRDUDE I cannot program the oscillator calibration value in FLASH (or EEPROM) automatically (as in AVR Studio). I'm not very "experienced" in script programming or makefiles with scripts but it must be possible. I need to program the flash with the code, then read the oscillator value and finally overwrite the flash (or write in a EEPROM) position where the code is getting this value. Since my program depends on this value for the switching power supply, I cannot be too away from the standard frequency of 1.6MHz.
Meanwhile I also updated my system to OpenSUSE 11.3 (yes, I know the new one is out... but I prefer "stability" over "bleeding edge").
The new code is pasted
hereTa Da for now!