Data pins D0 through D7 of the LCD are connected to port pins P2.0 through P2.7 of microcontroller IC2, respectively. Control pins register-select (RS), read/write (R/W) and enable (E) are connected to port pins P3.5, P3.6 and P3.7, respectively. Preset VR1 is connected to pin 3 of the LCD for contrast control. Power-‘on’ reset is provided by the combination of resistor R2 and capacitor C3. Switch S20 is used for manual reset. An 11.0592MHz crystal along with two 33pF capacitors provides the basic clock frequency to microcontroller IC2.

Fig. 2: An actual-size, single-side PCB for the circuit of RTC-based event logger
Fig. 3: Component layout for the PCB

Download PCB and component layout PDFs: click here

Download source code: click here

A 16-key numeric keypad for time/date entry is connected to port P0 of IC2. To economise on the use of I/O pins, we have used only eight pins for scanning and sensing sixteen keys. The keypad is arranged in a 4×4 matrix. There are four scan lines/pins, which are set in output mode, and four sense keys, which are used as input lines. Switches S17 through S19 are connected to port pins P1.3 through P1.5 of the microcontroller for event logging, display on the LCD and sending to PC’s HyperTerminal, respectively.

Port pins P1.0 and P1.1 of the microcontroller are connected to SDA and SCL lines of IC3, respectively. The microcontroller can write the data to and read from the RTC through SCL and SDA lines. RS232 interface is used to display the data on the PC’s HyperTerminal using USART transmission.

Working of the circuit is simple. When you power-‘on’ the system, you will see messages ‘Welcome’ and ‘EFY Time Logger’ displayed on the first and second lines of the LCD, respectively. After an interval of a second, messages ‘Set Clock’ and ‘Enter Hour’ are displayed on the first and second lines of the LCD, respectively. Enter hours using the numeric keypad. Then it will ask you to enter minutes, seconds, date, month and year one by one. The time and date are displayed on the first and second lines of the LCD after all the entries are done. Pressing of switch S17 is an event, which is stored with date and time in the logs. Last ten logs can be seen on the LCD by pressing switch S18. Last 100 entries can be retrieved using HyperTerminal. Connect the serial port and set up the HyperTerminal. Now if you press S19, the last 100 entries will appear on the HyperTerminal.

Construction and testing

An actual-size, single-side PCB for the circuit of the event logger (Fig. 1) is shown in Fig. 2 and its component layout in Fig. 3. Assemble the circuit on a PCB as it saves time and minimises assembly errors. Carefully assemble the components and double-check for any overlooked error. Use IC bases for the microcontroller and the RTC. Before inserting the ICs, check the supply voltage. Using preset VR1 set the LCD contrast for proper display. To test the circuit for proper working, check the voltages at different points as per Table II.

Software

The source program for the microcontrollers is written in ‘C’ language and compiled using Keil µVision4 compiler. The generated hex code is burnt into the microcontroller by using a suitable programmer. The program is well-commented and easy to understand.

On reset/power-‘on,’ the microcontroller executes the main program. It first initialises variables, baud rate and the LCD, then starts displaying the messages for setting the time and date using start( ) function. Time and date are to be entered from the numeric keypad. Key_scan( ) function scans for key entries. Message ‘Invalid Key’ is displayed on the LCD if any wrong key is pressed. A continuous loop always displays the date and time and checks the status of switches S17 through S19. Function DS1307_get(unsigned char addr) is used to read the time and date, which are displayed on the LCD by function sendlcd(unsigned char value).

When an event occurs (switch S17 pressed), the time and date of the event are saved on the microcontroller’s memory location by data_shift( ) function and message “You are logged” is displayed on the LCD. Switches S18 and S19 are used to display the last ten recorded data on the LCD one by one and the last 100 recorded data on the HyperTerminal. Functions DS1307_settime(unsigned char hh, unsigned char min, unsigned char ss) and DS1307_setdate(unsigned char dd, unsigned char mm, unsigned char yy) are used to set the time and date, respectively.


For more exciting Electronics Projects: click here

SHARE YOUR THOUGHTS & COMMENTS

Please enter your comment!
Please enter your name here