Brigadoon - An Occasional Corner on the Internet
Arduino Based Weather Station
Designed by Mark Little
"ATMega328/P Datasheet Complete" by Atmel
Next Page
Measuring Using an 16-Bit Counter
Like the 8-bit counter, the 16-bit counter is cleared, incremented or decremented at each count pulse (clkT1), depending on the register settings. The Timer/Counter Overflow Interrupt (TOV1) can be enabled to catch the overflow of the 16-bit counter (TCNT1). Unlike the 8-bit counter, the counter value must be done with two reads, but this is disguised if using the Arduino C/C++ Compiler.

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 (x 65,536) plus the value in TCNT1, alternatively, it could be the counter plus TCNT1, if 65,536 is added each time the rain counter is updated.

For low to normal rainfall locations, the TCNT1 counter is large enough to handle the annual rain fall directly, so if this counter is used, the interrupt will not be required, as it would be in the more general solution that can handle twice the world's maximum average annual rainfall.
Previous  Page