Temperature Controlled Fan Report

53,985 views

Published on

Temperature Controlled Fan Report

  1. 1. “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 1
  2. 2. TABLE OF CONTENTS Page No.1)Block Diagram 1.1 8051(AT89C51) 3 1.2 Temperature sensor(LM35) 3 1.3 ADC 0808 3 1.4 7 Segment display 42)Working 43)Simulations 54)Snapshots 65)Conclusion 76)Application 77)Future work 78)Appendix 8LIST OF FIGURES Page No.1)Fig1 32)Fig2 43)Fig3 44)Fig4 55)Fig5 56)Fig6 67)Fig7 7 2
  3. 3. ABSTRACTThis project is used to control the fan speed according to the temperature and it alsoindicates the temperature. The system will get the temperature sense from thetemperature measuring IC corresponding to which temperature digits are obtained anddisplayed and it will control the speed of fan according the duty cycle(PWM) valuesstored 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, ADC0808. 1. Block Diagram Fig 1(schematic block diagram of temperature controlled fan) 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 3
  4. 4. segment).The flow of program is as power supply is provided to motordriver,8051,switches and ADC0808.The measured temperature is given to ADC andconverted digital data from ADC is given to 8051 for further operation, display andspeed variation, motor is driven by driver circuit.1.1 8051(AT89c51) :- AT89C51 is a 8 bit microcontroller belongs to INTEL’s 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. 4
  5. 5. Fig 3(ADC interfacing with 8051) 1.4 Seven Segment display: - A seven-segment display (SSD), or seven- segment indicator, is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot-matrix displays. Seven- segment 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---- 0 1 2 3 5 5 6 7 8 9HEX CODE 7E 30 6D 79 33 5B 5F 70 7F 7B Fig 4 (7 segment) 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) 5
  6. 6. Finally the displayed values from a temporary register are used to select thedistinguish delay according to digits. For speed variation we have used PWM concept whichin turn stands by duty cycle variation. Duty cycle variation needs, different on time and offtime duration, which are generated in program through delay generation logic, where valueof digit is inversely proportional to the delay value selected for off time delay from the speedlookup table. This varying speed controls the running motion of dc motor. Further we have 2modes of operation, manual and automatic, depending upon the status of active low inputswitches, 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) 6
  7. 7. Fig 7(hardware implementation)5. Conclusion: - The problem statement is implemented .Hardware part is halfwayimplemented. 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 becontrolled. In home appliance, at institutes, firms, organizations, industries (to regulateoutput things via temperature).In computers, it can be use to cool the processor, as it getsheated, 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 moredevices, like Air conditioner, etc.. 7
  8. 8. 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 switchfcheck equ P1.1 // switch fcheck ,active low, if enabled vary the speed of fan according totemperature valueautomanual equ P1.2 // active low switch ,if switch is off do automaticoperation,otherwise manualsoc equ P3.1 // start of conversion for adc 8
  9. 9. read equ P3.0 // read the content of adcportEXT_SIGNL equ P3.3 // INT1 interrupt used to enable or disable operationmode equ 20H // mode, automatic if set and manual if it is resetdone equ 21H // a ram location used for interrupt ISR,for enabling and disablingoperationadc equ 30H // a ram location used to store the values from adcportadcport equ P2 // adcportscratchpad equ 40H // a random ram location used for storage purpose in programdisp equ P0 // 7 segment display portdc_mot1_t1 equ p1.3 // terminal 1 of dc motordc_mot1_t2 equ p1.4 // terminal 2 of dc motororg 0H //start of the program, PC initializationsjmp start //skip the interrupt vector location, jump to start(main program) org 13H // INT1 vector location setb done reti // return from the interruptstart: clr EXT_SIGNL // resetting all bits at initialization clr done clr mode mov IE,#10000011Bscan: acall read_temp //call read_temp subroutine, used to measure the temperature values from adcport JNB automanual, auto // deciding to do automatic or manual operation based upon switch status 9
  10. 10. clr mode //if manual clear the mode sjmp manual // jump to manual operationauto: setb mode // otherwise set the mode bit for automatic operationmanual: 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 processingfanoff: clr dc_mot1_t1 // off the fan clr dc_mot1_t2back: JNB off,back // if switch off is enabled stay in loop sjmp scan //otherwise start again for new datafanspeed: 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 // call the temp_checker subroutine setb dc_mot1_t1 // start the dc motor(running) clr dc_mot1_t2 acall ondelay // call ondelay clr dc_mot1_t1 // stop dc motors/fan clr dc_mot1_t2 acall offdelay // call offdelay sjmp scan // start the new operationinauto: mov a,adc //copy the adc(temperature value) data into reg A clr c 10
  11. 11. 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 fanchk: jc fanoff // if carry generated(temp<30)off the fan clr c // clear the carry flag sjmp fanspeed // otherwise jump to fanspeed subroutine,to vary the speed of fan acc to temperatureread_temp: clr soc nop setb soc // start the adchere: jnb done,here // if interrupt occurred, enable the operation, otherwisestay here clr done clr read // enable read operation from adc mov a,adcport //copy the content of adcport in A setb read // disable read operation now mov dptr,#ttable //load the temperature table in dptr movc a,@a+dptr //acc to adc value, temperature values are choosen,andcopied to A mov adc,a //copying the temperature value to adc ram mov dptr,#dtable // load the display values table in dptr swap a // swap the content(temperature value) of A anl a,#0FH // MASK THE LOWER BYE(ACTUAL UPPER DIGIT OF TEMPERATURE VALUE) movc a,@a+dptr // copying the corresponding display(hex code for 7 segment) in A 11
  12. 12. mov adcport,#00 // declare adcport as output port(used to enable the 7 segments, dual purpose) mov adcport,#1000b // enabling the 1st 7 segment display mov disp,a // copy the hex code(for display digit acc to code) in display port(7 segment) acall delay // call normal delay mov adcport,#00 // declare adcport as output port(used to enable the 7segments, 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) indisplay port(7 segment) acall delay // call normal delay retondelay: /*computing ondelay by subtracting the offdelay count from 100mov 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,r2bigloop1: mov r3,#50h djnz r3,$ dec a jnz bigloop1 retoffdelay: 12
  13. 13. mov scratchpad, r2 //offdelay is computed via sptable delay count andtemp_check subroutinebigloop2: mov r3,#50hloop: djnz r3,loop djnz r2,bigloop2 mov r2, scratchpad retdelay: mov r6,#20 // normal delaywait: mov r5,#255 djnz r5,$ djnz r6,wait rettemp_checker: // subroutine used to generate different offdelay regardingdifferent 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 // copy the speed table content to a,acc to temp digitgo: addc a,r2 // add content of a(sptable delay value) 5 times to itself to havea considerable delay count djnz r1,go mov r2,a // copy content of A to r2 mov a,adc // again load value of adc to A anl a,#ofh // mask lower nibble movc a,@a+DPTR // copy the speedtable content to A,acc to temp digit 13
  14. 14. add a,r2 //add the content of a with r2,to get final delay sum for off delay mov r2,a // 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 120org 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 D4ORG 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

×