You are on page 1of 5

Lab Lab 14

Number
Lab Title Open ended lab

Name: Asif Ali


Enrollment: 01-133182-017
Class: BEE(5B)
Temperature monitoring system using Pic18f452

A temperature monitoring system is to be designed that must include the following features:

1. Continuous monitoring of temperature using a temperature sensor


2. Display the temperature on a 16x2 LCD.
3. If the temperature increases beyond the normal temperature range it should alert the people by
ringing an alarm

Block Diagram:

Temperature Analogue i/p A/D digital o/p


16x2 LCD
sensor conversion

Alarm

Code & Simulation:

1. Code should be written in mikro C software


2. Software simulation of the circuit must be presented in proteus software

Hint:

Sensors (LM35):

The sensor can measure temperature in the range of 0 to 100°C, i.e., the output of the sensor varies
from 0 to 1000 mV. The LM35 operates over the temperature range of -55° to +150°C, while the LM35C
is rated for a -40°C to +110°C range (-10°C with improved accuracy).
(ADC result × 5) / 1023

The temperature in degree Celsius is: Sensor output × 1000 / 10 = Sensor output × 100

Pic18f452

The Pic18f452 microcontroller processes the sensor output to compute the temperature in degree
Celsius. The internal ADC of the microcontroller is used to convert the analogue output of the sensor
into its equivalent digital value. The internal ADC of the microcontroller has eight channels of analogue
input and gives 10-bit digital output. In this project, the reference voltage to the ADC is the same as the
supply voltage to the microcontroller, i.e., 5V. The resolution of the ADC can be calculated as follows:

Resolution = V ref / (1024-1) … (as it is a 10-bit ADC)


= 5/1023
= 4.887 mV

It means that for 4.887mV change in the analogue input, the ADC output changes by binary ‘1’ with a
reference voltage of 5V.

Code:

sbit LCD_D7 at RB2_bit;


sbit LCD_D6 at RB3_bit;
sbit LCD_D5 at RB4_bit;
sbit LCD_D4 at RB5_bit;
sbit LCD_EN at RB6_bit;
sbit LCD_RS at RB7_bit;

sbit LCD_D7_Direction at TRISB2_bit;


sbit LCD_D6_Direction at TRISB3_bit;
sbit LCD_D5_Direction at TRISB4_bit;
sbit LCD_D4_Direction at TRISB5_bit;
sbit LCD_EN_Direction at TRISB6_bit;
sbit LCD_RS_Direction at TRISB7_bit;
//************************temperature variables****************
int temp;
char temper[7];
//**************************************************************
void READ_temp(void)
{
temp = ADC_Read(0);
temp = temp * 500/1023;
temp = temp * 100;

}
void data_converstion(void)
{ temp=temp/100;

inttostr(temp,temper);
}
void display1(void)
{
lcd_out(1,1,"TEMPERATURE=");
lcd_out(1,13, Ltrim(temper));
Lcd_Chr_Cp(0xdf);
Lcd_Chr_Cp('C');
Lcd_Chr_Cp(' ');

void main()
{ TRISC=0;
ADC_Init();
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
lcd_cmd(_LCD_CURSOR_OFF);
lcd_out(1,4,"DIGITAL TEMPERATURE");
lcd_out(2,6,"SENSOR");
delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR); // Clear display

while(1)
{

READ_temp();
data_converstion();
display1();
if(temp>=24)
{
portc=1;
}
else
{
portc=0;
}
}
}
Task caption:” Task. A basic code for temperature sensors -Asif Ali”

Output:

Task caption:” Task. A basic Display of temperature sensor as output-Asif Ali”

Conclusion:
File name to be saved as.” Conclusion _ Asif Ali”

You might also like