| The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers. |
HT49R50A-1 Using thermistor implement thermometer D/NHA0098E
Top Searches for this datasheetHT49R50A-1 Using thermistor implement thermometer HT49R50A-1 Using thermistor implement thermometer D/NHA0098E This application note uses HT49R50A-1 microcontroller. pins PC.0, PC.1 PC.2 used read value thermistor, implement thermometer function. temperature value will displayed LCD. temperature range from -40°C 100°C, with tolerance ±1°C. Description Create project, place files TEMP.ASM CALCULATE.ASM into project using [Project/Edit] menu. temperature displayed metric LCD, with format shown drawing below. first position indicate whether temperature positive negative, negative then negative then this position will illuminate, temperature positive then will extinguished. second position digit, third position units. fourth position decimal point. temperature outside range, -40°C 100°C, second, third fourth digit will illuminate connections shown table. Because type thermistors used have uniform characteristics, special note must taken TABLE TEMPERATURE table. Because program written, table will increase thermistor's value times. data stored from high low. defined parameters main program, temp.asm, TEMP_START_ADDR, TEMP_END_ADDR NUM, must also modified according thermistor/temperature table: HT49R50A-1 Using thermistor implement thermometer #DEFINE TEMP_START_ADDR 0F0AH #DEFINE TEMP_END_ADDR TEMP_START_ADDR+100-(-40) #DEFINE TEMP_START_ADDR-(-40) Note: start address TEMP_END_ADDRTABLE_TEMPERATURE address NUM: measurable range SEG0 SEG1 SEG2 SEG3 SEG4 SEG5 SEG6 SEG7 COM0 COM1 COM2 COM3 Table SEG31 HT49R50A-1 Using thermistor implement thermometer Application Circuit HT49R50A-1 Using thermistor implement thermometer Function Description above circuit, precision reference resistor, also thermistor while capacitor. principles operation follows: after completely discharged, alone used again charge until high level PC.2 reached. timer will measure this time again fully discharged, charged thermistor When high level PC.2 reached this value measured From capacitor voltage equation, VC=V0(1-e-T/RC) derive that RK/T1. program used determine thermistor's resistance value, after which table consulted obtain corresponding temperature value. source temperature errors will come from, timer precision, precision thermistor precision. using program execute multi charge discharge cycles, then taking average measured times, measured error reduced. Flowchart MAIN Flow Chart Start Reset bank1 Reset bank0 Start Call SBR_RT Subroutine Call SBR_TEMP_DISPLAY Subroutine Return measure temp. HT49R50A-1 Using thermistor implement thermometer SBR_RT Subroutine Flow Chart SBR_RT Place into R_P_C L_TEST_T subroutine obtain time, charge capacitor with thermistor Multiply time Multiply above value 100, result r_num,r_tmr1,r_tmr0 clear, r_num_8 reload with Place into R_P_C Call L_TEST_T subroutine obtain time, charge capacitor with reference resistor Implement division calculation obtain times value thermistor value HT49R50A-1 Using thermistor implement thermometer SBR_TEMP_DISPLAY Subroutine Flow Chart SBR_TEMP_DISPLAY TBLP points temperature table start address Read temperature table high values store R_TBLH, R_TABLE_L (R_TBLH, R_TABLE_L) (R_RT_H, R_RT_L)? Clear Flag FLAG_EQU TBLP->R_TBLP Calculate value FLAG_EQU Clear R_DOT C<0? TBLP=TEMP_ START_ADDR? TBLP=TEMP_ END_ADDR? Calculate BP.1, 40H-46H clear Keep TO0->R_TO0 TO1->R_TO1 TBLP->R_TBLP Keep TO0->R_NUM0 TO1->R_NUM1 41H->MP1, R1.2 Temperature display TBLP+1 MP1+2->MP1, R1.2 Temperature units display Calculate (R_NUM1,R_NUM0)+ (R_TO1R_TO0)= (R_SUM1,R_SUM0) MP1+2->MP1, R1.2 Temperature decimal point (R_RT_H,R_RT_l) =(ZERO_H,ZERO_L)? (R_RT_H,R_RT_l) <(ZERO_H,ZERO_L)? display negative sign Display negative sign display negative sign FLAG_EQU=1? (R_TO1,R_TO0)-> (data1,data0), call L_DOT (R_NUM1, R_NUM0) ->(data1,data0) Call L_DOT FLAG_EQU=1? R_TBLP=TEMP_ END_ADDR? TBLP->R_TBLP R_TBLP-NUM ->R_TBLP 9->R_ITEM, 40H->MP1 Call L_TEMP_DISLOOP, display location NUM-R_TBLP->R_TBLP MP1+1->MP1, Call L_TEMP_DISLOOP, display units location L_16_to_10 MP1+1->MP1, call L_TEMP_DISLOOP, display decimal location HT49R50A-1 Using thermistor implement thermometer L_16_TO_10 Label Flow Chart L_16_TO_10 R_TBLP>10? R_RT_H+1,R_TBLP-10->R_TBLP BP.0,R_RT_H->R_ITEM,40H->MP1 Call L_TEMP_DISLOOP, Display temperature value MP1+1,R_TBLP->R_ITEM Call L_TEMP_DISLOOP, Display temperature units value MP1+1,R_DOT->R_ITEM Call L_TEMP_DISLOOP, Display temperature decimal value L_TEMP_DISLOOP Subroutine Flow Chart L_TEMP_DISLOOP TBLP,R_ITEM->TBLP Read table instruction, store result R_TABLE_L Mask highest 4-bits, place result location indicated MP1+1->MP1 Swap high nibble R_TABLE_L, mask highest four bits, place result location indicated HT49R50A-1 Using thermistor implement thermometer L_TEST_T Subroutine Flow Chart L_test_T output discharge delay r_numtmr0, tmr1 clear resistor charge capacitor Start timer0 timer1, start counting PC.2=1? Stop timer0 timer1, place result r_num, r_tmr1, r_tmr0 r_coun_8-1=0? Implement division calculation, calculate average times L_DOT Subroutine Flow Chart L_DOT Implement multiplication calculation (R_TO1,R_TO0 R_NUM1,R_NUM0)*10 Implement division calculation, above result (R_SUM2, R_SUM1) TO0->R_DOT HT49R50A-1 Using thermistor implement thermometer Program Example ****************File Name: Temp.Asm (main program)**************** ;;Client: ;;ID Code: ;;HT_ICE Version: ;;HT_IDE Version: V6.6 ;;Program Name: Temp.Prj ;;Program Version: ;;Established Date: 2005/08/11 ;;Programmer: Song ;;-;;Main Function: Test Temperature ;;MCU Body:Ht49r50 ;;VDD: ;;MCU Frequency: 8MHz ;;-;;Mask Option: ;Vdd 5.00V ;OSC: Crystal ;Fsys: 8MHz ;Package: QFP-A ;Wdt: Disable ;Clr Wdt: Clear Instruction ;Wake_Up PA0-7: Wake ;Pull-high Nmos&PULL-HIGH ;Pull-high Nmos&NON-PULL-HIGH ;Timer0 clock source: System clock ;Timer1 clock source: Timer0 overflow ;TMR0&TMR1 PFD: Disable ;Clock source: OSC(12K) ;BZ/BZB: Disable ;LCD duty: duty ;LVR: Disable ;LVD: Disable #INCLUDE HT49R50A-1.INC #INCLUDE MACRO.ASM #INCLUDE CALCULATE.INC #DEFINE #DEFINE #DEFINE #DEFINE ZERO_H ;;the high byte degree #DEFINE ZERO_L ;;the byte degree #DEFINE TEMP_START_ADDR 0F0AH ;;the start address temperature ;;table HT49R50A-1 Using thermistor implement thermometer TEMP_START_ADDR+100-(-40) ;;the address temperature table ;;100:the highest temperature tested; #DEFINE TEMP_START_ADDR-(-40) ;;-40:the lowest temperature tested DATA.SECTION DATA ACCBAK ;;save registor value STATUSBAK ;;save status registor value FLAG_EQU DBIT ;;compare temperature flag R_P_C ;;rigistro BUF1 ;;registor delay BUF2 ;;registor delay BUF3 ;;registor delay R_TBLP ;;save tblp value R_TBLH ;;save high byte table code R_TABLE_L ;;save byte table code R_RT_L ;;the byte summation R_RT_H ;;the high byte summation temperature R_RT ;;the (16~23)bit summation R_ITEM ;;registor diaplay subroutine R_TO0 ;;save R_TO1 ;;save R_TO2 ;;save R_TO3 ;;save R_COMPARE ;;for compare R_NUM ;;for calculate&interrupt time R_NUM1 ;;for calculate R_NUM2 ;;for calculate R_SUM1 ;;for calculate R_SUM2 ;;for calculate R_DOT ;;the decimal temperature R_COUN_8 ;;for times cycle R_COUN_4 ;;for times cycle R_TMR0 ;;the byte charging time ;;summation R_TMR1 ;;the high byte charging time ;;summation RC_NUM ;;the(16~23)bite charging time ;;summation #DEFINE TEMP_END_ADDR HT49R50A-1 Using thermistor implement thermometer MAIN.SECTION CODE MAIN ISR_TIMEBASE ISR_TMR1 ;;timebase interrupt vector ISR_TMR0 ;;timer1 interrupt vector ISR_EXTINT1 ;;timer0 interrupt vector ISR_EXTINT0 ;;external int1 interrupt vector ;;external int0 interrupt vector ;;rtc interrupt vector ISR_RTCC MAIN: CALL INI_LCD_RAM ;;initial bank1 CALL INI_RAM ;;initial band0 CALL INI_IO ;;initial CALL SBR_RT ;;get value CALL SBR_TEMP_DISPLAY ;;display temperature with ;;run again ISR_EXTINT0: ;;(no used)04 interrupt PUSH RETI ISR_EXTINT1: ;;(no used)08 interrupt PUSH RETI ISR_TMR0: ;;(no used)0c interrupt PUSH RETI HT49R50A-1 Using thermistor implement thermometer ISR_TMR1: ;;10 interrupt PUSH R_NUM RETI ISR_TIMEBASE: ;;(no used)14 interrupt PUSH RETI ISR_RTCC: ;;(no used)18 interrupt PUSH RETI #INCLUDE SUBROUTINE.ASM ***********File Name: Subroutine .Asm *************** ;;-INI_RAM: initial bank ram-INI_RAM: ;;initial bank BP.0 ;;bp point bank XMOV MP0, ;;ram start address ;;ram address XMOV XMOV XMOV XMOV XMOV XMOV INTC0, INTC1, TMR0C, TMR1C, 0A0H ;;enable gloable interrupt ;;enable timer1 interrupt ;;timer0 mode:timer mode select ;;system clock source ;;timer1 mode:timer mode&mask option ;;clock source R_COUN_8,8 R_COUN_4,4 HT49R50A-1 Using thermistor implement thermometer ;-INI_LCD_RAM:initial bank RAM-INI_LCD_RAM: ;;initial bank BP.0 ;;bp point bank XMOV MP1, ;;ram start address EJMP MP1, ;;ram address XMOV MP1, ;;lighten radix point[46H].1 ;;(seg6&com1) R1.1 ;;-INI_LCD_RAM:initial bank RAM-INI_IO: ;;initial ;;initial input port ;;-SBR_RT:get value RT-SBR_RT: ;;get value XMOV R_P_C, ;;charge with pc.1 CALL L_TEST_T ;;test charge time(T2) XMOV DATA0, ;;the average charge time(T2) ;;(to2 to0) XMOV DATA1, XMOV DATA2, ;;multiplicand(data2 data1 data0) XMOV DATA4, ;;multiplier(data6 data5 data4) DATA5 DATA6 CALL UNBIN_MUL_24 XMOV DATA0, ;;the result multiplication ;;(to3 to0) XMOV DATA1, XMOV DATA2, XMOV DATA3, ;;multiplicand ;;(data3 data2 data1 data0) XMOV CALL XMOV XMOV XMOV XMOV DATA4, DATA5 DATA6 DATA7 UNBIN_MUL_32 R_TO0, R_TO1, R_TO2, R_TO3, ;;multiplier(data7 data6 data5 data4) ;;T2*10*100 ;;the result multiplication ;;(to3 to0) ;;save HT49R50A-1 Using thermistor implement thermometer R_TMR0 R_TMR1 RC_NUM ;;clear next XMOV R_COUN_8,8 L_AVER4: XMOV R_P_C, ;;charge with pc.0 CALL L_TEST_T ;;test charge time(T1) XMOV XMOV XMOV XMOV XMOV XMOV XMOV DATA4, DATA5, DATA6, DATA7 DATA0, DATA1, DATA2, DATA3, R_TO0 R_TO1 R_TO2 R_TO3 ;;the average charge time(T1) ;;(to2 to0) ;;divisor(data4 data5 data6 data7) ;;dividend(data3 data2 data1 data0) CALL UNBIN_DIV_32 ;;devision XADDM R_RT_L,TO0 ;;summation XADCM R_RT_H,TO1 XADCM R_RT, XMOV R_COUN_8,8 ;;for next R_TMR0 R_TMR1 RC_NUM ;;clear next R_COUN_4 ;;for times SBR_RT R_RT ;;/2 R_RT_H ;;/2 R_RT_L ;;/2 R_RT ;;/2 R_RT_H ;;/2 R_RT_L ;;/2 L_TEST_T: ;;test charge time XMOV P_C, ;;discharge completely CALL DELAY_2mS ;;delay XMOV R_NUM TMR1C.4 TMR1C.4 TMR0 TMR1 P_C, R_P_C ;;clear timer0&timer1 preload ;;registor ;;charge with PC.x port HT49R50A-1 Using thermistor implement thermometer TMR0C.4 TMR1C.4 P_C, P_C.2 ;;timer0 ;;timer1 ;;wait charge finished TMR0C.4 ;;timer0 TMR1C.4 ;;timer1 XADDM R_TMR0,TMR0 ;;the summation time XADCM R_TMR1,TMR1 XADCM RC_NUM,R_NUM R_COUN_8 ;;for times L_TEST_T XMOV DATA0, R_TMR0 ;;dividend(data2 data1 data0) XMOV DATA1, R_TMR1 XMOV DATA2, RC_NUM XMOV DATA4, ;;divisor(data4 data5 data6) DATA5 DATA6 CALL UNBIN_DIV_24 ;;division ;;-SBR_TEMP_DISPLAY:chart table display temperature-SBR_TEMP_DISPLAY: ;;chart table display ;;temperature XMOV TBLP, TEMP_START_ADDR ;;tblp point first address ;;temperature table L_TABLE_COMPARE: TABRDL R_TABLE_L ;;low byte table coder_table_l XMOV R_TBLH,TBLH ;;high byte table coder_tblh EJMP TBLH, R_RT_H ;;if equals value table L_NEQU EJMP R_TABLE_L,R_RT_L L_NEQU XMOV R_TBLP,TBLP L_EQU L_EQU: ;;when equals value table FLAG_EQU ;;set equal flag R_DOT L_ZERO_COMP L_NEQU: ;;if unequal FLAG_EQU ;;clr equal flag XMOV DATA0, R_TABLE_L ;;minuend XMOV DATA1, R_TBLH XMOV DATA4, R_RT_L ;;subtrahend XMOV DATA5, R_RT_H CALL UNBIN_SUB_16 ;;compare table value with HT49R50A-1 Using thermistor implement thermometer NEJMP L_NEXT ;;if bigger than TBLP, TEMP_START_ADDR ;;if less than RT&if tblp point ;;the biggest L_TEMP_OVER ;;if over range table L_GET_TEMP ;;if ;;tblp point next address TBLP, TEMP_END_ADDR ;;if tblp point smallest L_TEMP_OVER ;;if excess range table R_TO0, ;;if save r_to0 R_TO1, ;;save r_to1 R_TBLP,TBLP ;;save tblp TBLP ;;point next address L_TABLE_COMPARE ;;compare again ;;figure temperature ;;minuend(data1 data0) ;;subtrahend(data5 data4) ;;subtration ;;save r_num1 ;;save r_num2 ;;augend(data1 data0) ;;addend(data5 data4) ;;addition(r_num2,r_num1) ;;+(r_to1,r_to0) ;;(r_num2,r_num1)+(r_to1,r_to0) ;;=(r_sum2,r_sum1) ;;compare with zero L_NEXT: NEJMP XMOV XMOV XMOV L_GET_TEMP: XMOV XMOV XMOV XMOV CALL XMOV XMOV XMOV XMOV XMOV XMOV CALL XMOV XMOV DATA0, R_RT_L DATA1, R_RT_H DATA4, R_TABLE_L DATA5, R_TBLH UNBIN_SUB_16 R_NUM1, R_NUM2, DATA0, R_NUM1 DATA1, R_NUM2 DATA4, R_TO0 DATA5, R_TO1 UNBIN_ADD_16 R_SUM1,TO0 R_SUM2,TO1 L_ZERO_COMP: EJMP R_RT_H,ZERO_H L_UNEQU_ZERO EJMP R_RT_L,ZERO_L L_UNEQU_ZERO L_EQU_ZERO: BP.0 XMOV MP1, R1.0 L_OVER_LOOP ;;equal zero ;;unlighen sign ([46H].0) HT49R50A-1 Using thermistor implement thermometer L_UNEQU_ZERO: XMOV DATA0, R_RT_L XMOV DATA1, R_RT_H XMOV DATA4, ZERO_L XMOV DATA5, ZERO_H CALL UNBIN_SUB_16 L_LOW_ZERO: XMOV XMOV XMOV CALL XMOV L_LOW_lOOP: L_LOW_ZERO L_OVER_ZERO ;;uneaual zero ;;RT compares with 0b3a ;;(T degree) ;;if lower than zero ;;if higher than zero ;;if lower than zero BP.0 MP1, R1.0 FLAG_EQU L_LOW_lOOP DATA0, R_NUM1 DATA1, R_NUM2 L_DOT R_TBLP,TBLP ;;lighen sign ([46h].0) ;;judge integer ;;if integer ;;if ,then deal with ;;the decimal(T<0) ;;if degree,then address ;;is smaller ;;T<0 degree,then [T]=NUM-r_tblp R_TBLP R_TBLP,A R_RT_H L_16_to_10 ;;for next user ;;if not,then deal with ;;the decimal(T>0) L_OVER_LOOP: ;;T>0 degree,then [T]=r_tblp-NUM NEJMP R_TBLP,TEMP_END_ADDR ;;check temperature ;;is degree L_TEMP_100 ;;if 100,then jump R_TBLP ;;if ,[T]=r_tblp-NUM L_OVER_ZERO: BP.0 XMOV MP1, R1.0 FLAG_EQU L_OVER_LOOP XMOV DATA0, R_TO0 XMOV DATA1, R_TO1 CALL L_DOT ;;if higer than zero ;;unlighen sign ([46h].0) ;;judge integer ;;if integer HT49R50A-1 Using thermistor implement thermometer L_16_TO_10: LBERJ XMOV XMOV CALL XMOV CALL XMOV CALL R_TBLP,A R_RT_H R_TBLP,0AH R_RT_H R_TBLP,A L_16_to_10 BP.0 R_ITEM,R_RT_H MP1, SBR_TEMP_DISLOOP R_ITEM,R_TBLP SBR_TEMP_DISLOOP R_ITEM,R_DOT SBR_TEMP_DISLOOP ;;convert from decimal ;;r_tblp-0ah ;;if r_tblp-0ah<0 ;;if r_tblp-0ah>0 ;;(T)H={r_rt_h,r_tblp}D ;;the number ;;the adress ;;display ;;the adress ;;the number ;;display ;;the adress ;;the number ;;display ;;return displayed->r_item displayed displayed displayed->r_item displayed displayed->r_item L_TEMP_100: ;;if T=100,then display 99.9 BP.0 XMOV R_ITEM,9 XMOV MP1, CALL SBR_TEMP_DISLOOP ;;display CALL SBR_TEMP_DISLOOP ;;display CALL SBR_TEMP_DISLOOP ;;display L_TEMP_OVER: ;;if over testing range, ;;then display BP.0 XMOV MP1, ;;clear [40h]~[46h] EJMP MP1, XMOV MP1, ;;display R1.2 R1.2 R1.2 HT49R50A-1 Using thermistor implement thermometer L_DOT: ;;deal with decimal(num*10/sum) XMOV DATA4, ;;*10 DATA5 CALL UNBIN_MUL_16 XMOV DATA0, XMOV DATA1, XMOV DATA4, R_SUM1 XMOV DATA5, R_SUM2 CALL UNBIN_DIV_16 ;;/(sum2,sum1) XMOV R_DOT, ;;save r_dot SBR_TEMP_DISLOOP: ;;display pointed number pointed address TBLP ;;mp1->the pointed address XADDM TBLP, R_ITEM ;;number displayed->r_item TABRDL R_TABLE_L XAND R_TABLE_L,0FH ;;display number r_item saved SWAP R_TABLE_L XAND R_TABLE_L,0FH DELAY_2mS: ;;delay about XMOV BUF2, ;;recycle times BUF1 ;;32us time BUF1 BUF2 ;;-TABLE NUMBER TEMPERATURE-TABLE0 .SECTION 0F00H CODE;;the displayed code number0~9 03FH, 006H,05BH,04FH ;;0,1,2,3 066H, 06DH,07DH,007H ;;4,5,6,7 07FH, 06FH ;;8,9 TABLE_TEMPERATURE.SECTION 0F0AH CODE ;;-40~-31 ;;-30~-21 ;;-20~-11 HT49R50A-1 Using thermistor implement thermometer ;;-10~-9 ;;0~9 ;;10~19 ;;20~29 ;;30~39 ;;40~49 ;;50~59 ;;60~69 70~79 ;;80~89 ;;90~99 00090 ;;100 Other recent searchesW5641A - W5641A W5641A Datasheet SPB-8605LG - SPB-8605LG SPB-8605LG Datasheet SPB-8605BLG - SPB-8605BLG SPB-8605BLG Datasheet SPB-8605ALG - SPB-8605ALG SPB-8605ALG Datasheet NLB-400Cascadable - NLB-400Cascadable NLB-400Cascadable Datasheet LHRF2043-PF - LHRF2043-PF LHRF2043-PF Datasheet ISL59830 - ISL59830 ISL59830 Datasheet HS-5202C - HS-5202C HS-5202C Datasheet FYLF-1130UR1C - FYLF-1130UR1C FYLF-1130UR1C Datasheet FR30-005G - FR30-005G FR30-005G Datasheet FR30-10G - FR30-10G FR30-10G Datasheet BUL741 - BUL741 BUL741 Datasheet
Privacy Policy | Disclaimer |