Professional Documents
Culture Documents
Number
Lab Title Open ended lab
A temperature monitoring system is to be designed that must include the following features:
Block Diagram:
Alarm
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:
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:
}
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:
Conclusion:
File name to be saved as.” Conclusion _ Asif Ali”