Вы находитесь на странице: 1из 17

Temperature Sensing System Using 8051

Submitted BY: Nisarg Pandya (08EC029)


Chetan Panchal (08EC025)

Ahmadabad Institute of Technology, Ahmadabad Nov-2010

Certificate
This is to certify that the project of 8051 entitled Temperature Sensor Using 8051 submitted by 5th EC students, Name
Yashpal Padheriya Chetan Panchal Nishant Pandey Nisarg Pandya Apoorva Patel Jignesh Patel Jimmy Patel Ketan Patel Niraj Patel Krunal Patel

Roll No.
08EC024 08EC025 08EC028 08EC029 08EC036 08EC039 08EC040 08EC041 08EC042 08EC043

Submitted for the project work held on 15th Nov 2010.

Signature of Examiner

Introduction:
This project explains about a simple circuit which can be mainly used to detect temperature at any place. It indicates temperature on the LCD screen with the help of microcontroller. It uses LM35 which is 3 pin centigrade temperature sensor IC. It directly senses the temperature sensor and sends it to the controller. The block diagram consists of temperature sensor, ADC, microcontroller 8051 and LCD display. LM35 senses the temperature and sends the analog output to the Analog to Digital converter which in turn converts the analog signal to digital signal. The digital out of ADC is sends to the controller and using LCD the temperature is displayed on the screen.

Block Diagram:

Temperature Sensor

Analog to Digital Converter

Micro Controller

LCD Screen

mainly consists of following blocks 1. Sensor: we are going to use temperature sensor to sense temperature. These sensor sense the parameter and gives corresponding voltage output. 2. ADC: The main part of our project is microcontroller which reads only digital input (0V & 5V) but the output of sensor is in analog form, so it has to be converted into digital format, for this purpose we are going to use ADC to convert

Description: It

analog output from amplifier into the digital output to be given to microcontroller 3. Microcontroller: This is the CPU (central processing unit) of our project. We are going to use microcontroller of 8051 family. The various functions of microcontroller are like I. Reading the digital input from ADC which is derived from Temperature sensor. II. Sending this data to LCD so that the person operating this project should read the values of temperature and light. III. Sending the values of temperature to LCD screen.

Hardware Description:
1) Power Supply: LM7805: The LM 7804 series of three terminal positive regulators are
available in TO-220 package and several fixed output voltages, making them widely applicable. Each type employs internal current limiting, thermal shutdown and safe operating area protection, making it indestructible. Although designed primarily as fixed voltage regulators, these devices can be used with external components to obtain adjustable voltages and currents.

Features:
O/P current up to 1A O/P voltages of 5V to 24V Thermal overload protection Short circuit protection

Working: Voltage regulator limits the voltage that passes through it. 7805 is a
5V voltage regulator. That means how many volts you put into it, it will output only 5v. 2)

LM35:

The LM35 series are precision integrated-circuit temperature Sensors, whose output voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage over linear temperature sensors calibrated in Kelvin, as the user is not required to subtract a large constant voltage from its output to obtain convenient Centigrade scaling. The LM35 does not require any external calibration or trimming to provide typical accuracies of 14C at room temperature and 34C over a full 55 to +150C temperature range. Low cost is assured by trimming and calibration at the wafer level. The LM35s low output impedance, linear output and precise inherent calibration make Interfacing to readout or control circuitry especially easy. It Can be used with single power supplies, or with plus and Minus supplies. As it draws only 60 A from its supply, it has Very low self-heating, less than 0.1C in still air. The LM35 is rated to operate over a 55 to +150C temperature range, while the LM35C is rated for a 40 to +110C range. The LM35 series is available packaged. In hermetic TO-46 transistor packages, while the LM35C, LM35CA, and LM35D are also available in the Plastic TO-92 transistor package. The LM35D is also available in an 8-lead surface mount small outline package and a plastic TO-220 package.

Features:
Calibrated directly in Celsius (Centigrade) Linear + 10.0 mV/C scale factor 0.5C accuracy guaranteeable (at +25C) Rated for full 55 to +150C range Suitable for remote applications Low cost due to wafer-level trimming Operates from 4 to 30 volts Less than 60 A current drain Low self-heating, 0.08C in still air Nonlinearity only 14C typical

Applications: The LM35 can be applied easily in the same way as other
integrated-circuit temperature sensors. It can be glued or cemented to a surface and its temperature will be within about 0.01C of the surface temperature. This presumes that the ambient air temperature is almost the same as the surface temperature; if the air temperature were much higher or lower than the surface temperature, the actual temperature of the LM35 die would be at an intermediate temperature between the surface temperature and the air temperature. This is expecially true for the TO-92 plastic package, where the copper leads are the principal thermal path to carry heat into the device, so its temperature might be closer to the air temperature than to the surface temperature. To minimize this problem, be sure that the wiring to the LM35, as it leaves the device, is held at the same temperature as the surface of interest. The easiest way to do this is to cover up these wires with a bead of epoxy which will insure that the leads and wires are all at the same temperature as the surface, and that the LM35 dies temperature will Not be affected by the air temperature.

3)

Analog to Digital Converter:

The ADC0801, ADC0802, ADC0803, ADC0804 and ADC0805 are CMOS 8-bit successive approximation A/D converters that use a differential potentiometric ladder similar to the 256R products. These converters are designed to allow operation with the NSC800 and INS8080A derivative control bus with TRISTATE output latches directly driving the data bus. These A/Ds appear like memory locations or I/O ports to the microprocessor and no interfacing logic is needed. Differential analog voltage inputs allow increasing the common-mode rejection and offsetting the analog zero input voltage value. In addition, the voltage reference input can be adjusted to allow encoding any smaller analog voltage span to the full 8 bits of resolution.

Features:
Compatible with 8080 mp derivatives no interfacing logic needed access time - 135 ns Easy interface to all microprocessors, or operates stand alone'' Differential analog voltage inputs Logic inputs and outputs meet both MOS and TTL voltage level specifications Works with 2.5V (LM336) voltage reference On-chip clock generator 0V to 5V analog input voltage range with single 5V supply No zero adjust required 0.3 standard width 20-pin DIP package 20-pin molded chip carrier or small outline package Operates ratio metrically or with 5 VDC, 2.5 VDC, or analog span adjusted voltage reference

Key Specifications:

Resolution 8 bits Total error g (/4 LSB, g (/2 LSB and g1 LSB Conversion time 100 ms

4)Microcontroller: The

P89V51RD2 is an 80C51 microcontroller with 64 kB Flash and 1024 bytes ofdata RAM. A key feature of the P89V51RD2 is its X2 mode option. The design engineer can choose to run the application with the conventional 80C51 clock rate (12 clocks per machine cycle) or select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput at the same clock frequency. Another way to benefit from this feature is to keep the same performance by reducing the clock frequency by half, thus dramatically reducing the EMI. The Flash program memory supports both parallel programming and in serial. In-System Programming (ISP). Parallel programming mode offers gangprogramming at high speed, reducing programming costs and time to market. ISP allows a device to be reprogrammed in the end product under software control. The capability to field/update the application firmware makes a wide range of applications possible. The P89V51RD2 is also In-Application Programmable (IAP), allowing the Flash program memory to be reconfigured even while the application is running.

Features

80C51 Central Processing Unit 5 V Operating voltage from 0 to 40 MHz 64 kB of on-chip Flash program memory with ISP (In-System Programming) and IAP (In-ApplicationProgramming) Supports 12-clock (default) or 6-clock mode selection via software or ISP

SPI (Serial Peripheral Interface) and enhanced UART PCA (Programmable Counter Array) with PWM and Capture/Compare functions Four 8-bit I/O ports with three high-current Port 1 pins (16 mA each) Three 16-bit timers/counters Programmable Watchdog timer (WDT) Eight interrupt sources with four priority levels Second DPTR register Low EMI mode (ALE inhibit) TTL- and CMOS-compatible logic levels Brown-out detection Low power modes Power-down mode with external interrupt wake-up Idlemode PDIP40, PLCC44 and TQFP44 packages

Block Diagram of p89v51rd2

Pin Diagram 4) Liquid Crystal Display:

16 CHAR x 2ROW Vcc at pin 16 controls the background contrast Vcc at pin 2 controls the display contrast Pin 7-14 gets input data Pin 1& 3 controls the brightness of the display Pin 5 gets a R/W signal Pin 6 get enable signal Pin 4 gets data register select

PIN CONFIGURATION
1 VSS 2 VCC 3 VEE 4 RS 5 R/W 6 E 7 DB0 8 DB1 9 DB2 10 DB3 11 DB4 12 DB5 13 DB6 14 DB7 15 LED + 16 LED-

Result: In the temperature sensing system we have used four blocks those are
sensor, ADC, Microcontroller, LCD. In this system, sensor senses the atmospheric temperature and sends it to ADC to convert it into digital form and that hex code is then converted into ASCI code to display it to LCD.

Reference:
Books:The 8051 Microcontroller and Embedded Systems, Muhammad Ali Mazidi Website: scribd.com

Program:
include<reg51.h> #define port P3 #define adc_input P1 #define dataport P0 #define sec 100 sbit rs = port2^0; sbit rw = port2^1; sbit e = port2^2;

sbit wr= port3^3; sbit rd= port3^4; sbit intr= port3^5;

int test_intermediate3=0, test_final=0,test_intermediate1[10],test_intermediate2[3]={0,0,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; 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() { lcd_cmd(64); lcd_data(2); lcd_data(5); lcd_data(2); lcd_data(0);

// Function to create the shape of degree

lcd_data(0); lcd_data(0); lcd_data(0); lcd_data(0); }

void convert() { int s;

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

test_final=test_intermediate3; lcd_cmd(0xc1); delay(2); lcd_data_string("TEMP:"); 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);

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++) { delay(1); rd=1; 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(); } }

Вам также может понравиться