proteus仿真图
51单片机温度控制高温低温报警汇编语言源程序:
- LED_0 EQU 30H
- LED_1 EQU 31H
- LED_2 EQU 32H
- ADC EQU 35H
- TCNTA EQU 36H
- TCNTB EQU 37H
- H_TEMP EQU 38H ;温度上限
- L_TEMP EQU 39H ;温度下限
- FLAG BIT 00H
- H_ALM BIT P3.0
- L_ALM BIT P3.1
- SOUND BIT P3.7
- CLOCK BIT P2.4
- ST BIT P2.5
- EOC BIT P2.6
- OE BIT P2.7
- ORG 00H
- SJMP START
- ORG 0BH
- LJMP INT_T0
- ORG 1BH
- LJMP INT_T1
-
- START: MOV LED_0,#00H
- MOV LED_1,#00H
- MOV LED_2,#00H
- MOV DPTR,#TABLE
- MOV H_TEMP,#153
- MOV L_TEMP,#77
- MOV TMOD,#12H
- MOV TH0,#245
- MOV TL0,#0
- MOV TH1,#(65536-1000)/256
- MOV TL1,#(65536-1000)MOD 256
- MOV IE,#8aH
- CLR C
- SETB TR0 ;为ADC0808提供时钟
- WAIT: SETB H_ALM
- SETB L_ALM
- CLR ST
- SETB ST
- CLR ST ;启动转换
- JNB EOC,$
- SETB OE
- MOV ADC,P1 ;读取AD转换结果
- CLR OE
- MOV A,ADC
- SUBB A,#77 ;判断是否低于下限
- JC LALM
- MOV A,H_TEMP
- MOV R0,ADC
- SUBB A,R0 ;判断是否高于上限
- JC HALM
- CLR TR1
- LJMP PROC
- LALM: ;低温报警
- CLR L_ALM
- SETB TR1
- CLR FLAG
- LJMP PROC
- HALM: ;高温报警
- CLR H_ALM
- SETB TR1
- SETB FLAG
- LJMP PROC
- PROC: MOV A,ADC ;数值转换
- MOV B,#100
- DIV AB
- MOV LED_2,A
- MOV A,B
- MOV B,#10
- DIV AB
- MOV LED_1,A
- MOV LED_0,B
- LCALL DISP
- SJMP WAIT
- INT_T0: CPL CLOCK ;提供ADC0808时钟
- RETI
- INT_T1: MOV TH1,#(65536-1000)/256
- MOV TL1,#(65536-1000)MOD 256
- CPL SOUND
- INC TCNTA
- MOV A,TCNTA
- JB FLAG,I1 ;判断是高温警报还是低温警报
- CJNE A,#30,RETUNE ;低温警报声
- SJMP I2
- I1: CJNE A,#20,RETUNE ;高温警报声
- I2: MOV TCNTA,#0
- INC TCNTB
- MOV A,TCNTB
- CJNE A,#25,RETUNE
- MOV TCNTA,#0
- MOV TCNTB,#0
- LCALL DELAY2
- RETUNE: RETI
-
- DISP: MOV A,LED_0 ;数码显示子程序
- MOVC A,@A+DPTR
- CLR P2.3
- MOV P0,A
- LCALL DELAY
- SETB P2.3
- MOV A,LED_1
- MOVC A,@A+DPTR
- CLR P2.2
- MOV P0,A
- LCALL DELAY
- SETB P2.2
- MOV A,LED_2
- MOVC A,@A+DPTR
- CLR P2.1
- MOV P0,A
- LCALL DELAY
- SETB P2.1
- RET
- DELAY: MOV R6,#10
- D1: MOV R7,#250
- DJNZ R7,$
- DJNZ R6,D1
- RET
- DELAY2: MOV R5,#20
- D2: MOV R6,#20
- D3: MOV R7,#250
- DJNZ R7,$
- DJNZ R6,D3
- DJNZ R5,D2
- RET
- TABLE: DB 3FH,06H,5BH,4FH,66H
- DB 6DH,7DH,07H,7FH,6FH
- END
复制代码
51单片机温度控制高温低温报警仿真工程文件和汇编源码下载:
55 Temperatuer Monitor.zip
(55.01 KB, 下载次数: 41)
|