Sei sulla pagina 1di 14

TEMPERATURE CONTROLLED FAN

A PROJECT REPORT
Submitted by

PEEYUSH PASHINE(2011H140033H)
PRAVESH TAMRAKAR(2011H140036H)
SRI KRISHNA YADAV(2011H140031H)
J GANESH(2011H140032H)

M.E. (EMBEDDED SYSTEMS)


BIRLA INSTITUTE OF TECHNOLOGY AND SCINCE PILANI-HYDERABAD

TABLE OF CONTENTS

Page No.
3

1)Block Diagram

3
3
4
4
5
6
7
7
7
8

1.1 8051(AT89C51)
1.2 Temperature sensor(LM35)
1.3 ADC 0808
1.4 7 Segment display
2)Working
3)Simulations
4)Snapshots
5)Conclusion
6)Application

Page No.
3

7)Future work

8)Appendix

LIST OF FIGURES
1)Fig1

5
5

2)Fig2
3)Fig3
4)Fig4
5)Fig5

6
7

6)Fig6
7)Fig7

ABSTRACT
This project is used to control the fan speed according to the temperature and it also
indicates the temperature. The system will get the temperature sense from the
temperature measuring IC corresponding to which temperature digits are obtained and
displayed and it will control the speed of fan according the duty cycle(PWM) values
stored in a lookup table according to the temperature measured .

Hardware tools :- microcontroller AT89C51, Temperature measuring IC (LM35),


resistors, capacitors,7 segment displays, motor(fan), power supply ,op amp ic, ADC
0808.

1. Block Diagram

Fig 1(schematic block diagram of temperature controlled fan)


3

Description :-As in Fig 1,the block diagram contains 8051 microcontroller, power
supply and reset circuit ,8 bit ADC ,temperature sensor LM35,motor driver L293D,
and DC motor(bipolar),sensor opamp circuit for generating interrupt(to enable or
disable entire operation) ,input switches for manual operation and display devices(7
segment).The flow of program is as power supply is provided to motor
driver,8051,switches and ADC0808.The measured temperature is given to ADC and
converted digital data from ADC is given to 8051 for further operation, display and
speed variation, motor is driven by driver circuit.
1.1

8051(AT89c51) :- AT89C51 is a 8 bit microcontroller belongs to INTELs


8051 family. It has 16 bits of address,128 bytes of RAM, two 16 bit
timer/counter, 6 interrupt(2 external hardware interrupt INT1and INT2),4k bytes
of ROM, which can be extended up to 64Kbytes.It has got wide variety of
instructions like data transfer, arithmetic and logical instruction. In addition it
has feature of branch instruction, serial communication, timer feature and ISR
execution.

1.2

Temperature sensor (LM 35):-

The LM35 series are precision


integrated-circuit temperature sensor, whose output is linearly proportional to
Celsius scale. The LM35(fig 2) does not require any external calibration or
trimming to provide accuracies of +-1/4 degree centigrade to +-3/4 centigrade
over -55 to +150 degree centigrade

Fig 2(LM35 Connection)


1.3

ADC0808:- The ADC0808, ADC0809 data acquisition component is a


monolithic CMOS device with an 8-bit analog-to-digital converter, 8-channel
multiplexer and microprocessor compatible control logic. The 8-bit A/D
converter uses successive approximation as the conversion technique. The
converter features a high impedance chopper stabilized comparator, a 256R
voltage divider with analog switch tree and a successive approximation register.
The 8-channel multiplexer can directly access any of 8-single-ended analog
signals. It has a total of eight analogue input channels, out of which any one can
be selected using address lines A, B and C. Here, in this case, input channel IN0
is selected by grounding A, B and C address lines,as shown in figure3 below.

Fig 3(ADC interfacing with 8051)


1.4

Seven Segment display: - A seven-segment display (SSD), or sevensegment indicator, is a form of electronic display device for displaying decimal
numerals that is an alternative to the more complex dot-matrix displays. Sevensegment displays are widely used in digital clocks electronic meters and other
electronic devices for displaying numerical information. For displaying each
alphanumeric code, 7 segments requires unique hex code.the schematic is as in
fig4 and 5 below.

DIGIT----
HEX CODE

0
7E

1
30

2
6D

Fig 4 (7 segment)

3
79

5
33

5
5B

6
5F

7
70

8
7F

9
7B

Fig 5(7 segment diagram)

2. Working: -

In fig 1 all the modules used are integrated, here is the working
description about project. Speed of fan is monitored by temperature variation. Basic idea
behind project is getting the temperature, displaying the temperature and change in
temperature is reflected as change in speed of fan. We are using LM35 temperature
sensor(shown in fig 2), whose output is given to ADC(see fig 3).The entire working is
enabled or disabled by external interrupt(so it acts as a switch)the interrupt signal is
generated by opamp sensor, which can be calibrated for different type of sensors.

The output of ADC used to select unique values of temperature from look up table in
program, based on different output values of ADC, different 2 digits value for temperature
representation are selected, which in turn are provided to display port. Display port includes
7 segment display devices(refer fig 4 and 5), where alphanumeric symbols/digits are
displayed using some special HEX code, preconfigured for 1 seven segment display. By
enabling one 7 segment at a time, no of digits can be displayed to several segments via just
one port. We are using two 7 segment display required to represent 2 digit temperature (Here
Celsius is taken by default)
Finally the displayed values from a temporary register are used to select the
distinguish delay according to digits. For speed variation we have used PWM concept which
in turn stands by duty cycle variation. Duty cycle variation needs, different on time and off
time duration, which are generated in program through delay generation logic, where value
of digit is inversely proportional to the delay value selected for off time delay from the speed
lookup table. This varying speed controls the running motion of dc motor. Further we have 2
modes of operation, manual and automatic, depending upon the status of active low input
switches, mode operation can selected.

3.Simulation :Example: - lets take the output of ADC as 42H=01000010B


Corresponding to this value 35 from the temperature table is selected and
displayed through the codes required at 7 segment display from display table. That
code here is ED for 3 and 2B for 5.Now one digit is displayed at a time through the
display port, which is connected to 7 segments.
Further for 3(msb digit) the delay value from speed table is selected, which
is 12 here, and for 5(lsb digit) it is 8.12 is added 5 times, as in code and then summed
with 8, so we get 5*12+8=68,which is value for off delay. The ondelay is 100-68= 32.
So duty cycle of pulse is 32/68=47.05%
Now suppose temperature is increased to 44 degree Celsius. Through similar
calculation we get duty cycle value as,
=>offtime=5*10+10=60,=>ontime =100-60=40, hence duty cycle=40/60=66.66%
(hence speed of the motor will increase)

4. Snapshots: - Fig 6(circuit schematic in Multisim)

Fig 7(hardware implementation)


5. Conclusion: -

The problem statement is implemented .Hardware part is halfway


implemented. Through simulations and after running the code in IDE abstract is verified.

6. Application:-This project can be use everywhere where power consumption has to be


controlled. In home appliance, at institutes, firms, organizations, industries (to regulate
output things via temperature).In computers, it can be use to cool the processor, as it gets
heated, the speed of fan can be made proportional to the temperature rise and fall.

7. Future work:-This

concept can be utilized further, by interfacing it with more


devices, like Air conditioner, etc..

8.

APPENDIX
CODE:
;------------------------------------------;
;

SPDT

= Auto/Manual

SW2

= Off

SW3

= fcheck

;
;------------------------------------------off

equ

P1.0 // switch off, motors/fan will off if switch is off, active low switch

fcheck equ P1.1 // switch fcheck ,active low, if enabled vary the speed of fan according to
temperature value

automanualequ

P1.2

// active low switch ,if switch is off do automatic

operation,otherwise manual
8

soc

equ

P3.1

// start of conversion for adc

read equ

P3.0

// read the content of adcport

EXT_SIGNL equ
mode equ

20H

done

21H

equ

P3.3

// INT1 interrupt used to enable or disable operation

// mode, automatic if set and manual if it is reset


// a ram location used for interrupt ISR,for enabling and disabling

operation
adc

equ

30H

// a ram location used to store the values from adcport

adcport equ

P2

scratchpad
disp

equ

equ
P0

40H

// adcport
// a random ram location used for storage purpose in program

// 7 segment display port

dc_mot1_t1

equ

p1.3

// terminal 1 of dc motor

dc_mot1_t2

equ

p1.4

// terminal 2 of dc motor

org 0H

//start of the program, PC initialization

sjmp start

//skip the interrupt vector location, jump to start(main program)

org 13H

// INT1 vector location

setb done
reti

// return from the interrupt

start:
clr EXT_SIGNL

// resetting all bits at initialization

clr done
clr mode
mov IE,#10000011B
scan:
acall read_temp

//call read_temp subroutine, used to measure the

temperature values from adcport


9

JNB automanual, auto

// deciding to do automatic or manual operation

based upon switch status


clr mode

//if manual clear the mode

sjmp manual

// jump to manual operation

auto:
setb mode

// otherwise set the mode bit for automatic operation

manual:
JB mode,inauto

//if mode is set operation is automatic otherwise manual

JNB off,fanoff

//manual:if off is enabled, go to subroutine fanoff

JNB fcheck,fanspeed

//manual:if fcheck is enabled vary the speed of fan

sjmp scan

//start scan for new data processing

fanoff:
clr dc_mot1_t1

// off the fan

clr dc_mot1_t2
back:
JNB off,back
sjmp scan

// if switch off is enabled stay in loop


//otherwise start again for new data

fanspeed:
mov DPTR,#Sptable

// load the speedtable in dptr, which signifies

delay count,
according to temperature for varying duty cycle
according to temperature
acall temp_checker
setb dc_mot1_t1

// call the temp_checker subroutine


// start the dc motor(running)

clr dc_mot1_t2
acall ondelay
clr dc_mot1_t1

// call ondelay
// stop dc motors/fan

clr dc_mot1_t2
acall offdelay

// call offdelay

sjmp scan

// start the new operation

inauto:
10

mov a,adc

//copy the adc(temperature value) data into reg A

clr c
cjne a,#30H,chk

//compare the temperature with 30,if not equal


jump to check whether the temperature is greater or lesser
than 30 if greater vary the speed of fan according to
temperature value,otherwise
off the fan

chk:
jc fanoff
clr c
sjmp fanspeed

// if carry generated(temp<30)off the fan


// clear the carry flag
// otherwise jump to fanspeed subroutine,to vary the speed of

fan acc to temperature


read_temp:
clr soc
nop
setb soc
here: jnb done,here

// start the adc


// if interrupt occurred, enable the operation, otherwise

stay here
clr done
clr read
mov a,adcport
setb read
mov dptr,#ttable
movc a,@a+dptr

// enable read operation from adc


//copy the content of adcport in A
// disable read operation now
//load the temperature table in dptr
//acc to adc value, temperature values are choosen,and

copied to A
mov adc,a
mov dptr,#dtable
swap a
anl a,#0FH

//copying the temperature value to adc ram


// load the display values table in dptr
// swap the content(temperature value) of A
// MASK THE LOWER BYE(ACTUAL UPPER DIGIT

OF TEMPERATURE VALUE)
11

movc a,@a+dptr

// copying the corresponding display(hex code for 7

segment) in A
mov adcport,#00

// declare adcport as output port(used to enable the 7

segments, dual purpose)


mov adcport,#1000b
mov disp,a

// enabling the 1st 7 segment display


// copy the hex code(for display digit acc to code) in

display port(7 segment)


acall delay
mov adcport,#00

// call normal delay


// declare adcport as output port(used to enable the 7

segments, dual purpose)


mov adcport,#0100b

// enabling the 2nd 7 segment display

mov a,adc

//copying the temperature value to adc ram

anl a,#0FH

// MASK THE LOWER BYE

movc a,@a+dptr

// copying the corresponding display(hex code for 7

segment) in A
mov disp,a

// copy the hex code(for display digit acc to code) in

display port(7 segment)


acall delay

// call normal delay

ret
ondelay: /*computing ondelay by subtracting the offdelay count from 100
mov r4,#100 basically calculating different duty cycle value and thus using pwm,
varying the speed, according to temperature for which distinguish delay
is generated using temp_check subroutine and sptable */
mov a,r4
subb a,r2
bigloop1:
mov r3,#50h
djnz r3,$
dec a
jnz bigloop1
ret
12

offdelay:
mov scratchpad, r2

//offdelay is computed via sptable delay count

and

temp_check subroutine
bigloop2: mov r3,#50h
loop:

djnz r3,loop
djnz r2,bigloop2
mov r2, scratchpad
ret

delay:
mov r6,#20

// normal delay

wait:
mov r5,#255
djnz r5,$
djnz r6,wait
ret
temp_checker:

// subroutine used to generate different offdelay regarding

different temperature value


clr c
mov r2,#00

// initializing r2 with 0

mov r1,#5

// a normal assumed count

mov a, adc

// copying the content of adc(temperature) in A

swap a

// swap the reg A content

anl a,#0fh

// mask the lower nibble(higher digit,as it swaped)

movc a,@a+DPTR
go:

addc a,r2

// copy the speed table content to a,acc to temp digit


// add content of a(sptable delay value) 5 times to itself to have

a considerable delay count


djnz r1,go
mov r2,a
mov a,adc
anl a,#ofh

// copy content of A to r2
// again load value of adc to A
// mask lower nibble
13

movc a,@a+DPTR
add a,r2
mov r2,a

// copy the speedtable content to A,acc to temp digit

//add the content of a with r2,to get final delay sum for off delay
// copy it to r2

ret
org 300h

// temperature table, values chose acc to adc values

ttable: DB 25 26 27 28 29 30 31 32
DB 33 34 35 36 37 38 39 40
DB 41 42 43 44 45 46 47 48
DB 49 50 51 52 53 54 55 56
DB 57 58 59 60 61 62 63 64
DB 65 66 67 68 69 70 71 72
DB 73 74 75 76 77 78 79 80
DB 81 82 83 84 85 86 87 88
DB 89 90 91 92 93 94 95 96 97
DB 97 98 99 100 101 102 103 104
DB 105 106 107 108 109 110 111 112
DB 113 114 115 116 117 118 119 120
org 400h

// 7 segment hex code reqd to display corresponding digits from 0 to 9

dtable: DB 54 32 78 ED 4F 2B 8E 6C AC D4
ORG 500H

//speedtable,have delay values corresponding to digit from 0 to 9

Sptable: DB 18 16 14 12 10 8 6 4 2 1
END

14

Potrebbero piacerti anche