Tuesday, February 23, 2010

Clock - some hints and thoughts

I have reprogrammed the clock-thermometer the first time after soldering it to the breadboard.

In the circuit diagram you can throw away jmp3 and jmp4 and replace them with a common jumper on the mass of D2 and R7.

Because my wall power supply not only outputs 9 V DC but also ~13 V AC, i decided to power the circuit with rechargeable batteries (4*1,2 V).

I thought it could help to change the following line:
degree = (degree * VREF) >> ADC_BITS;
to:
degree = ((degree * 1024) + (degree * 64) + (degree * 8) + (degree * 4)) >> ADC_BITS;

Where ADC_BITS is defined as 10 and VREF as 1100 (mV).
Indeed the code size shrinked from 3132 bytes to 3060 bytes, but the temperature was calculated wrong. The thermometer displayed a negative temperature, although my room was warm.

When i changed the code to:
degree = ((degree * 1024L) + (degree * 64L) + (degree * 8L) + (degree * 4L)) >> ADC_BITS;

The filesize was 3132 bytes again.

As you can see: the AVR GCC port isn't as stupid as you (or me) think. ;)

Happy soldering!

No comments:

Post a Comment