CURRENT ISSUE

Contests

bottom corner

FEATURE ARTICLE



Issue #216 July 2008

Second Place Microchip 2007 Design Contest
’Net-Enabled Alarm Clock

by DJ Delorie

Start | System Overview | Network | Display | MP3 | ADC | Memory | Power | Software | Time | Alarms | GUI | Remote Protocols | Construction & Packaging | Smart Combinations | Sources & PDF

TIME

Of course, the most important feature of an alarm clock is the clock. I use the built-in real-time clock to keep track of the current time (running off the 32.768-kHz oscillator). One of the configuration bytes in the EEPROM is the calibration setting for the RTC, so you can adjust the “speed” of the clock, if needed.

Rather than expect the user to set the clock each time power is applied (or reapplied after a blackout), the clock uses SNTP to get the current time. SNTP enables you to request the time with a single UDP packet sent to your network’s broadcast address. A single reply packet gives you the time without having to configure an NTP client or keep track of the state of the protocol. The clock checks the time at 30 s past each minute, keeping it within 1 s of the correct time.

The clock does not know about time zones. Another configuration byte keeps track of the offset from SNTP’s UTC zone, but you could have your SNTP server update that byte as needed, without any user interaction. Based on the SNTP time and time zone, the RTC module is updated.

The RTC module interrupts the PIC24FJ64 once per second, sets a flag, and decrements the sleep timer. The next time the RTC’s task runs, it checks the flag to see if the time needs updating. The SNTP socket is always checked. The sleep timer and its display are updated every second. If the minute also changes, the main display is updated and the alarm module is called. In addition, if the photocell value has changed, that forces a main display update. This way, the clock can respond to ambient light changes quickly, without wasting time to redraw the display when it’s not needed. Even though the PIC24FJ64 always runs at full speed, it’s important to leave as much processing power available as possible for streaming the MP3 data.

Previous | Next                *| Subscription Deals |*

 


bottom corner