MIT Project Report
MIT Project Report
TERM PROJECT
COURSE CODE : 19CCE201 SEMESTER : 3 BRANCH : CCE
1.Abstract
A Temperature Controlled DC Fan Is a system which automatically turns
on a DC Fan when the ambient temperature increases above a certain limit.
Generally, electronic devices produce more heat. So this heat should be reduced in
order to protect the device.
The aim of this project Is to design a temperature controlled fan using
LPC2148 microcontroller, in which the fan is automatically turned ON or OFF
according to the temperature and also the temperature limit can be changed
anytime using input from UART .
In this circuit, the LM35 temperature sensor is used to get the temperature
sensed. Then, the temperature is displayed on the LCD.
Like this, the microcontroller will continuously monitor the temperature. If
the temperature exceeds more than 35 degree Celsius (upper safe temperature
limit of laptops), the microcontroller will turn on the relay to start the fan.
If the temperature drops below 35 degree Celsius, the microcontroller will
turn off the relay , but the fan speed will slow down gradually which further
reduces the temperature.
2. Introduction
PINSEL0 = 0x00000000;
IODIR0 |= 0X00100000; // P0.20 as output for DC Fan
IODIR0 &= 0XFFFEFFFF; // P0.16 as input from switch
ADC_INIT();
LCD_INIT();
while (1)
{
ADC_val = ADC(); // Returns ADC Value
if ((IOPIN0 & 0x00010000) == 0x00010000) // if P0.16 is high
{
TEMP_LIMIT = UART(); // Returns temperature limit from PC
check = 1; //executes if statement to check again
}
delay_ms(1000); // 1000 milli sec = 1 sec
if (prev != ADC_val || check == 1)
{
temp_f = (ADC_val *9/5)+32 ; // temperature in farenheit
sprintf(val," %dC / %dF",ADC_val,temp_f); // int to string
int ADC(void)
{
unsigned int ADC_data;
AD0CR = 0x00200700; //CLKDIV=(PCLK)/8, BURST=0, CLKS=11clks/10bits, PDN=1
AD0CR|= 0x01; // A/D Channel 0
AD0CR |= (1<<24); //Activate ADC Module (new conversion )
//Wait for conversion to get over by monitoring 28th bit of A/D register
while(!(AD0GDR & 0x80000000));
//Read 10 bit ADC Data ie RESULT = 10 Bit Data (15:6)
ADC_data = (AD0GDR >> 6)& 0x3FF;
//Deactivate ADC Module ie START = 000 (Bits 26:24) (stop conversion)
AD0CR &= 0xF8FFFFFF;
return ADC_data;
}
int UART(void)
{
unsigned int i=0 ,val;
char data = 0, str[4];
PINSEL0 |= 0x00000005; // Enable RxD0 and TxD0
U0LCR = 0x83; // 8 bits, no parity , 1 stop bits, DLAB = 1
U0DLL = 97; // 9600 Baud Rate @ 15MHZ VPB Clock
U0LCR = 0x03; // DLAB = 0
while(data != 44) // if data received is not comma
{
// Wait until reception is over and UART0 is ready with data
while(!(U0LSR & 0x01));
data = U0RBR; //Receive character
// Wait until UART0 ready to send character
while(!(U0LSR & 0x20));
U0THR = data; //Send character
str[i] = data;
i++;
}
val = atoi(str); //converts string into integer
return val;
}
void LCD_INIT(void)
{
//P0.12 to P0.15 LCD Data. P0.4,5,6 as RS RW and EN
IO0DIR |= 0x0000F070;
delay_ms(20);
LCD_CMD(0x02); // Initialize cursor to home position
LCD_CMD(0x28); // 4 - bit interface, 2 line, 5x8 dots
LCD_CMD(0x06); // Auto increment cursor
LCD_CMD(0x0C); // Display on cursor off
LCD_CMD(0x01); // Display clear
LCD_CMD(0x80); // First line first position
}
With temperature unchanged , switch is pressed and “37,” is entered in the virtual
terminal. Now, the LCD display shows “Normal” because the TEMP_LIMIT is 37
now but the current temperature is 35. Relay is off.
With temperature unchanged , switch Is pressed and “32,” is entered in the virtual
terminal. Now, the LCD display shows “Overheat” because the TEMP_LIMIT is 32
now but the current temperature is 34. Relay is on.