You are on page 1of 27

OBJECTIVE:

To develop a temperature monitoring for alarm security system To recognize and comprehend the principle and application of analog to digital converter device, ADC0804 To design a sensory base for adaptive alarm system to measure the accuracy data

INTRODUCTION:

Adaptive temperature monitoring for alarm security system is designed for the fire alert which data retrieved from the temperature condition of the surrounding. The system developed to sense and display indoor temperature. When there is the excessive heat that causing the temperature increases up to certain level (i.e equal or higher than 40 C), the system will create an alerted notification by a red light indication. Purpose of this indication is mainly to reduce the injuries or damages to the minimum level. In this project, analog to digital converter ADC0804, temperature sensor LM35, microcontroller AT89C51, LED indicator, LCD display 16X2, and Keil compiler is used.

METHODOLOGY:

The main purposes and objectives of this system to be developed should be outlined as they are the central element of this system to be existed. As for an example, the application of analog to digital converter ADC0804 and microcontroller AT89C51 is main concerned of this project. Then, the title of adaptive temperature monitoring for alarm security system is obtained and decided. The project is divided to several sections and each group members do their part accordingly and researches done based on the part being assigned.

This system consists of two main sections which are software part and hardware part. For the hardware section, the circuit is designed based on the components such as microcontroller

AT89C51, analog to digital converter ADC0804, temperature sensor LM35, LCD display 16X2, and led indicator. The program of microcontroller AT89C51 which is written in Keil compiler is included in software part. Testing process includes hardware compiling and troubleshooting, and source code writing. After successfully tested, a HEX file is executed from the source code and burned into microcontroller AT89C51 through the hardware-programmer board. The functionality of circuit is tested and the expected outcome should be obtained. If it is fail, troubleshooting process will be taken until success. Final chores are report submission and system presentation.
Start

Identify the purpose of project Decide the title of project Distribute the work and task of project

Search for information Hardware: Circuit consist of Sensor, ADC, MCU, LCD display, & Alarm Do the circuit connection on electronic board B Software: firmware of microcontroller

Write c language programming in Keil software

Testing?

If fail, do the troubleshooting Testing? If fail, do the troubleshooting

Success A

Success

Burn HEX file which is written in Keil software into MCU

Testing? If fail, do the troubleshooting Success

Obtain the expected outcome

Do the report Submit report and do presentation

End

Flowchart 1: Methodology of Project Structure

In the hardware design concern, the condition of the system should be identified before researches done on the circuitry designation. Functionalities and the natures of each of the components should be comprehended before designing. This step is taken to strengthen the understanding of the operation and application of each component in circuit. In response to that, circuit is designed with the programmed microcontroller AT89C51. The testing process is to ensure the expected outcomes are achieved. On the other hand, the troubleshooting process is taken to confront the error, failures and the mistake occurred.

Start

Indentify the condition of system Search information for circuit design Search the datasheet and learn the function of each component in circuit

Able to understand circuit operation and application for each component in circuit
Design the circuit on stripboard

Place the AT89C5 with the firmware in the circuit

Testing? If fail, do the troubleshooting Success Obtain the expected outcome

End Flowchart 2: Methodology for Hardware

In the software part, there are two basic tools being used to program the microcontroller which are hardware-programmer board and software for downloading the program. As mention earlier, the compiler used to writing the source is Keil software, which is used to write C language programming source code for the microcontroller.

First of all, the understanding of the C language programming in the way of interfacing the microcontroller with other peripheral devices is vital before do start writing the program. This will benefit to understand the steps of enable and control circuit function (i.e. ADC0804, AT89C51, and LCD display). After the program source code is written, it will then compile to identify the errors and specify the path of file. If the file does not consisting errors, a HEX file is executed. The troubleshooting process is done only if the program source code compiled with errors.

After that, the microcontroller AT89C51 will be programmed with the executed HEX file through the hardware-programmer board. The following step is locating the microcontroller on the circuit board.

Start

Understand and learn programming c language Able to understand the steps of enable and control circuit function

Write the programming in Keil software

Simulate? If fail, do the troubleshooting Success

Obtain the HEX file

Burn the HEX file into microcontroller AT 89C51

Place the microcontroller on the circuit

V
Testing? If fail, do the troubleshooting Success Obtain the expected outcome

End Flowchart 3: Methodology for Software

SYSTEM DESCRIPTION:

Heat source

Sensor, LM 35

Analogto-digital converter, ADC0804

LCD display, 16X2

Microcontroller, AT89C51
LED indicator

Figure 1: Block diagram of the system

In this system, temperature sensor LM35 is used to detect and sense the room environment temperature. Its output voltage is linearly proportional to the Celsius temperature. According to the datasheet of LM35, the sensor will produces an output of 10mV per Celsius. The sensor will detect the temperature and produces analog voltage to the analog to digital converter device, ADC 0804.

Since the output voltage of sensor device, LM 35 cannot directly read by microcontroller, analog-to-digital converter device ADC0804 is required to convert analog input into digital form in bits. The operation of ADC0804 is under controlled by firmware of microcontroller AT89C51. There are three important steps in operation of ADC0804 and shown in below:

Figure 2: Step of start conversion

Figure 3: Step of end of conversion

Figure 4: Step of read the data

Figure 5: Data transmission

After that, the data is transmitted from ADC0804 to microcontroller AT89C51 in parallel. At the same time, the data is saved in memory of microcontroller AT89C51. Then, the firmware also would enable the LCD display function and send the data to LCD display from microcontroller. LCD display would display the data measurement of temperature. There are four important steps in operation of LCD display and shown in below:

Figure 6: Step of command register

Figure 7: Step of enable LCD display

Figure 8: Step of data register

Figure 9: Step of write data on LCD

Additionally, led indicator light would ON in the condition of temperature is equal or higher than 40oC to signify the unusual heat level.

CIRCUIT DESCRIPTION:

In this project, there are four central components are being utilized to build up an adaptive temperature monitoring for alarm security system. They are microcontroller AT89C51, analog-to-digital converter ADC0804, LCD display 16x2, and temperature sensor LM35. In Figure 10, the complete schematic shows the overall system.

Figure 10: Complete schematic of the system

Figure 11: completed circuit

Generally, microcontroller is a tiny computer that integrated in a single integrated circuit (IC) which consists of a processor core, memory and programmable input or output peripherals. In this project implementation, the chores of the microcontroller are to retrieve the data output from the ADC 0804 and undergoing processes to give an output data to the LCD to display the current temperature of surrounding. Besides, it also triggers the siren when certain level of the temperature is being reached. Microcontroller retrieves data from ADC 0804 through 8 pins of the port 1, while transforming output to the LCD through 8 pins of the port 0. In the nature of microcontroller, port 0 does not have the built-in pull-up feature. In response to this situation, the pull-up resistors of the value of 10K need to be added into every pin of the port 0.

An analog-to-digital Converter (ADC) is a component or device that converts the continuous measure into the discrete time digital representation. The role of the ADC in adaptive temperature monitoring for alarm security system is to take the value from the temperature sensor LM 35 in the form of voltage and convert it into the digital measure before forwarding to microcontroller. The values are taken from the VOUT pin of the LM35 through pin 6 of the ADC. Pin 9 of the ADC connected to the potentiometer to give a voltage reference, VREF of 1.28V. With the VREF of 1.28, the step size will be 10mV which mean increase of 10mV received by the ADC0804 will change the output of the ADC by 1 bit. For example, from 0V to 10mV will change the VOUT of ADC from 0000 0000 to 0000 0001. In other word, 0.27V is signifying 27C. To display the course name and the surrounding temperature, LCD 16x2 is used. Pin 7 to pin 14 in the LCD is the data pin which is connected to the port 0 of the microcontroller to retrieve the data that need to be displayed. As discussed earlier, port 0 of the microcontroller does not have the built-in pull-up, so the pull-up resistor of 10K are needed for each pin that being used. The display of the LCD is shown in the Figure 12.

10

Figure 12: Display of course name and the temperature

Temperature sensor, LM35 utilized in adaptive temperature monitoring for alarm security system is to take the analog input which is the temperature of the surrounding and convert it into the output in the voltage form. Basically, it uses a solid-state technique to determine the temperature. In other words, it uses the fact as temperature increases, the voltage across a diode increases at an acceptable rate. Pin in the middle which it the output of the analog voltage is connected to the pin 9 in the ADC0804 which is the VIN(+) pin that retrieve analog input voltage. Pin descriptions of the LM 35 are shown in the Figure 13.

Figure 13: Pin description of LM 35

11

SOFTWARE DESCRIPTION:

Main function
Zero reset for ADC input Indicates 2 lines and 5x7 matrix is used Display on, Cursor off Clear Screen

Low-to-high pulse at WR pin for start conversion

High-to-low pulse at RD pin for data outputs from ADC to microcontroller

Trigger alarm if the temperature more than 40 degree

Figure 14: Main function of programming codes

The main function starts by reading data from ADC by microcontroller. For an ADC 0804, a high bit at CS pin keeps ADC disabled. Therefore, in order to access the ADC this pin always must be low (grounded). A low-to-high pulse at WR pin start converting the analog input

12

value of Vin to an 8-bit digital number. When the data conversion is complete, the INTR pin is forced low by ADC which indicates the end of conversion. Then, the data is read by sending a high-to-low pulse at RD pin of the ADC. When a high-to-low pulse is applied to the RD pin, the 8-bit digital output shows up at the D0-D7 data pins (port 1 of microcontroller). The RD pin is also referred as output enable.

After that, an average temperature is calculated in order to get more accurate temperature. Then, the convert function is called for converting the values of ADC into numeric value to be sent to LCD to display. As this is an alarm system, if the temperature is more than or equal to 40 degree Celsius, the microcontroller will send an output to port 2.2 in order to trigger the LED alarm indicator.

Define usage of microcontroller ports


Define port 3 Define port 1 for ADC input Define port 0 for LCD output Define pin for LCD output command: register select, read / write and enable command Define pin for ADC input command write, read and interrupt command Define port 2 pin 2 for alarm output

Figure 15: Define usage of microcontroller ports

The ADC and LCD are interfaced with microcontroller (AT89C51). This microcontroller has 40 pins with four 8-bit ports (P0, P1, P2, and P3). Here, P0 of microcontroller is used as output port which is connected to data pins of the LCD. The control pins of LCD (pin 4-6) are controlled by pins 0-2 of P3 port in microcontroller. On the other hand, P1 of microcontroller is used as input port which is connected to data pins of the ADC. Signal from analog sensor is input

13

to ADC, ADC which is connected to microcontroller, outputs the digital data through P1 to microcontroller. The pins 3-5 of P3 port in microcontroller is used to control the control pins of ADC (pin 2, 3&5) in order to send the data to microcontroller.

Function of delay

Figure 16: Delay Function This is delay function for system buffer. It is counting in millisecond.

Function to send command to LCD

High-to-low pulse for Enable pin

Figure 17: Function to send command to LCD

In order to send a command on the LCD, a particular command is first specified to the data pins with R/W = 0 (to specify the write operation) and RS = 0 (to select the command register). A high to low pulse is given at EN pin when data is sent.

14

Function to send data to LCD

High-to-low pulse for Enable pin

Figure 18: Function to send data to LCD

In order to send data on the LCD, data is first written to the data pins with R/W = 0 (to specify the write operation) and RS = 1 (to select the data register). A high to low pulse is given at EN pin when data is sent. Each write operation is performed right after the Enable signal.

Function to send string to LCD

Figure 19: Function to send string to LCD

This function is called during string the data in character form. The function will loop until all the characters such as TEMP: and KNK 4053 are shown on the LCD.

15

Function to convert the values of ADC into numeric value to be sent to LCD

Display TEMP: on the second line of LCD display Since ASCII value of 0 is 48, 48 is added to each value of the data values from ADC for displaying numeric values on LCD display Dividing the integer in order to display first value Modulo operation in order to display the second value Display KNK 4053 on the first line of LCD display

Figure 20: Convert Function

LCD is a very commonly used output device to display alphanumeric characters. This function is called to convert the values of ADC into numeric value to be display on LCD. The LCD displays the character corresponding to the data received on its input data port. It treats the data as the ASCII value of the character to be displayed.

So, the number to be displayed is store in a variable. Then each digit of the number is fetched individually in an array. Since the ASCII value of 0 is 48, 1 is 49 and so on. Thus, we come to the conclusion that the ASCII value of a digit (from 0 to 9) can be calculated by adding 48 to it. Therefore, 48 is added to each value of that array and assigned to the dataport of the LCD one by one. In this way, each digit of the data is displayed on the LCD and as a whole the microcontroller has succeeded in displaying an integer number (temperature values) on the LCD according to the data inputs by ADC.

16

RESULTS & DISCUSSIONS:

Figure 22: Completed Circuit

Figure 23: Temperature reading is 34oC and led indicator is OFF

17

Figure 24: Temperature reading is 57oC and led indicator is ON

PROBLEMS & SOLUTIONS:

There are many expected and unexpected problems arise in this system. At the beginning of the project, the lack of knowledge and experience in using analog to digital converter device ADC0804, microcontroller AT89C52, and LCD display give many obstacles. After researches are done and studied being carried out on datasheet of each electronic component, the function and application of each electronic component would be understood.

For the hardware part, the circuit connection problems such as short circuit, open circuit, and disconnect pin of components are happened causing all the dilemmas. The problems are solved by double checking the circuit connections over and over again. For the temperature measurement, the limitation is the voltage reference used. The voltage reference should be adjusted to 1.28V by potentiometer to obtain the most accurate temperature reading.

For the software part, the C programming language is utilized instead of assembly language. This is because C programming language is a high level programming language and it

18

is easier to program since instruction set used are human understandable language. Unlike the assembly language, it is difficult to work on and require high expertise.

There are a lot of problems arise when writing the program for microcontroller. Firstly, the pulse applied to control pins of the ADC and LCD in order to input the digital data and output the data to be displayed on LCD display. The solution is by reading the condition on datasheet and referring to some online tutorials and forums. Besides, problem faced in converting data from ADC to number display on LCD while trying to program the LCD. With the help of online articles, the problem is solved by adding 48 which represent 0 in ASCII code in the programming source code.

In order to make the LCD display presents more nicely, our group plans to add in some animation on LCD display. We plan to program our group member name in scrolling conditions. However, the program did not run well as expected. After many times of troubleshooting, the problems still cannot solve due to lack of knowledge on C language and lack of time, we modify the program to normal static words display on LCD display.

Furthermore, there is an alarm system in this project, so another output pin is added on microcontroller to trigger the LED alarm system in our program. However, it did not send out the signal as expected when reached the 40oC. After troubleshooting, we realized that the pointer of the data address in our programming source code for the temperature is wrong. After modified the program, the circuit run as expected to trigger the LED alarm indicator.

All in all, we learned a lot from the problem raised and troubleshooting the problems throughout this project. Finally, all the problems are solved and the circuit functions well as expected.

19

CONCLUSION & RECOMMENDATIONS:

All the objectives of this project are achieved. The circuit can measure the surrounding temperature and display the temperature measurement on LCD. Additionally, led indicator acts as alarm will ON in the condition of surrounding temperature is equal or higher than 40oC. This proven that the system can function properly and achieve the expected outcomes.

Although, there are limitations on this monitoring system and further enhancement is feasible for future development. Blinking light together with the actual siren can be integrated into this monitoring system for it to work perfectly and effectively in the concern of reducing the undesired level injuries and damages. In addition, utilizing the huge computerize display by using graphical user interface (GUI) approach is good to alert not only the officer who are taking charge on this system but everyone who are close to the area.

REFERENCES:

[1.]

Digital thermometer by using 8051 microcontroller. (n.d.). Retrieved November 4, 2011 from http://www.engineersgarage.com/microcontroller/8051projects/Celsius-scalethermometer-AT89C51-circuit

[2.]

Stephen Zahra. (n.d.). Interface LM35 with 8051 ADC. Retrieved November 1, 2011 from http://www.electronics-control.info/8051Adc.htm

[3.]

Precision Centigrade Temperature Sensor (n.d.). Retrieved November 1, 2011 from http://www.national.com/mpf/LM/LM35.html#Overview

[4.]

Muhammad Ali Mazidi & Janice Gillispie Mazidi. (n.d.). The 8051 microcontroller and embedded systems.

20

[5.]

Keil 8051 microcontroller development tools. (n.d.). Retrieved November 2, 2011 from http://www.keil.com/c51/

APPENDIX:

i.

Programming codes
//Program to make a digital thermometer with display in centigrade scale #include<reg51.h> #define port P3 #define adc_input P1 #define dataport P0 #define sec 100 sbit rs = port^0; sbit rw = port^1; sbit e = port^2; sbit wr= port^3; sbit rd= port^4; sbit intr= port^5; sbit out=P2^2; int test_intermediate3=0, test_final=0,test_intermediate1[10],test_intermediate2[3]={0,0,0}, shift=0; void delay(unsigned int msec ) { int i ,j ; for(i=0;i<msec;i++) for(j=0; j<1275; j++); } void lcd_cmd(unsigned char item) //Function to send command to LCD { dataport = item; rs= 0; rw=0; e=1;

21

delay(1); e=0; return; } void lcd_data(unsigned char item) //Function to send data to LCD { dataport = item; rs= 1; rw=0; e=1; delay(1); e=0; //delay(100); return; } void lcd_data_string(unsigned char *str) // Function to send string to LCD { int i=0; while(str[i]!='\0') { lcd_data(str[i]); i++; delay(10); } return; } void shape() // Function to create the shape of degree { lcd_cmd(64); lcd_data(2); lcd_data(5); lcd_data(2); lcd_data(0); lcd_data(0); lcd_data(0); lcd_data(0); lcd_data(0); } void convert() // Function to convert the values of ADC into numeric value to be sent to LCD { int s;

22

test_final=test_intermediate3; lcd_cmd(0xc1); delay(2); lcd_data_string("TEMP:"); delay(30);s=test_final/100; test_final=test_final%100; lcd_cmd(0xc8); if(s!=0) lcd_data(s+48); else lcd_cmd(0x06); s=test_final/10; test_final=test_final%10; lcd_data(s+48); lcd_data(test_final+48); lcd_data(0); lcd_data('c'); lcd_data(' '); delay(2); lcd_cmd(0x82); delay (2); lcd_data_string("KNK 4053"); } void main() { int i,j; adc_input=0xff; lcd_cmd(0x38); lcd_cmd(0x0c); //Display On, Cursor Blinking delay(2); lcd_cmd(0x01); // Clear Screen delay(2); while(1) { for(j=0;j<3;j++) { for(i=0;i<10;i++) { shift++; delay(1); rd=1;

23

wr=0; delay(1); wr=1; while(intr==1); rd=0; lcd_cmd(0x88); test_intermediate1[i]=adc_input/10; delay(1); intr=1; } for(i=0;i<10;i++) test_intermediate2[j]=test_intermediate1[i]+test_intermediate2[j]; } test_intermediate2[0]=test_intermediate2[0]/3; test_intermediate2[1]=test_intermediate2[1]/3; test_intermediate2[2]=test_intermediate2[2]/3; test_intermediate3=test_intermediate2[0]+test_intermediate2[1]+test_intermediate2[2]; shape(); convert(); if (adc_input>=40) out =1; else out =0; } }

24

ii.

LCD display 16X2

Pin 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Symbol VSS VCC VEE RS R/W EN DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 Led+ Led-

Description Ground Main power supply Power supply to control contrast Register Select Read/write Enable Data bit (LSB) Data bit Data bit Data bit Data bit Data bit Data bit Data bit (MSB) Backlight VCC Backlight Ground

0V +5 V Contrast adjustment by providing a variable resistor through VCC RS=0 to select Command Register RS=1 to select Data Register R/W=0 to write to the register R/W=1 to read from the register A high to low pulse (minimum 450ns wide) is given when data is sent to data pins

8-bit data pins

+5 V 0V

25

iii.

Microcontroller AT89C51

Pin 1-8 9 10- 17 18 19 20 21-28 29 30 31 32-39 40

Symbol P1 RST P3 XTAL2 XTAL1 GND P2 PSEN ALE/PROG EA/VPP P0 VCC

Description 8-bit data pins Reset input 8-bit data pins Output from the inverting oscillator amplifier Input to the inverting oscillator amplifier Ground 8-bit data pins Program store enable Address Latch Enable External access 8-bit data pins Supply voltage (+5V).

P3.0 P3.1 P3.2 P3.3 P3.4 P3.5 P3.6 P3.7

Port Pin Alternate Function RxD (serial input port) TxD (serial output port) INT0 (external interrupt 0) INT1 (external interrupt 1) T0 (timer 0 external input) T1 (timer 1 external input) WR (external data memory write strobe) RD (external data memory read strobe)

26

iv.

Analog to digital converter, ADC0804

Pin 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Symbol CS RD WR CLK IN INTR VIN (+) VIN (-) A GND VREF/2 D GND D7 (MSB) D6 D5 D4 D3 D2 D1 D0 (LSB) CLK R VCC

Description Chip select (active low) Read (active low) Write (active low) Clock in Interrupt (active low) Analog Voltage Input Analog Voltage Input Analog ground Voltage Reference / 2 Digital ground

8-bit data pins

Clock Reset Power supply (+5V)

27

You might also like