Thursday, 10 August 2017

Learn to Build Real Time Clock using 8051and DS1307 RTC Module

Interfacing RTC Module (DS1307) With 8051 Micro controller In this article, we are going to see how to interface an RTC (Real Time Clock) Module to 8051 micro controller. There are different kinds of RTC module available in the market. We are using the most common RTC module that comes with the DS1307 IC, an LCD module and AT89S52 (8051 variant) for this tutorial. AT89S52 is a typical 8051 microcontroller manufactured by Atmel. Interfacing an RTC module to 8051 microcontroller is pretty simple. You only need to make 2 connections between the RTC module and 8051. So lets get to business! A Real Time Clock module is basically a time tracking device which gives the current time and date. RTC modules that comes with DS3231 IC have the provision to set alarms. Notes On DS1307 RTC Module Here we are using an RTC module with clock chip DS1307 based on I2C protocol (Two Wire Protocol). The module provides details such us second, minute, hour, day of week, day of month, month and year including correction for leap year. It can operate either in 12 Hour or in 24 Hour format. Current consumption of this module is nano ampere range. Even a 3V battery can power it for 10 years maintaining an accurate clock and without any external power. DS1307 has a memory area of 64 bytes of which the first 8 bytes are reserved as RTC register area and the remaining 56 bytes are allotted as general purpose RAM. The details about current, date and time is stored in its register area as Binary Coded Decimals(BCD). The module communicates with the microcontroller using a serial communication protocol called I2C. The I2C bus physically consists of 2 active wires. The wires, called SDA and SCL, are both bi-directional. SDA is the Serial Data line, and SCL is the Serial CLock line. Every device connected to the bus has its own unique device address, no matter whether it is an MCU or RTC module. Each of these chips can act as a receiver or transmitter, depending on the functionality. DS1307 will act as slave in the communication network and controller can only access the slave by initiating a start condition along with a device address. Thereafter, we need to send the register number in order to access the value inside. The interface to the 8051 is simple I2C, with SDA and SCL pins connected to the any two pins of 8051. At the software side we are using a user defined library named “I2C” for I2C communication. This library allows you to communicate with I2C / TWI devices. I hope you understood so far!  Lets get to the circuit diagram! So given below is the circuit diagram to connect RTC module to 8051. Circuit Diagram – RTC Interfacing with 8051   Make the connections as shown!  Now  lets get to the coding part. The Program/Code Explanation  Download Program – Embedded C The program for RTC (Real Time Clock) using 8051 is written in Embedded C (using Keil compiler). We begin by including “LCD8bit” library into the program. It is a user defined library for interfacing microcontroller with LCD module in 8 bit mode. In this library, we included a few functions for initializing LCD, for sending commands and for sending data which is to be displayed. The port which is to be connected to the data pins of the LCD and the pins which is to be connected to the command pins can be configured in the library itself. Here we defined port0 for data pins and P3.5, P3.6, & P3.7 for...
read more

The post Learn to Build Real Time Clock using 8051and DS1307 RTC Module appeared first on Electronic Circuits and Diagram-Electronics Projects and Design.

No comments:

Post a Comment

In major materials breakthrough, team solves a nearly 200-year-old challenge in polymers

Researchers' new polymer strategy shifts a centuries-old engineering paradigm with a molecular design that doesn't sacrifice stretch...