Professional Documents
Culture Documents
Project Report Submitted for the award of the degree of Bachelor of Technology in Electrical and Electronics Engineering By
Department of Electrical And Electronics Engineering NATIONAL INSTITUTE OF TECHNOLOGY CALICUT April 2011
CERTIFICATE
This is to certify that the report entitled Temperature Controlled DC Fan using PIC18F452 Microcontroller is a bonafide record of the Mini Project done by Prem Shankar (Roll No: B080425EE), Prashant Jaiswal (Roll No: B080433EE) and Vikash Kumar (Roll No: B080449EE) under my supervision, in partial fulfillment of the requirements for the award of the degree of Bachelor of Technology in Electrical And Electronics Engineering from National Institute of Technology Calicut, and this work has not been submitted elsewhere for the award of a degree.
DR . Jeevamma Jacob
(Guide)
Dept. of Electrical Engineering
Mr. P. Ananthakrishnan
Associate Professor
Department seal
ACKNOWLEDGEMENT
We express our sincere gratitude to our Guide, Dr. Jeevamma Jacob, Professor, Department Of Electrical Engineering for her continuous support without which this project would not have been a success. We would also like to thank our Course Coordinator, Mr. Ananthakrishnan, Associate Professor, Electrical Engineering Department, NITC for his timely advices without which this project would be incomplete. This project would have been impossible without the guidance of Mr. Jagdanand, Assistant Professor .We thank him for his timely advice rendered in guiding us throughout the Project. Last but not the least we thank our Parents and Lord Almighty.
ABSTRACT
This project targets on designing, simulating, prototyping and controlling the speed of a dc motor fan which can be used to keep the temperature of computers processor within specified limits. The primary aim of our project is to control the speed of a dc motor fan according to the temperature sensed by a temperature sensor using a pic microcontroller.
CONTENTS
1. Introduction 1.1Why use microcontroller? 1.2Methodology 1.3Project Objective 2. Components and Hardware 2.1 Components Used 2.2 Hardware 2.2.1 PIC Microcontroller 2.2.2 Temperature Sensor 2.2.3 Optoisolator 2.2.4 N-Channel MOSFET 2.2.5 DC Motor 3. Implementation 3.1 Circuit diagram 3.2 Flow Chart 3.3 Configuring ADC 3.4 Program Code 3.5 Simulation Result 4. Results and Conclusion 5. References 28 28 14 7 6
Chapter 1 INTRODUCTION
In todays hi-tech world computers have become part and partial of life. But temperature of the processor inside the computing system needs to be controlled for proper functioning of the semiconductor devices. Thus it is important to keep the temperature within the prescribed limits. 1.1 Why use microcontroller?
To control the temperature it must be sensed and check in what range it lies according to which the speed of the cooling fan is decided. These tasks can be performed very easily using a microcontroller. It involves decision making steps, which can be easily achieved by using a microcontroller instead of complex IC circuits. 1.2 Methodology
First of all the temperature will be sensed by a temperature sensor, which works as a transducer and gives voltage equivalent of the sensed temperature. This analog signal will be fed to the ADC of PIC microcontroller. Thereafter the adc will take the analog input and convert it to digital domain. Now the digital data will be compared to the prespecified conditions in the program. According to result of comparison, desired duty ratio will be generated.
1.3
Project Objective
This project targets on designing, simulating, prototyping and testing of a temperature controlled dc motor fan that is practically used for cooling the processor in computers. The primary aim of our project is to control dc motor, fan in our project, using a pic micro controller. The fan will be given an input duty ratio which increases in steps of 25% for every 10 degree rise in temperature, starting from 25 degrees. The fan will be kept off for temperature less than 25 degree and will run maximum speed for temperature above 55 degrees.
2.2 Hardware
2.2.1 PIC Microcontroller For this project, we are using PIC18F452. PIC18 XXX is an 8 bit microcontroller. The other PIC families are 10xxx ,12xxx ,14xxx & 17xxx. They all are 8 bit processors, meaning that the CPU can work on only 8 bit data at a time. The data larger than 8 bit has to be broken into 8 bit pieces to be processed by CPU. The PIC18f has an instruction size of 16 bit wide. PIC18f is available in 18-80 pin packages makes it ideal for new designs. PIC18 features: PIC18 has a RISC architecture that comes with some standard features such as on-chip program ROM, data RAM, data EEPROM, TIMERS, ADC, and USART and I/O ports. Using these features, various tasks can be performed. Block diagram representation is shown in fig 2.2.
PIC18F452 has 10 bit inbuilt ADC, which converts the analog input data fed to it through PORTA pins. ADCs are mainly used for data acquisition. Here a physical quantity like temperature, pressure is converted to electrical (voltage, current) signals using a device called a transducer. Transduces are also referred to as sensors . Sensors for temperature, velocity and many other physical quantities produce an output that is voltage (or current). Therefore, we need an analog-to-digital converter to translate the analog signals to digital numbers so that the microcontroller can read and process that. While configuring an ADC one must focus on certain parameters like RESOLUTION, CONVERSION TIME, INPUT VOLTAGE (Vref) etc.
Dual Inline Package of PIC18F452 that is being used for our project is shown in figure 2.4.
10
For the 40 pin DIP structure, 33 pins are set aside for five ports PORTA, PORTB, PORTC, PORTD and PORTE. The rest of the pins are designated as Vdd(power supply pin), Vss(ground), OSC1,OSC2,MCLR(reset), and another set of Vdd and Vss. A powerful feature of PIC I/O ports is their capability to access individual bits of the port without altering the rest of the bits in that port. This can be used if we need to access only 1 or 2 bits of the port instead of the entire 8 bits. 2.2.2 Temperature Sensor A sensor is a device that measures a physical quantity and converts it into a signal which can be read by an observer or by an instrument. Simple and widely used linear temperature sensors used include the LM34 and LM35 series from National Semiconductor Corporation. The sensors of LM34 series are precision integrated-circuit temperature sensors whose output voltage is linearly proportional to the Fahrenheit temperature. But In common practice degree Celsius is more in use than Fahrenheit scale. Therefore LM35 is a better option.
LM35 series sensors are precision integrated-circuit temperature sensors whose output voltage is linearly proportional to the Celsius temperature. It requires no external caliberation because it is internally caliberated . The table above sufficiently explains the need of using LM35D in our project.
11
representation
2.2.3 Optoisolator
This is an electronic device designed to transfer electrical signals by utilizing light waves to provide coupling with electrical isolation between its input and output. It is also known as optocoupler and is used to isolate two parts of a system. An optoisolator has an LED transmitter and a photosensor receiver, separated from each other by a gap. When current flows through the diode, it transmits a signal applied across the gap and receiver produces the same signal with the same phase but a different current and amplitude. We are using MCT2E as optocoupler in our project.
12
The metaloxidesemiconductor field-effect transistor (MOSFET, MOS-FET, or MOS FET) is a transistor used for amplifying or switching electronic signals. In this project we have used IRF 520 as the n-channel MOSFET.
Figure 2.10 Characterstic curve for n-channel MOSFET The advantages of using MOSFET as switch are: 1. Low gate signal power requirement. No gate current can flow into the gate after the small gate oxide capacitance has been charged.
13
2. Fast switching speeds because electrons can start to flow from drain to source as soon as the channel opens. The channel depth is proportional to the gate volage and pinches closed as soon as the gate voltage is removed, so there is no storage time effect as occurs in bipolar transistors.
2.2.5 DC Motor Direct current motor is a widely used device to translate electrical pulses in to mechanical movement. In our project we are using Brushless DC motors. Brushless DC motors (BLDC motors, BL motors) also known as electronically commutated motors (ECMs, EC motors) are synchronous electric motors powered by direct-current (DC) electricity and having electronic commutation systems, rather than mechanical commutators and brushes. The current-totorque and frequency-to-speed relationships of BLDC motors are linear. A sample brushless DC motor is shown in figure 2.11.
14
Chapter-3 Implementation
15
The ADCONO register is used to set the conversion time and select the analog input channel among other things. Figure 13-6 shows the ADCONO register. In order to reduce the power consumption of the PIC 18, the ADC feature is turned off when the microcontroller is powered up. We turn on the ADC with the ADON bit of the ADCONO register, as shown in Figure 13-6. The other important bit is the GO/DONE bit. We use this bit to start conversion and monitor it to see if conversion has ended. Notice in ADCCONO that not all family members have all the 8 analog input channels.
16
The conversion time is set with the ADCS bits. While ADCS 1 and ADCSO are held by the ADCONO register, ADCS2 is part of the ADCON 1 register.
ii) ADCON1 The ADCON 1 register is used to select the Vref voltage among other things. It is shown in Figure below. After the A/D conversion is complete, the result sits in registers ADRESL (A/D Result Low Byte) and ADRESH (AID Result High Byte).The ADFM bit of the ADCON1 is used for making it right-justified or left-justified because we need only 10 bits of the 16.
17
18
19
3.4 Program Code LIST P=PIC18F452, F=INHX32, MM=OFF, N=0, ST=OFF, R=HEX #include P18F452.INC CONFIG OSC=HS, OSCS=OFF CONFIG WDT=OFF CONFIG DEBUG=OFF, LVP=OFF, STVR=OFF ORG 00H BSF TRISA,0 BCF TRISC,CCP1 MOVLW 81H MOVWF ADCON0 MOVLW 8FH MOVWF ADCON1 CALL DELAY BSF ADCON0,GO BACK BTFSC ADCON0,DONE BRA BACK REFRESH register 01h MOVFF ADRESL, 01H ;Polling ;Copy the converted digital value to file ;Tacq~12.86 uSec ;Starting conversion ;Checking if the conversion is complete ;Configuring the control register 1 of ADC ;Make pin RA0 an input pin ;Make pin RC2/CCP1 output pin ;Configuring the control register 0 of ADC
MOVFF ADRESH, 02H CALL DELAY BSF ADCON0,GO ;---------------------------------------------------------------------------------------------------------------------------------------------------------------MOVLW D'50' CPFSLT 01H GOTO CHECK DR_0 BCF PORTC,2 GOTO REFRESH BRA DR_0 CHECK MOVLW D'70' ;CALL Q_SEC_DELAY
20
CPFSLT 01H GOTO CHECKA CALL DR_25 GOTO REFRESH CHECKA MOVLW D'90'
CPFSLT 01H GOTO CHECKB CALL DR_50 GOTO REFRESH CHECKB MOVLW D'110'
CPFSLT 01H BRA X1 BRA X2 X1 GOTO DR_100 GOTO REFRESH X2 CALL DR_75 GOTO REFRESH ORG 310H DELAY MOVLW 48H PRESCALE MOVWF T0CON MOVLW 9CH MOVWF TMR0L BCF INTCON, TMR0IF BSF T0CON, TMR0ON D1 BTFSS INTCON, TMR0IF BRA D1 BCF T0CON, TMR0ON RETURN ORG 410H DR_25 D25 NOP BSF PORTC,2 ;CLEAR THE CONTROL REGISTER OF CCP ;TMROL=9CH ;CLEAR TIMER0 INTERRUPT FLAG BIT ;START THE TIMER0 ;MONITOR TIMER0 FLAG ;UNTIL IT ROLLS OVER ;STOP TIMER0 ;RETURN TO MAIN PROGRAM ;TIMER0 8 BIT MODE, INT CLK, NO ;LOAD T0CON REGISTER
21
CALL DELAY_DR BCF PORTC,2 CALL DELAY_DR CALL DELAY_DR CALL DELAY_DR MOVWF 01H, W ;COPY CONTENT OF 01H TO WREG
CPFSEQ ADRESL ;SKIP THE NEXT INSTRUCTION IF VALUE OF ADRESL REGISTER IS EQUAL TO WREG BRA B1 GOTO D25 B1 NOP RETURN ORG 520H DR_50 D50 NOP BSF PORTC,2 CALL DELAY_DR CALL DELAY_DR BCF PORTC,2 CALL DELAY_DR CALL DELAY_DR MOVWF 01H, W CPFSEQ ADRESL BRA B2 CONTINUE GOTO D50 B2 NOP RETURN ORG 620H DR_75 D75 NOP BSF PORTC,2 CALL DELAY_DR CALL DELAY_DR ;CLEAR THE CONTROL REGISTER OF CCP ;IF THERE IS CHANGE TAKE NEW VALUE ELSE ;CHECK FOR ANY CHANGE IN ADC OUTPUT ;CLEAR CCP1CON REGISTER ;CLEAR THE CONTROL REGISTER OF CCP ;JUMP TO REFRESH ;JUMP TO D25
22
CALL DELAY_DR BCF PORTC,2 CALL DELAY_DR MOVWF 01H, W CPFSEQ ADRESL BRA B3 CONTINUE GOTO D75 B3 NOP RETURN ORG 720H DR_100 D100 NOP BSF PORTC,2 GOTO REFRESH ORG 820H DELAY_DR MOVLW D'31' ;IF THERE IS CHANGE TAKE NEW VALUE ELSE ;CHECK FOR ANY CHANGE IN ADC OUTPUT
MOVWF 05H AGAIN NOP DECF 05H,F BNZ AGAIN RETURN END
23
3.5 Simulation Result: To check if the code will work on the fabricated model we need to simulate and check if the codes are giving the desired results. For this purpose, the circuit was connected in proteus as shown in figure 3.3
24
Channel A is connected to pin 17 of the PIC and channel B is connected through the n-Channel Mosfet acting as the switch. The output for temperature below 25 degree celcius is as shown in figure 3.4
25
We can see that the output is zero as expected. Now For temperature range 26 to 35 degree, the output is as shown in figure 3.5
Figure 3.5 Output at 30 degree celcius We can see that the output is a pulse with duty ratio 25% as expected. Now For temperature range 36 to 45 degree, the output is as shown in figure 3.6
Figure 3.5 Output at 38 degree celcius We can see that the output is a pulse with duty ratio 50% as expected. Now For temperature range 46 to 55 degree, the output is as shown in figure 3.6
26
Figure 3.6 Output at 52 degree celcius We can see that the output is a pulse with duty ratio 75% as expected. Now For temperature greater than 55 degree, the output is as shown in figure 3.7
Figure 3.7 Output at 62 degree celcius We can see that the output is a pulse with duty ratio 100% as expected.
27
The prototype of the Temperature controlled DC fan using PIC18F452 microcontroller was simulated and fabricated. The sensor was successfully interfaced with the microcontroller using ADC the desired output pulses were observed in the simulation using PROTEUS software.
References
1. Muhammad Ali Mazidi, PIC Microcontroller and Embedded System, Pearson Education inc. 2. http://extremeelectronics.co.in/microchip-pic-tutorials/interfacing-lm35-temperaturesensor-with-pic-microcontroller/ 3. http://www.makingthings.com/teleo/teleo/cookbook/autofan/index.htm 4. Datasheets of PIC18F452, LM35D, IRF520
28