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: 1
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
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
1
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.
2
Decide the title of project
Search for information
If fail, do the troubleshooting
Start
Distribute the work and task of project
Hardware: Circuit consist of Sensor, ADC, MCU, LCD
display, & Alarm
Software: firmware of microcontroller
Testing?Testing?
Do the circuit connection on electronic board
Write c language programming in Keil
software
If fail, do the troubleshooting
Success Success
B
A
Identify the purpose of project
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.
3
Testing?
End
Obtain the expected outcome
Success
BIf fail, do the troubleshooting
Burn HEX file which is written in Keil software into MCU
Submit report and do presentation
A
Do the report
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.
4
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?
Obtain the expected outcome
End
If fail, do the troubleshooting
Success
Start
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.
5
Start
Understand and learn programming c language
Write the programming in Keil software
Simulate?
Obtain the HEX file
Burn the HEX file into microcontroller AT 89C51
Success
If fail, do the troubleshooting
D
Able to understand the steps of enable and control circuit function
C
V
Flowchart 3: Methodology for Software
SYSTEM DESCRIPTION:
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.
6
Sensor, LM 35
Analog-to-digital converter, ADC0804
Microcontroller, AT89C51
LCD display, 16X2
LED indicator
Heat source
Success
Place the microcontroller on the circuit
Testing?
Obtain the expected outcome
End
If fail, do the troubleshooting
D
C
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:
7
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.
8
Figure 10: Complete schematic of the system
Figure 11: completed circuit
9
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 27°C.
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
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
Low-to-high pulse at WR pin for start conversion
High-to-low pulse at RD pin for data outputs
from ADC to microcontroller
Indicates 2 lines and 5x7 matrix is used
Zero reset for ADC input
Display on, Cursor off
Clear Screen
Trigger alarm if the temperature more than 40 degree
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
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
Define port 1 for ADC input
Define port 3
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
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
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
High-to-low pulse for Enable pin
Function to send data to LCD
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
High-to-low pulse for Enable pin
Function to convert the values of ADC into numeric value to be sent to LCD
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
Display “TEMP:” on the second line of LCD display
Display “KNK 4053” on the first 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
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-scale-
thermometer-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 100sbit rs = port^0;sbit rw = port^1;sbit e = port^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 LCDdataport = item;rs= 0;rw=0;e=1;
21
delay(1);e=0;return;void lcd_data(unsigned char item) //Function to send data to LCDdataport = 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 LCDint i=0;while(str[i]!='\0') lcd_data(str[i]); i++; delay(10);return;
void shape() // Function to create the shape of degreelcd_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 LCDint s;
Pin Symbol Description 1 VSS Ground 0 V2 VCC Main power supply +5 V3 VEE Power supply to control contrast Contrast adjustment by providing a variable
resistor through VCC
4 RS Register Select RS=0 to select Command RegisterRS=1 to select Data Register
5 R/W Read/write R/W=0 to write to the registerR/W=1 to read from the register
6 EN Enable A high to low pulse (minimum 450ns wide) is given when data is sent to data pins
7 DB0 Data bit (LSB)
8-bit data pins
8 DB1 Data bit9 DB2 Data bit10 DB3 Data bit11 DB4 Data bit12 DB5 Data bit13 DB6 Data bit14 DB7 Data bit (MSB)15 Led+ Backlight VCC +5 V16 Led- Backlight Ground 0 V
25
iii. Microcontroller AT89C51
Pin Symbol Description1-8 P1 8-bit data pins9 RST Reset input
10- 17 P3 8-bit data pins18 XTAL2 Output from the inverting oscillator amplifier19 XTAL1 Input to the inverting oscillator amplifier20 GND Ground
21-28 P2 8-bit data pins29 PSEN Program store enable30 ALE/PROG Address Latch Enable31 EA/VPP External access
32-39 P0 8-bit data pins40 VCC Supply voltage (+5V).
Pin Symbol Description1 CS Chip select (active low)2 RD Read (active low)3 WR Write (active low)4 CLK IN Clock in5 INTR Interrupt (active low)6 VIN (+) Analog Voltage Input7 VIN (-) Analog Voltage Input8 A GND Analog ground9 VREF/2 Voltage Reference / 210 D GND Digital ground11 D7 (MSB)
8-bit data pins
12 D613 D514 D415 D316 D217 D118 D0 (LSB)19 CLK R Clock Reset20 VCC Power supply (+5V)