Friday 11 November 2011

Unique Content Article on real time clock module,real time clock

It's about time for microcontrollers


by Ian Harris


Having the ability to tell the present time is a fairly handy feature when you make a microcontroller project. You might, for instance, need to actually display the time as a clock - on an LED display or a LED display panel. Or, you may want to just do something now and then - like turn a watering system on and off at various times of the day. Either way, knowing what the time is essential.

Usually microcontrollers have timers, which can be set to incrementally count on each instruction clock pulse. Timers also have dividers, which slow down the clock effectively, so you can time longer periods. This is a way of timing things that need to be done pretty regularly (for instance, refreshing a display or checking for key input) but the issue with them is they are not very accurate. It is very tricky to get a precise timing for (say) once per second. And if your clock is out by 1% which doesn't sound much, it suggests the particular time you are counting will be out by up to 432 minutes each month!

A better idea is to utilise the option on many microcontrollers of having a second clock source - but in place of using a 20Mhz crystal, a 32,768Hz crystal is employed. Now that number 32,768 might seem a little familiar if you are comfortable thinking in binary. It's a nice number that divides very well by factors of two. So that you can quite accurately get a count of how many seconds have elapsed. Still, you're using timers and must be careful that you reset the timer properly on overflow (otherwise, you may finish up putting additional "time" in each second heartbeat).

The best way is by utilising a seperate real time clock module. These modules, based on the M41T81S or DS1307 (there are several others) lets you query the time down to the millisecond via a two-wire protocol like I2C. These modules commonly have battery back up as well , meaning that even without power the time will continue to be correct. This also suggests that your microcontroller is free to not have to stress about keeping time and can concentrate on doing the actual work you have designed for it.

Using modules that have a specific purpose is a fantastic way of prototyping functional blockss in your project and in this case, also gets you accurate, battery backed time information.




About the Author:





You are receiving this because you signed up for it on 2011-10-03 from IP 203.109.66.181


To fine-tune your selection of which articles to receive, just login here
using your username:


To unsubscribe please use the following link:

Unsubscribe



No comments:

Post a Comment