Brigadoon - An Occasional Corner on the Internet
Arduino Based Weather Station
Designed by Mark Little
The ATmega328P used by the Arduino Uno is a low power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture. It has two (2) 8-bit Timer/Counters and one (1) 16-bit Timer/Counter. The block diagram of an 8-bit counter is shown above.
The 8-bit counter is cleared, incremented or decremented at each count pulse (clkTn), depending on the register settings. The Timer/Counter Overflow Interrupt (TOVn) can be enabled to catch the overflow of the 8-bit counter (TCNTn).
While the counter has not overflowed, the operation of the counter does not affect program execution. When an overflow occurs, an interrupt will be generated. It is at this time that the normal program execution is interrupted.
There are a number of counters maintained based on the number of bucket tips. This can include the rainfall rate (a per minute reading), daily rainfall, weekly rainfall, monthly rainfall and annual rainfall. This leaves two options for handling bucket tips. The first is set the counter to trigger an interrupt each time it detects a pulse from the rain gauge. The interrupt would then update each of the counters. While this adds overhead to normal execution of the program, it makes reading the registers very easy.
The alternate way is to set the counter to give an interrupt when the counter overflows. At this stage, it would update the various counters. While this reduces the overhead on the main program, it makes reading the various more complex. The actual value of each of the counters is the value of the counter (x256) plus the value in TCNTn, alternatively, it could be the counter plus TCNTn, if 256 is added each time the rain counter is updated.
Measuring Using an 8-Bit Counter