Final Documentation

61
ABSTRACT Manual operation of school bell / college bell creates lot of disturbances caused by human errors. If the bell operator forgets to ring the bell for a specific period, or delayed to ring the bell, it creates disturbances for entire the institution. All the classes on that day will be completely disturbed. This problem is more present if the bell operator is on leave. Automatic Periodic College Bell is the only solution to avoid all these problems. This project is very useful in schools, colleges and educational / academic institutions for automation of periodic class bell. This bell rings only at preprogrammed timings. As the DS1307 Real Time Clock chip is used, entire the calendar can be programmed into the microcontroller. User can program the bell to ring the bell from morning to evening and not to ring in after school hours and on Sundays and Second Saturdays. Switches are provided for entering the required timings. LCD displays are provided to display the alarm times and current time. DS1307 is interfaced to the microcontroller for real timing performance. A 3V battery 1

Transcript of Final Documentation

Page 1: Final Documentation

ABSTRACT

Manual operation of school bell / college bell creates lot of disturbances caused

by human errors. If the bell operator forgets to ring the bell for a specific period, or

delayed to ring the bell, it creates disturbances for entire the institution. All the classes on

that day will be completely disturbed. This problem is more present if the bell operator is

on leave. Automatic Periodic College Bell is the only solution to avoid all these

problems. This project is very useful in schools, colleges and educational / academic

institutions for automation of periodic class bell. This bell rings only at preprogrammed

timings. As the DS1307 Real Time Clock chip is used, entire the calendar can be

programmed into the microcontroller. User can program the bell to ring the bell from

morning to evening and not to ring in after school hours and on Sundays and Second

Saturdays. Switches are provided for entering the required timings. LCD displays are

provided to display the alarm times and current time. DS1307 is interfaced to the

microcontroller for real timing performance. A 3V battery can be connected to DS1307 to

avoid time disturbances caused by power failures.

External EPROM is used to store the timings. Data stored remains in the memory

even after power failure, as the memory ensures reading of the latest saved settings by the

micro controller. It can retain data for more than ten years. This project uses regulated

5V, 500mA power supply. Unregulated 12V DC is used for relay. 7805 three terminal

voltage regulator is used for voltage regulation. Bridge type full wave rectifier is used to

rectify the ac out put of secondary of 230/12V step down transformer.

1

Page 2: Final Documentation

CONTENTS

1. INTRODUCTION 05

2. PROBLEM DOMAIN 06

3. DESCRIPTION OF COMPONENTS 07

3.1 Hardware Components 08

3.1.1 89s51 Micro Controller 08

3.1.2 Switch 08

3.1.3 Battery 08

3.1.4 DS 1307 RTC 08

3.1.5 LCD 09

3.1.6 Voltage Regulator 09

3.1.7 Flter 10

3.2 Software Components 10

3.2.1 KEIL Compiler 10

3.2.2 PROLOAD 10

4. HARDWARE IMPLEMANTATION 11

4.1 Block Diagram 11

4.2 Circuit Diagram 12

5. SOFTWARE IMPLEMENTATION 13

5.1 Flow Chart 13

5.2 Program 14

2

Page 3: Final Documentation

5.2.1 LCD Program 28

5.3 Debugging using KEIL u Vision3.0 40

5.4 PROLOAD 41

5.4.1 Description 42

5.4.2 Programming Software 43

5.4.3 Features 44

6. WORKING 45

7. RESULT 46

8. CONCLUSION & FUTURESCOPE 47

9. BIBLOGRAPHY 47

3

Page 4: Final Documentation

LIST OF FIGURES

3.1.5 LCD Display 09

4.1 Automatic College Bell Block Diagram 11

4.2 Circuit Diagram 12

5.1 Flow Chart 13

5.2 Compilation of Source Code 40

5.3 Run the Compiled Program 41

5.4 ATMEL 8051 Dervice Programmer 42

5.5 Steps involved in Programming 43

5.6 Writing the Program bytes onto the Microcontroller 44

LIST OF TABLES

3.1 Hardware Components 08

4

Page 5: Final Documentation

1. INTRODUCTION

An embedded system can be defined as a computing device that does a specific

focused job. Appliances such as the air-conditioner, VCD player, DVD player, printer,

fax machine, mobile phone etc. are examples of embedded systems.Each of these

appliances will have a processor and special hardware to meet the specific requirement of

the application along with the embedded software that is executed by the processor for

meeting that specific requirement. The embedded software is also called “firm ware”.

The desktop/laptop computer is a general purpose computer.

You can use it for a variety of applications such as playing games, word

processing, accounting, software development and so on. In contrast, the software in the

embedded systems is always fixed listed below:

Embedded systems do a very specific task; they cannot be programmed to do

different things. Embedded systems have very limited resources, particularly the

memory. Generally, they do not have secondary storage devices such as the

CDROM or the floppy disk. Embedded systems have to work against some

deadlines. A specific job has to be completed within a specific time. In some

embedded systems, called real-time systems, the deadlines are stringent. Missing

a deadline may cause a catastrophe-loss of life or damage to property. Embedded

systems are constrained for power. As many embedded systems operate through a

battery, the power consumption has to be very low.

Some embedded systems have to operate in extreme environmental conditions

such as very high temperatures and humidity.

Embedded systems are specially designed and developed to solve a Real time

issue in our practical life, which eases our work and reduces the strain. They are

dedicated devices and are highly application specific.

Our project is one such an embedded system which is introduced to solve one of

such a real-time issue

5

Page 6: Final Documentation

2.PROBLEM DOMAIN

Now-a-days the schools and colleges are run with a tight,busy and dynamic

schedules.It is often difficult to maintain an alarm particularly where there is always a

change in schedules.A dedicated person must be hired for this purpose who is responsible

to make sure that the alarm rings as per the intimated schedule.

Our project AUTOMATIC COLLEGE BELL is the best device which serves

the purpose of a special person hired for ringing the alarm.

The key Features of the device is :

It is multiple programmable device

Users Friendly

Total 7 time intervals can be given simultaneously in the single

attempt

Works even when there is no power supply as it runs through a

battery power

This is intented for the institutions which maintain dynamic

schedules and hence the alarm timings on a particular day can also

be set in advance

6

Page 7: Final Documentation

3. DESCRIPTION OF COMPONENTS

3.1 Hardware Components:

S. NO. NAME OF COMPONENTS

TYPE QUANTITY

1. 89S51 Microcontroller 1

2. IC DS 1307 Real Time Clock

1

3. IC 7805 Voltage Regulator 5V 1

4. Transformer Step-Down 1

5. Crystal 11.0592 MHz32.768KHz

11

6. Diode 1N4700 4

7. Resistor 10k 8.2k330

211

8. Storage Capacitor 100 µF 10 µF 104pf

111

9. Ceramic Capacitor 33 pF 2

10. LED General 1

11. Lcd Display 16*2 1

12. Switches 4

13. Buzzer 6-12 V operated 1

7

Page 8: Final Documentation

3.1.1 89S51 Micro Controller:

Microprocessors and microcontrollers are widely used in

Embedded systems products. Microcontroller is a programmable device. The

microcontroller used in this project is AT89S51. Atmel Corporation introduced this

89S51 microcontroller. The present project is implemented on Keil Uvision. In order to

program the device, proload tool has been used to burn the program onto the

microcontroller.

3.1.2 Switch:

There are four switches used here in our project. The ENTER switch is used to

enter the data like time, date, day. The SET switch is used to set the data which is already

stored in the LCD. The INCREMENT switch is used to increase the value by one. The

DECREMENT switch is used to decrease the value by one.

3.1.3 Backup battery:

A backup battery provides power to a system when the primary source of power is

unavailable. Backup batteries range from small single cells to retain clock time and date

in computers, up to large battery room facilities that power uninterruptible power

supply systems for large data centers. Small backup batteries may be primary cells;

rechargeable backup batteries are kept charged by the prime power supply.

3.1.4 DS 1307 RTC:

The real time clock (RTC) is a widely used device that provides accurate time and

date for many applications. The RTC chip present in the PC provides time components of

hour, minute and second in addition to the date/calendar components of year, month and

day. The DS1307 serial real-time clock (RTC) is a low power, full binary-coded decimal

(BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred

serially through an I2C, bidirectional bus. The clock/calendar provides seconds, minutes,

hours, day, date, month, and year information. The end of the month date is automatically

adjusted for months with fewer than 31 days, including corrections for leap year. The

clock operates in either the 24-hour or 12-hour format with AM/PM indicator. The

DS1307 has a built-in power-sense circuit that detects power failures and automatically

switches to the backup supply. Timekeeping operation continues while the part operates

from the backup supply.

8

Page 9: Final Documentation

3.1.5 LCD:

LCD stands for Liquid Crystal Display. LCD is finding wide spread use replacing

LEDs (LCD LEDs or other multi segment LEDs) because of the following reasons:

1. The declining prices of LCDs.

2. The ability to display numbers, characters and graphics. This is in contrast to

LEDs, which are limited to numbers and a few characters.

3. Incorporation of a refreshing controller into the LCD, thereby relieving the CPU

of the task of refreshing the LCD. In contrast, the LED must be refreshed by the

CPU to keep displaying the data.

4. Ease of programming for characters and graphics.

These components are “specialized” for being used with the microcontrollers,

which means that they cannot be activated by standard IC circuits. They are used for

writing different messages on a miniature LCD.

Fig 3.1 LCD display

3.1.6 Voltage Regulator:

As the name itself implies, it regulates the input applied to it. A voltage regulator

is an electrical regulator designed to automatically maintain a constant voltage level. In

this project, power supply of 5V and 12V are required. In order to obtain these voltage

levels, 7805 and 7812 voltage regulators are to be used. The first number 78 represents

positive supply and the numbers 05, 12 represent the required output voltage levels.

9

Page 10: Final Documentation

3.1.7 Filter:

Filter removes the ripples from the output of rectifier and smoothens the D.C.

Output received from this filter is constant until the mains voltage and load is

maintained constant. Capacitive filter is used in this project .However, if either of the two

is varied, D.C. voltage received at this point changes. Therefore a regulator is applied at

the output stage.

3.2 SOFTWARE COMPONENTS:

3.2.1 KEIL Compiler:

KEIL compiler is a software used where the machine language code is written and

compiled. After compilation, the machine source code is converted into hex code which

is to be dumped into the microcontroller for further processing. KEIL compiler also

supports C language code.

3.2.2 PROLOAD:

PROLOAD is a software which accepts only hex files. Once the machine code is

converted into hex code, that hex code has to be dumped into the microcontroller and this

is done by the PROLOAD. PROLOAD is a programmer which itself contains a

microcontroller in it other than the one which is to be programmed. This microcontroller

has a program in it written in such a way that it accepts the hex file from the KEIL

compiler and dumps this hex file into the microcontroller which is to be programmed. As

the PROLOAD programmer kit requires power supply to be operated, this power supply

is given from the power supply circuit designed above. It should be noted that this

programmer kit contains a power supply section in the board itself but in order to switch

on that power supply, a source is required. Thus this is accomplished from the power

supply board with an output of 12volts.

10

Page 11: Final Documentation

4. HARDWARE IMPLEMENTATION

4.1 Block Diagram:

The Automatic college bell consists of an LCD, an 89S51 micro controller,

switches, RTC, battery, crystal oscillator, reset circuit, buzzer & relay.

Figure 4.1 Automatic College Bell Block Diagram

Incr switch

Decr switch

Set switch

Back-upBattery

CrystalDS1307

RTC

Crystal

Reset circuit

Step down T/F

Bridge Rectifier

Filter Circuit Regulator +5V to all sections

+12V to Relay

Buzzer

LCD

8

9

S

5

1

11

Page 12: Final Documentation

4.2 Circuit Diagram:

Figure 4.2 Circuit Diagram

12

Page 13: Final Documentation

5. SOFWARE IMPLEMENTATION

5.1 Flow chart

Figure 5.1 Flow Chart

13

Page 14: Final Documentation

5.2 Program:

SOURCE CODE:RB0 EQU 00H ; Select Register Bank 0RB1 EQU 08H ; Select Register Bank 1 ...poke to PSW to use;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%; PORT DECLARATION;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%SDA EQU P1.1 ;SDA=PIN5SCL EQU P1.0 ;SCL=PIN6DS1307W EQU 0D0H ; SLAVE ADDRESS 1101 000 + 0 TO WRITEDS1307R EQU 0D1H ; SLAVE ADDRESS 1101 000 + 1 TO READs ENTER EQU P1.5INCR EQU P1.6 DECR EQU P1.7RS EQU P3.0RW EQU P3.1 EN EQU P3.2 RELAYS EQU P0 /* THIS IS FOR INBUILT EEPROM */WMCON DATA 96h ; watchdog and memory control registerEEMEN EQU 00001000b ; EEPROM access enable bitEEMWE EQU 00010000b ; EEPROM write enable bitWDTRST EQU 00000010b ; EEPROM RDY/BSY bitDPS EQU 00000100b ; data pointer select bit ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ;DSEG ; This is internal data memory;ORG 20H ; Bit addressable memoryFLAGS DATA 20HLASTREAD BIT FLAGS.0 SQW BIT FLAGS.4ACK BIT FLAGS.5BUS_FLT BIT FLAGS.6_2W_BUSY BIT FLAGS.7 CANCEL BIT FLAGS.1CANCEL1 BIT FLAGS.2 ALARM BIT FLAGS.3BITCNT DATA 21HBYTECNT DATA 22HSECS DATA 24H ; ' SECONDS STORAGE RAMMINS DATA 25H ; ' MINUTES ' 'HRS DATA 26H ; ' HOURS ' 'TIMES DATA 27H ; ' DAY ' ';DATE1 DATA 28H ; ' DATE ' ';MONTH DATA 29H ; ' MONTH ' '

14

Page 15: Final Documentation

TEMP_DPTR DATA 2AH ; ' YEAR ' 'CONTROL DATA 2BH ; FOR STORAGE OF CONTROL REGISTER WHEN READ.ALM_HOUR DATA 2CH ; INTERNAL (ALARM HOURS) STORAGE.ALM_MIN DATA 2DH ; INTERNAL (ALARM MINUTES) STORAGE.ALM_CNTRL DATA 2EH ; INTERNAL STORAGE FOR ALARM (ON) TIME.COUNT DATA 2FHALRM_COUNT DATA 30HHRTEMP DATA 31HMINTEMP DATA 32H BCD_HR DATA 33H BCD_MIN DATA 34H BCD_HR1 DATA 35H BCD_MIN1 DATA 36H STACK DATA 3FH ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%; ***MACRO'S***SCL_HIGH MACRO SETB SCL ; SET SCL HIGH JNB SCL,$ ; LOOP UNTIL STRONG 1 ON SCL ENDM;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%;CSEG AT 0 ; RESET VECTOR;---------==========----------==========---------=========---------; PROCESSOR INTERRUPT AND RESET VECTORS;---------==========----------==========---------=========--------- ORG 00H ; Reset

; ==---------=========---------; Main routine. Program execution starts here.;---------==========----------==========---------=========---------MAIN: MOV PSW,#RB0 ; Select register bank 0 MOV SP,STACK MOV P0,#0 ;Switch OFF relay MOV ALRM_COUNT,#00H

MOV COUNT,#0 MOV TEMP_DPTR,#0

MOV HRTEMP,#00H MOV MINTEMP,#00H

SETB ENTER SETB INCR SETB DECR

/* CLR ALARM MOV TMOD,#01H ;enable timer0 for scanning MOV TL0,#00H MOV TH0,#0FDH SETB ET0 SETB EA

15

Page 16: Final Documentation

SETB TR0 ;Start the Timer */; **********************************************************; INITILIZE RTC ; **********************************************************

SETB SDA ; ENSURE SDA HIGH SCL_HIGH ; ENSURE SCL HIGH CLR ACK ; CLEAR STATUS FLAGS CLR BUS_FLT CLR _2W_BUSY

CLR SQW CALL OSC_CONTROL ; Initialize the RTC ACALL SQW_CONTROL_1HZ

; **********************************************************; INTIALISATION OF LCD ; **********************************************************

MOV DPTR,#COMNDSBACK: CLR A

MOVC A,@A+DPTR JZ MESGE ACALL CMNDWRT ACALL LCD_DELAY INC DPTR SJMP BACK

MESGE: MOV DPTR,#MSG1 ACALL LCD_DISPLAY

ACALL LCD_DELAY MOV A,#0C4H ACALL CMNDWRT ACALL LCD_DELAY MOV DPTR,#MSG2

ACALL LCD_DISPLAY ; **********************************************************; CHECK FOR ENTER THE TIME ; **********************************************************JB ENTER,$ACALL ENTER_TIMETIME_OK: MOV A,#01H ACALL CMNDWRT MOV DPTR,#MSG4 ACALL LCD_DISPLAY MOV A,HRTEMP ;CHANGE

MOV B,#10 DIV AB SWAP A ORL A,B

MOV BCD_HR,A MOV A,MINTEMP ;CHANGE

16

Page 17: Final Documentation

MOV B,#10 DIV AB SWAP A ORL A,B

MOV BCD_MIN,A;(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((; STORE THE TIME TO RTC CHIP ;(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((

LCALL SEND_START ; SEND 2WIRE START CONDITION MOV A,#DS1307W ; LOAD DS1307 WRITE COMMAND LCALL SEND_BYTE ; SEND WRITE COMMAND MOV A,#08H ; SET DS1307 DATA POINTER TO

BEGINNING LCALL SEND_BYTE ; OF USER RAM 08H MOV A,#0AAH ; WRITE BYTE TO ENTIRE RAM SPACE LCALL SEND_BYTE LCALL SEND_STOP ; SEND 2WIRE STOP CONTION

LCALL SEND_START ; SEND 2WIRE START CONDITION MOV A,#DS1307W ; LOAD DS1307 WRITE COMMAND LCALL SEND_BYTE ; SEND WRITE COMMAND

MOV A,#01H ; SET DS1307 DATA POINTER TO BEGINNING LCALL SEND_BYTE ; OF 01H MOV A,BCD_MIN ; SEND MINUTES LCALL SEND_BYTE ; MOV A,BCD_HR ;SEND HOURS CLR ACC.6 ;to select 24hr mode[CHANGE]

LCALL SEND_BYTE LCALL SEND_STOP ; SEND 2WIRE STOP CONDITION

; *********************************************************************; MAIN PROGRAM; ********************************************************************** START_PROGRAM:

MOV COUNT,#00HCALL READ_CLOCK

MOV R1,#26H ;GET HOUR AND DISPLAY MOV A,#0C4HACALL CMNDWRTACALL LCD_DELAYMOV A,@R1LCALL BCD_2_ASCI

MOV A,#':'ACALL DATAWRTACALL LCD_DELAYMOV R1,#25H ;GET MIN AND DISPLAYMOV A,#0C7H

17

Page 18: Final Documentation

ACALL CMNDWRTACALL LCD_DELAY

MOV A,@R1 LCALL BCD_2_ASCI

MOV A,#':' ACALL DATAWRT ACALL LCD_DELAY

MOV R1,#24H ;GET SEC AND DISPLAY MOV A,@R1 LCALL BCD_2_ASCI

ACALL LCD_DELAY;MOV TIMES,#0JNB ENTER,ENTER_ALARAM

CONTINUE:MOV A,#0CH ;CURSOR OFF ACALL CMNDWRT ACALL LCD_DELAY ACALL LCD_DELAY

ACALL LOAD_ALRM ;CHECK ALARAM TIME SJMP START_PROGRAM ENTER_ALARAM:

JNB ENTER,$ ;DEBOUNCEINC TIMESACALL LCD_DELAYMOV A,#01ACALL CMNDWRT ACALL LCD_DELAY

MOV A,#0EHACALL CMNDWRTACALL LCD_DELAY

MOV DPTR,#MSG3 ACALL LCD_DISPLAY

ACALL LCD_DELAY MOV A,#0C4HACALL CMNDWRTACALL LCD_DELAY MOV DPTR,#MSG2

ACALL LCD_DISPLAY MOV HRTEMP,#0 MOV MINTEMP,#0

ACALL ENTER_TIMEJNB ENTER,$ ;DEBOUNCEMOV A,HRTEMP ;CHANGEMOV B,#10DIV ABSWAP A ORL A,B

MOV BCD_HR1,A

18

Page 19: Final Documentation

MOV A,MINTEMP ;CHANGEMOV B,#10DIV ABSWAP A ORL A,B

MOV BCD_MIN1,A MOV A,TIMES

ACALL WRITE_2_EEPROM MOV A,#01

ACALL CMNDWRT ACALL LCD_DELAY ;JB ENTER,$

JJJ:JNB INCR ,ENTER_ALARAMJNB DECR,C11SJMP JJJ

C11:MOV DPTR,#MSG4ACALL LCD_DISPLAYSJMP CONTINUERET

WRITE_2_EEPROM: ;MOV A,COUNT

MOV WMCON,#18H MOV A,TIMES CJNE A,#1,JAG1 ;JNZ XY ;MOV DPL,COUNT MOV DPTR,#01

JMP XYJAG1: CJNE A,#2,JAG2 MOV DPTR,#3;INC COUNT

JMP XY JAG2: CJNE A,#3,JAG3 MOV DPTR,#5;INC COUNT

JMP XYJAG3: CJNE A,#4,JAG4 MOV DPTR,#7;INC COUNT

JMP XYJAG4: CJNE A,#5,JAG5 MOV DPTR,#9;INC COUNT JMP XYJAG5: CJNE A,#6,JAG6 MOV DPTR,#11;INC COUNT

JMP XYJAG6: CJNE A,#7,JAG7 MOV DPTR,#13;INC COUNT

JMP XYJAG7: ;CJNE A,#8,JAG8 MOV DPTR,#15;INC COUNT

;JMP XY

19

Page 20: Final Documentation

XY:;MOV DPL,TEMP_DPTR

MOV A,BCD_HR1 MOVX @DPTR,A

CTHD: MOV A,WMCON ;Check for eeprom finished or not

JNB ACC.1,CTHD INC DPTR MOV A,BCD_MIN1 MOVX @DPTR,A

CTTHD: MOV A,WMCON ;Check for eeprom finished or not

JNB ACC.1,CTTHD INC DPTR MOV WMCON,#08H ; DISable EEPROM WRITE RET

;(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((; CHECK FOR TIME IS EQUAL;(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((LOAD_ALRM:

MOV DPTR,#0100H ORL WMCON, #EEMEN ; enable EEPROM accesses MOVX A,@DPTR MOV B,#02H DIV AB MOV R5,A MOV DPTR,#0001H

REPEAT: MOVX A,@DPTR MOV ALM_HOUR,A INC DPTR MOVX A,@DPTR MOV ALM_MIN,A INC DPTR MOV A,HRS CJNE A,ALM_HOUR,CHKK MOV A,MINS CJNE A,ALM_MIN,CHKK MOV A,SECS ANL A,#01111111B MOV SECS,A MOV A,#00H CJNE A,SECS,CHKK ;Time Is Equal INC ALRM_COUNT

MOV A,ALRM_COUNTCJNE A,#1,LT1

MOV RELAYS,#0FFHJMP JAG

LT1: CJNE A,#2,LT2

20

Page 21: Final Documentation

MOV RELAYS,#0AAHJMP JAG

LT2: CJNE A,#3,T3MOV RELAYS,#10010010BJMP JAG

T3: CJNE A,#4,JAGMOV RELAYS,#0MOV ALRM_COUNT,#0

JAG: ACALL LCD_DELAYACALL LCD_DELAY

ACALL LCD_DELAY ACALL LCD_DELAY ACALL LCD_DELAY ACALL LCD_DELAY ACALL LCD_DELAY ACALL LCD_DELAY ACALL LCD_DELAY ACALL LCD_DELAY ACALL LCD_DELAY ACALL LCD_DELAY ACALL LCD_DELAY ACALL LCD_DELAY ACALL LCD_DELAY ACALL LCD_DELAY ACALL LCD_DELAY ACALL LCD_DELAY ACALL LCD_DELAY ACALL LCD_DELAY /*ACALL LCD_DELAY ACALL LCD_DELAY ACALL LCD_DELAY ACALL LCD_DELAY ACALL LCD_DELAY*/ /*JB ALARM,CHKK

ORL TMOD,#10H ;ENABLE TIMER 0 MOV TL1,#08H MOV TH1,#01H SETB ET1 MOV TIM,#100 SETB TR1 SETB RELAY SETB ALARM */

CHKK: DJNZ R5,REPEAT XRL WMCON, #EEMEN ; disable EEPROM accesses RET

; **********************************************************; SUB SETS THE DS1307 OSCILLATOR; **********************************************************OSC_CONTROL:

21

Page 22: Final Documentation

ACALL SEND_START ; GENERATE START CONDITION MOV A,#DS1307W ; 1101 0000 ADDRESS + WRITE-BIT ACALL SEND_BYTE ; SEND BYTE TO 1307 MOV A,#00H ; ADDRESS BYTE TO REGISTER 00H ACALL SEND_BYTE ; SECONDS REGISTER, ALWAYS LEAVE SETB LASTREAD ; REG 00H-BIT #7 = 0 (LOW) ACALL SEND_STOP ; IF REG 00H-BIT #7 = 1 CLOCK ACALL SEND_START ; OSCILLATOR IS OFF. MOV A,#DS1307R ; 1101 0001 ADDRESS + READ-BIT ACALL SEND_BYTE ; ACALL READ_BYTE ; READ A BYTE FROM THE 1307 CLR ACC.7 ; CLEAR REG 00H-BIT #7 TO ENABLE OSCILLATOR.OSC_SET: PUSH ACC ; SAVE ON STACK ACALL SEND_STOP ; ACALL SEND_START ; MOV A,#DS1307W ; SETUP TO WRITE ACALL SEND_BYTE ; MOV A,#00H ; REGISTER 00H ADDRESS ACALL SEND_BYTE ; POP ACC ; GET DATA TO START OSCILLATOR ACALL SEND_BYTE ; SEND IT ACALL SEND_STOP RET ; **********************************************************; THIS SUB CONTROLS THE SQW OUTPUT 1HZ; **********************************************************SQW_CONTROL_1HZ:

LCALL SEND_START ; SEND START CONDITION MOV A,#DS1307W ; SET POINTER TO REG 07H ON DS1307

LCALL SEND_BYTE MOV A,#07H LCALL SEND_BYTE MOV A,#90H ; SQW/OUT ON AT 1HZ JNB SQW,SQW_SET ; JUMP IF SQW BIT IS ACTIVE MOV A,#80H ; TURN SQW/OUT OFF – OFF HIGH

SQW_SET: LCALL SEND_BYTE LCALL SEND_STOP RET

;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––; THIS SUB CONTROLS THE SQW OUTPUT 32KHZ;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––SQW_CONTROL_32KHZ:

LCALL SEND_START ; SEND START CONDITION MOV A,#DS1307W ; SET POINTER TO REG 07H ON DS1307 LCALL SEND_BYTE MOV A,#07H LCALL SEND_BYTE

22

Page 23: Final Documentation

MOV A,#93H ; SQW/OUT ON AT 1HZ JNB SQW,SQW_SET3 ; JUMP IF SQW BIT IS ACTIVE MOV A,#80H ; TURN SQW/OUT OFF – OFF HIGH

SQW_SET3: LCALL SEND_BYTE LCALL SEND_STOP RET

; **********************************************************; THIS SUB READS ONE BYTE OF DATA FROM THE DS1307; **********************************************************READ_BYTE: MOV BITCNT,#08H ; SET COUNTER FOR 8-BITS DATA MOV A,#00H SETB SDA ; SET SDA HIGH TO ENSURE LINE ; FREEREAD_BITS: SCL_HIGH ; TRANSITION SCL LOW-TO-HIGH MOV C,SDA ; MOVE DATA BIT INTO CARRY RLC A ; ROTATE CARRY-BIT INTO ACC.0 CLR SCL ; TRANSITION SCL HIGH-TO-LOW DJNZ BITCNT,READ_BITS ; LOOP FOR 8-BITS JB LASTREAD,ACKN ; CHECK TO SEE IF THIS IS ; THE LAST READ CLR SDA ; IF NOT LAST READ SEND ACK-BITACKN: SCL_HIGH ; PULSE SCL TO TRANSMIT ACKNOWLEDGE CLR SCL ; OR NOT ACKNOWLEDGE BIT RET; **********************************************************; SUB SENDS START CONDITION; **********************************************************SEND_START: SETB _2W_BUSY ; INDICATE THAT 2-WIRE CLR ACK ; OPERATION IS IN PROGRESS CLR BUS_FLT ; CLEAR STATUS FLAGS JNB SCL,FAULT JNB SDA,FAULT SETB SDA ; BEGIN START CODITION SCL_HIGH CLR SDA ACALL DEELAY CLR SCL RETFAULT: SETB BUS_FLT RET; **********************************************************

23

Page 24: Final Documentation

; SUB SENDS STOP CONDITION; **********************************************************SEND_STOP: CLR SDA SCL_HIGH SETB SDA CLR _2W_BUSY RET; **********************************************************; SUB DELAYS THE BUS ; **********************************************************DEELAY: NOP ; DELAY FOR BUS TIMING RET; **********************************************************; THIS SUB SENDS 1 BYTE OF DATA TO THE DS1307; CALL THIS FOR EACH REGISTER SECONDS TO YEAR; ACC MUST CONTAIN DATA TO BE SENT TO CLOCK; **********************************************************SEND_BYTE: MOV BITCNT,#08H; SET COUNTER FOR 8-BITSSB_LOOP: JNB ACC.7,NOTONE; CHECK TO SEE IF BIT-7 OF SETB SDA ; ACC IS A 1, AND SET SDA HIGH JMP ONENOTONE: CLR SDA ; CLR SDA LOWONE: SCL_HIGH ; TRANSITION SCL LOW-TO-HIGH RL A ; ROTATE ACC LEFT 1-BIT CLR SCL ; TRANSITION SCL LOW-TO-HIGH DJNZ BITCNT,SB_LOOP; LOOP FOR 8-BITS SETB SDA ; SET SDA HIGH TO LOOK FOR SCL_HIGH ; ACKNOWLEDGE PULSE CLR ACK JNB SDA,SB_EX ; CHECK FOR ACK OR NOT ACK SETB ACK ; SET ACKNOWLEDGE FLAG FOR ; NOT ACKSB_EX: ACALL DEELAY ; DELAY FOR AN OPERATION CLR SCL ; TRANSITION SCL HIGH-TO-LOW ACALL DEELAY ; DELAY FOR AN OPERATION RET; **********************************************************; SUB READS THE CLOCK AND WRITES IT TO THE SCRATCHPAD MEMORY; ON RETURN FROM HERE DATE & TIME DATA WILL BE STORED IN THE; DATE & TIME REGISTERS FROM 24H (SECS) TO 2AH (YEAR); ALARM SETTINGS IN REGISTERS 2CH(HRS) AND 2DH(MINUTES).; **********************************************************

24

Page 25: Final Documentation

READ_CLOCK: MOV R1,#24H ; SECONDS STORAGE LOCATION MOV BYTECNT,#00H CLR LASTREAD ACALL SEND_START MOV A,#DS1307W ACALL SEND_BYTE MOV A,#00H ACALL SEND_BYTE ACALL SEND_STOP ACALL SEND_START MOV A,#DS1307R ACALL SEND_BYTEREAD_LOOP: MOV A,BYTECNT CJNE A,#09H,NOT_LAST SETB LASTREADNOT_LAST: ACALL READ_BYTE MOV @R1,A MOV A,BYTECNT CJNE A,#00H,NOT_FIRST MOV A,@R1 CLR ACC.7 ; ENSURE OSC BIT=0 (ENABLED) MOV @R1,ANOT_FIRST: INC R1 INC BYTECNT MOV A,BYTECNT CJNE A,#0AH,READ_LOOP ACALL SEND_STOP RETENTER_TIME: JNB ENTER,$CHECK: MOV A,#0C4H ;MOVE CURSOR TO HOURS POSITION

ACALL CMNDWRT ACALL LCD_DELAY

JNB INCR,HR_INC JNB DECR,HR_DEC

JNB ENTER,ENTER_MINS SJMP CHECK

HR_INC: JNB INCR,$ INC HRTEMP MOV A,HRTEMP

CJNE A,#24,NO_CHANGE MOV HRTEMP,#0NO_CHANGE:MOV A,HRTEMP

ACALL DATA_2_LCD SJMP CHECK

25

Page 26: Final Documentation

HR_DEC: JNB DECR,$ MOV A,HRTEMP

CJNE A,#0,OK SJMP XXOK: DEC HRTEMP

XX: MOV A,HRTEMP ACALL DATA_2_LCD SJMP CHECK

ENTER_MINS: JNB ENTER,$

CHECK1: MOV A,#0C7H ACALL CMNDWRT ACALL LCD_DELAY JNB INCR,MIN_INC JNB DECR,MIN_DEC

JNB ENTER,ENDTIME SJMP CHECK1

MIN_INC: JNB INCR,$ INC MINTEMP MOV A,MINTEMP

CJNE A,#60,NO_CHANGE1 MOV MINTEMP,#0

NO_CHANGE1:MOV A,MINTEMP ACALL DATA_2_LCD SJMP CHECK1

MIN_DEC: JNB DECR,$ MOV A,MINTEMP

CJNE A,#0,OK1 SJMP XX1OK1: DEC MINTEMP

XX1: MOV A,MINTEMP ACALL DATA_2_LCD

SJMP CHECK1ENDTIME: RET CMNDWRT: MOV P2,A

CLR RS CLR RW SETB EN ACALL LCD_DELAY CLR EN RET

LCD_DISPLAY: SS: CLR AMOVC A,@A+DPTR

JZ REACALL DATAWRTACALL LCD_DELAYINC DPTR

26

Page 27: Final Documentation

SJMP SSRE: RET

DATA_2_LCD: MOV R6,A

MOV B,#10DIV ABORL A,#30HACALL DATAWRTACALL LCD_DELAYMOV A,BORL A,#30HACALL DATAWRTACALL LCD_DELAYRET

BCD_2_ASCI:MOV B,ASWAP AANL A,#0FHORL A,#30HACALL DATAWRTACALL LCD_DELAYMOV A,BANL A,#0FHORL A,#30HACALL DATAWRTACALL LCD_DELAYRET

DATAWRT: MOV P2,A SETB RS CLR RW SETB EN ACALL LCD_DELAY CLR EN RET

LCD_DELAY: MOV R2, #250REP2: MOV R3, #50REP1: DJNZ R3,REP1

DJNZ R2,REP2 RET

COMNDS:DB 38H,0EH,01H,06H,80H,0H MSG1: DB "SET CURRENT TIME",0 MSG2: DB "00:00",0 MSG3: DB "ENTER ALARM TIME",0 MSG4: DB "CURRENT TIME",0 END

27

Page 28: Final Documentation

5.2.1 LCD Programming#include<reg51.h>#include<intrins.h>#include "lcddisplay.h"sbit SCL=P2^0; sbit SDA=P2^1;sbit enter = P2^2;sbit dec = P2^3;sbit inc = P2^4;sbit alarm_sw = P2^5;sbit bel = P2^7;void start(void);void write(unsigned char,unsigned char);unsigned char read(unsigned char);void ptos(unsigned char );void stop(void);void delay(unsigned int );void settime(void);unsigned char COUNT,dat,add,hr,min,x,binbyte,B1,B2,B3,digit1,digit2,digit3,digit4;unsigned int i;unsigned char h_break[10],m_break[10],d11,d22,memory,zzz;void delay1(unsigned int itime);unsigned char time[7],temptime[7],alarmcheck,day,type,dispcount=0,dispdata;bit pm=0,pm1,dayselect;void daydisplay(unsigned char); void main(){ unsigned char z; dayselect=0; delay(100); lcd_init(); lcd_init(); msgdisplay("welcome"); lcdcmd(0x0c); z=read(0); if(z==0x80) { start: lcdcmd(0x01); msgdisplay(" SET THE TIME ");

28

Page 29: Final Documentation

type=6; settime(); write(0,0); delay(10); write(1,temptime[1]); delay(10); write(2,temptime[0]); delay(10); for(add=4;add<7;add++) { write(add,temptime[add-1]); delay(10); } write(0x07,0x10); delay(100); write(0x20,0); delay(10); dayselect=1; } delay(300); alarmcheck=read(0x20); timedisp: if(alarmcheck) { d22=0x15; for(d11=0;d11<7;d11++) { h_break[d11]=read(d22++); delay(100); m_break[d11]=read(d22++); delay(100); } }back1: lcdcmd(0x01); msgdisplay("Dt:"); while(1) { lcdcmd(0x04); for(add=0;add<7;add++) {

29

Page 30: Final Documentation

time[add]=read(add); z=time[add]; if(add==0) { lcdcmd(0x04); lcdcmd(0xC9);} if(add==4) { lcdcmd(0x06);

lcdcmd(0x84); } if(add==2) { z=time[2]&(0x60); if(z==0x40) pm1=0; else pm1=1; z=time[2]&0x1f; } B1=z&0x0f; B2=(z&0xf0)>>4; if(add<3) {lcddata(B1+48); lcddata(B2+48); } if(add>3) { lcddata(B2+48); lcddata(B1+48); } if(add<2) lcddata(':'); if((add>3)&&(add<6)) lcddata('/'); delay(5); } lcdcmd(0xca); if(pm1) msgdisplay("pm");

30

Page 31: Final Documentation

else msgdisplay("am");if(dayselect==1) { lcdcmd(0x1); msgdisplay("SELECT DAY: SUN"); while(enter==1) { lcdcmd(0x8d); lcdcmd(0xe); if(inc==0) { while(inc==0); if(day<8) day=day+1; daydisplay(day); } if(dec==0) { while(dec==0); if(day>1) day=day-1; daydisplay(day); } } write(3,day); while(enter==0); dayselect=0; lcdcmd(0x0c); goto timedisp; } lcdcmd(0x8d); daydisplay(time[3]); if(alarmcheck) { if(((time[2]==h_break[0])&&(time[1]==m_break[0])&&(time[0]<5))) { bel=0; lcd_init(); lcd_init(); delay(500);

31

Page 32: Final Documentation

goto back1; } else if(((time[2]==h_break[1])&&(time[1]==m_break[1])&&(time[0]<5))) { bel=0; lcd_init(); lcd_init(); delay(500); goto back1; } else if(((time[2]==h_break[2])&&(time[1]==m_break[2])&&(time[0]<5))) { bel=0; lcd_init(); lcd_init(); delay(500); goto back1; } else if(((time[2]==h_break[3])&&(time[1]==m_break[3])&&(time[0]<5))) { bel=0; lcd_init(); lcd_init(); delay(500); goto back1; } else if(((time[2]==h_break[4])&&(time[1]==m_break[4])&&(time[0]<5))) { bel=0; lcd_init(); lcd_init(); delay(500); goto back1; } else if(((time[2]==h_break[5])&&(time[1]==m_break[5])&&(time[0]<5))) {

32

Page 33: Final Documentation

bel=0; lcd_init(); lcd_init(); delay(500); goto back1; } else if(((time[2]==h_break[6])&&(time[1]==m_break[6])&&(time[0]<5))) { bel=0; lcd_init(); lcd_init(); delay(500);goto back1; } else bel=1; } if(alarm_sw==0) { while(alarm_sw==0); alarmcheck=read(0x20); delay(200); alarmcheck=~alarmcheck; write(0x20,alarmcheck); if(alarmcheck) { lcdcmd(0x01); msgdisplay("ENTER BELL TIMES"); delay(500); memory=0x15; for(zzz=1;zzz<8;zzz++) { lcdcmd(0x01); msgdisplay("ENTR BELL TIME "); lcddata(zzz+48); type=3; settime(); write(memory++,temptime[0]); delay(10); write(memory++,temptime[1]);

33

Page 34: Final Documentation

delay(10); } delay(500); } goto timedisp; } if(enter==0) { lcdcmd(0x01); msgdisplay("SET THE TIME "); while(enter==0); goto start; } } }void settime(void){ unsigned char keycount=0,h,g,d1,d2,cmd,uplimit; lcdcmd(0xC0);if(type==6) msgdisplay("hh:mmAM dd/mm/yr"); else msgdisplay("hh:mmAM "); lcdcmd(0x0e); //cursor blinking while(keycount<type) // to select alarm or current time { h=0; if(keycount==0) { cmd=0xc0; uplimit=12; } else if(keycount==1) { cmd=0xc3; uplimit=59; } else if(keycount==2)

34

Page 35: Final Documentation

{ cmd=0xc5; uplimit=1; } else if(keycount==3) { cmd=0xc8; uplimit=31; } else if(keycount==4) { cmd=0xcb; uplimit=12; } else if(keycount==5) { cmd=0xce; uplimit=99; } else; while(enter==1) { lcdcmd(cmd); while((inc==1)&&(dec==1)&&(enter==1)); //wait till any switch is pressed if(inc==0) { while(inc==0); if(h==uplimit) h=0; h=h+1; }if(dec==0) { while(dec==0); if(h) h=h-1; else h=uplimit;

35

Page 36: Final Documentation

} if(keycount==2) { if(h) { msgdisplay("pm"); pm=1; } else { msgdisplay("am"); pm=0; } } else { g=h; d1=g/10; d2=g%10; lcddata(d1+48); lcddata(d2+48); g=(d1<<4)|(d2%10); temptime[keycount]=g; } } if(keycount==2) lcddata(' ');keycount=keycount+1; while(enter==0); delay(500);}if(pm) temptime[0]= temptime[0]|0x60;else temptime[0]=temptime[0]|0x40; lcdcmd(0x01); // clear the lcdlcdcmd(0x0c); //curser blink off; }void write(unsigned char add,unsigned char dat) { start();

36

Page 37: Final Documentation

ptos(0Xd0); //device addr in write mode// ptos(add); //byte addr// ptos(dat); //data// stop(); }//%%%%%%%%%%%%%%%%%%%% READING FUNCTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%unsigned char read(unsigned char add)

{unsigned char v,i; start();

ptos(0Xd0); //device addr in write mode//ptos(add); //byte addr// _nop_(); start(); ptos(0Xd1); //device addr in read mode// v=0;

SDA=1; for(i=0;i<=7;i++) { SCL=0; _nop_(); _nop_(); SCL=1; v=v|SDA; if(i<=6) v=v<<1; } SCL=0; delay1(100); stop();

return(v); }// ####################################### DATA READING FUNCTION ###################################void daydisplay(unsigned char day){if(day==1) msgdisplay("SUN");elseif(day==2)

37

Page 38: Final Documentation

msgdisplay("MON");elseif(day==3) msgdisplay("TUE");elseif(day==4) msgdisplay("WED");elseif(day==5) msgdisplay("THU");elseif(day==6) msgdisplay("FRI");elseif(day==7) msgdisplay("SAT");else;} //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ START FUNCTION $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ void start(void)

{ SCL=1; SDA=1; _nop_(); _nop_(); SDA=0; SCL=0;}

//aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa DATA SENDING TO EEPRAM IN READ MODE AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

void ptos(unsigned char a) {

unsigned char i,c; for(i=0;i<=7;i++) { c=a&128;

if(c==0) SDA=0; else

38

Page 39: Final Documentation

SDA=1; SCL=1;

_nop_(); _nop_(); SCL=0;

a=a<<1; } SDA=1; _nop_(); _nop_(); SCL=1; _nop_(); _nop_(); SCL=0; }

//SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS STOP FUNCTION SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSvoid stop(void)

{ SDA=0; SCL=1; _nop_(); _nop_(); SDA=1; SCL=0;

} void delay1(unsigned int itime){unsigned int i,j;for(i=0;i<itime;i++)for(j=0;j<3;j++);}

5.3 Debugging Using KEIL u Vision 3.0 and PROLOAD V4.0KEIL Compiler:

Keil compiler is software used where the machine language code is written and

compiled. After compilation, the machine source code is converted into hex code which

is to be dumped into the microcontroller for further processing. Keil compiler also

supports C language code.

39

Page 40: Final Documentation

Fig 5.2 Compilation of Source Code

40

Page 41: Final Documentation

Fig 5.3 Run the Compiled Program

5.4 PROLOAD:

Proload is software which accepts only hex files. Once the machine code is

converted into hex code, that hex code has to be dumped into the microcontroller and this

is done by the Proload. Proload is a programmer which itself contains a microcontroller

in it other than the one which is to be programmed. This microcontroller has a program in

it written in such a way that it accepts the hex file from the Keil compiler and dumps this

hex file into the microcontroller which is to be programmed. As the Proload programmer

kit requires power supply to be operated, this power supply is given from the power

supply circuit designed above. It should be noted that this programmer kit contains a

power supply section in the board itself but in order to switch on that power supply, a

source is required. Thus this is accomplished from the power supply board with an output

of 12volts.

Fig 5.4 ATMEL 8051 Device Programmer

5.4.1 Description

It is simple to use and low cost, yet powerful flash microcontroller programmer

for the Atmel 89 series. It will Program, Read and Verify Code Data, Write Lock Bits,

41

Page 42: Final Documentation

Erase and Blank Check. All fuse and lock bits are programmable. This programmer has

intelligent onboard firmware and connects to the serial port. It can be used with any type

of computer and requires no special hardware. All that is needed is a serial

communication ports which all computers have.

All devices have signature bytes that the programmer reads to automatically

identify the chip. No need to select the device type, just plug it in and go! All devices also

have a number of lock bits to provide various levels of software and programming

protection. These lock bits are fully programmable using this programmer. Lock bits are

useful to protect the program to be read back from microcontroller only allowing erase to

reprogram the microcontroller. The programmer connects to a host computer using a

standard RS232 serial port. All the programming 'intelligence' is built into the

programmer so you do not need any special hardware to run it. Programmer comes with

window based software for easy programming of the devices.

42

Page 43: Final Documentation

Fig 5.5 Steps Involved in Programmer

5.4.2 Programming Software

Computer side software called 'Proload V4.1' is executed that accepts the Intel HEX

format file generated from compiler to be sent to target microcontroller. It auto detects

the hardware connected to the serial port. It also auto detects the chip inserted and bytes

used. Software is developed in Delphi 7 and requires no overhead of any external DLL.

Fig 5.6 Writing the Program Bytes onto the Micro Controller

5.4.3 Features

Supports major Atmel 89 series devices

Auto Identify connected hardware and devices

Error checking and verification in-built

Lock of programs in chip supported to prevent program copying

20 and 40 pin ZIF socket on-board

43

Page 44: Final Documentation

Auto Erase before writing and Auto Verify after writing

Informative status bar and access to latest programmed file

Simple and Easy to use

Works on 57600 speed

6. WORKING

Embedded Periodic School Bell using AT89S51 Microcontroller is an exclusive

project in terms of saving the electrical power up to some extent. It also eliminates man

power up to the maximum extent.

The working of this project starts when the school bell has to be rung. Before the

advent of this product, a person used to operate the bell manually for a specific period.

Sometimes there might be a chance that the operator may forget to operate the bell at that

particular time which may cause inconvenience to the entire institution and this problem

becomes worse when the operator is on leave. To avoid all these, we developed a product

Embedded Periodic School Bell.

In this, we use AT89S51 Microcontroller to perform all these tasks. As the bell

has to be operated at predefined timings, we need to store these timings in our

microcontroller for which we will be using the EEPROM. It is also required to calculate

the current time. For this purpose, we use an IC called Real Time Clock (RTC DS 1307).

This current time is compared with the predefined timings stored in the external

EEPROM 24C04...

The bell will be connected to one of the microcontroller port pins through relay.

Thus to operate the bell, the relay should be switched on. This relay is connected to the

microcontroller through transistors or ULN driver as the microcontroller cannot drive the

bell directly.

44

Page 45: Final Documentation

To ring the bell at different timings, we enter different alarm times in the

microcontroller. Here, we are operating the bell at eight different timings. Thus these

eight timings are entered through the switches-enter switch, increment switch and

decrement switch. The alarm times are stored in the EEPROM and the microcontroller

accepts the current time from the RTC continuously. These timings are displayed on the

7-segment displays provided on the system board. The program in the microcontroller

will be written in such a way that the bell rings for a specific duration at predefined alarm

times. Thus when the current time approaches the first alarm time, the bell rings for a

certain duration (may be 10 sec) and stops ringing and again when the current time

approaches the second alarm time, the bell rings for a specified duration. In the similar

fashion, the bell rings whenever the current time equals the predefined alarm times. With

RTC, we can store the entire calendar into the microcontroller. Thus, it is also possible to

operate the bell from morning to evening and not to ring after school hours and on

Sundays and Second Saturdays. This is very much important because the operator may

forget to switch off the system on weekends or holidays.

The user can change these preprogrammed timings according to his requirements.

Therefore, with this project there is no chance for any disturbances while the classes are

going on and human involvement is almost completely eliminated in operating the system

unless the user wishes to change the preprogrammed timings to operate the bell

7. RESULT

45

Page 46: Final Documentation

The automatic college bell has been successfully implemented and tested.

8. CONCLUSION AND FUTURE SCOPE

The designed equipment is working properly. And it applicable to the schools, colleges,

more educational institutions, offices, factories, and etc..It can be enhanced to use it for many

more applications in the future without any major modifications. This project was a

overall success. The specifications originally suggested were met, and others were added to

future improve the design and functioning of the device.

In this project modify the more applications using a microcontroller

1. It can be used in the college, school for belling purpose.

2. It can be used in the any type of examination for belling because we can set

46

Page 47: Final Documentation

the ringing time.

3. Automatic scheduling of college bell is possible.

4. Compact in size so takes less space.

5. Time editable facility is available.

9. BIBLOGRAPHY9. BIBLOGRAPHY

www.8051projects.info

www.en.wikipedia.org

www.alldatasheet.com

www.datasheetcatalog.com/datasheets_pdf/7/8/0/5/7805.shtml

8051 Microcontroller and Embedded Systems by Mazidi and Mazidi

Applied Electronics by R. S. Sedha

47