A time-aware project that I worked on recently was a simple activity timer for my nephew. He’s tasked with practicing piano 30 minutes every evening from 6:30 to 7:00 pm, Monday through Saturday. I use a passive infrared (PIR) detector ($8, Parallax.com) aimed at the area in front of his piano. He can move in and out of the area all day and nothing registers. However, when it’s his normal practice time, a huge event timer starts up and begins counting up when he’s in range of the PIR. I used four massive 6.5” seven-segment LEDs ($15 each, [url=http://www.sparkfun.com]http://www.sparkfun.com[/url]), an Arduino Uno, and a DS1307-based RTC breakout board ($15, SparkFun) to control the display, handle the PIR detector, and keep track of elapsed time.
The display automatically shuts off and resets to zero at 8:00 pm — long enough for my nephew’s parents to verify he was in front of his piano at the specified time. Of course, the timer doesn’t determine the quality of his practice and I suspect he’ll learn to reprogram the Arduino when he’s a year or two older. For now, it’s a good practice tool.
Another time-dependent project is a data logger built around an Arduino, a set of sensors, and a microSD memory card. The data logger — which tracks environmental conditions over time — started as an Arduino connected to my PC and a simple data logging and display program written in Processing ([url=http://www.processing.org]http://www.processing.org[/url]). That was a waste of energy and also limited my ability to work with some applications. Another DS1307-based RTC breakout board, an external power supply, and microSD Shield ($15, SparkFun) freed up my PC for other tasks.
There are several ways of adding time capabilities to a microcontroller-based project, and some microcontrollers have built-in timers. In the RTC chip world, Maxim/Dallas Semiconductor (DS) seems to have the major market share with over 80 RTC chips to choose from. The chips vary in operating temperature range, accuracy, onboard RAM, ability to charge the battery, and need for external components. Some chips require an external capacitor and standard 32.768 kHz crystal oscillator, while others require only five or 3.3 VDC. RTC chips of similar capabilities are also available from Texas Instruments, NXP (Philips), STMicroelectronics, and Intersil.
As noted in the above two projects, I’ve had great results from the DS1307. SparkFun’s breakout board is a little pricy at $15, given an Arduino Pro sells for about $20. However, I’ve found the breakout board to be accurate and reliable in a home environment. According to the spec sheet, accuracy is mainly a function of the crystal and the degree of match between the capacitive load of the oscillator circuit and the capacitive load for which the crystal was trimmed.
The lithium coin cell battery has a theoretical nine year lifetime. Setup is simple — in part because SparkFun ships the RTC set to MST. Changing the date and time — or zeroing the clock for data logging or other timing purposes — involves running a short program. The DS1307 should work with any microcontroller that supports two-wire I2C communications.
An alternative to the DS1307 breakout board is to purchase a DS1302, a 32 MHz crystal, and a capacitor from Parallax for about $7. According to the Parallax forums, the SD1303 is a good option if you already have a battery backup or want to integrate RTC capabilities into a custom printed circuit board. I haven’t used the chip, however.
The DS series of RTCs is great for applications that use time in the standard second, minute, hour, day, month, and year format. If you need higher accuracy than a minute or so a month or if your circuit is exposed to significant variation in temperature, then consider a more capable DS chip such as the DS3234. This surface-mount chip includes an internal temperature-compensated crystal and two alarms. SparkFun sells the bare chip for $10 and an easy-to-use breakout board for $20 — without the coin cell battery.
The list of possible applications for experimentation is virtually endless. You could create an electronic doorbell with an MP3 shield and an RTC chip to produce different chimes for different times of the day. If you like getting up with the sun, you can build an alarm clock that tracks the time of local sunrise, and so is independent of ambient light. If you’re into astronomy, you can add RTC capabilities to your motorized positioning program to auto-track targets, with corrections for local time changes.
For information on the design considerations for RTC chips, check out the technical documents on the Maxim/DS site at [url=http://www.maxim-ic.com]http://www.maxim-ic.com[/url]. Texas Instruments offers documentation and application notes for their BQ series of RTC chips on their site at [url=http://www.ti.com]http://www.ti.com[/url]. NXP (ics.nxp.com) offers a few good white papers on the use of their RTC chips in various applications. The best way to learn about this technology, of course, is to get your hands on a chip and start experimenting. NV