单片机最小系统部分:
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" />ADC0809的A/D采样部分:
四位LED数码管显示部分:
<?xml:namespace prefix = w ns = "urn:schemas-microsoft-com:office:word" />
单片机串口通信电路:
温度采集部分:
报警电路: 温控模拟部分(没有加热和冷却设备,只好模拟,达到实验目的就行):
以下是程序:
;显示区地址分别为63H,62H,61H,60H
;上限温度地址分别为2EH,2DH,2CH
;下限温度地址分别为2BH,2AH,29H
;用到的位地址有00H,01H,30H
; ===============主程序===============
ORG 0000H
LJMP <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />MAIN
ORG 0003H
LJMP INT0
ORG 0030H
MAIN: MOV SP,#70H ;置初值
CLR P1.7
MOV R0,#40H
SETB PSW.4
SETB PSW.3
SETB IT0
SETB EA
SETB EX0
MOV TMOD,#20H ;波特率9600
MOV TH1,#0FDH
MOV TL1,#0FDH
SETB TR1
MOV SCON,#50H
SETB TI
CLR 30H
CLR 01H
SETB P1.7
CLR P1.6
CLR P1.5
MOV DPTR,#0BFFFH
MOV A,#00H
MOV 2EH,#0
MOV 2DH,#0
MOV 2CH,#0
MOV 2BH,#0
MOV 2AH,#0
MOV 29H,#0
MOV 62H,#0
LOOP: MOV DPTR,#0BFFFH
MOVX @DPTR,A ;启动A/D转换
CLR 00H
WAIT: LCALL XUAN
CHAXUN:JNB P1.3,LOOP1 ;调整
JNB P1.4,LOOP2
JNB 00H,GG ;判断是否再启动
LJMP LOOP
GG: LJMP WAIT
;===========上限温度调整===========
LOOP1: CLR EX0
LCALL DELAY1
JNB P1.3,$
MOV 62H,2EH
MOV 61H,2DH
MOV 60H,2CH
JB P1.2,M2
MOV A,2EH
ADD A,#01
DA A
MOV 2EH,A
CJNE A,#10H,M1
MOV 2EH,#00
M1: JNB P1.2,$
M2: JB P1.1,M4
MOV A,2DH
ADD A,#01H
DA A
MOV 2DH,A
CJNE A,#10H,M3
MOV 2DH,#00
M3: JNB P1.1,$
M4: JB P1.0,M5
MOV A,2CH
ADD A,#01
DA A
MOV 2CH,A
CJNE A,#10H,M5
MOV 2CH,#00
M5: JNB P1.0,$
SETB 30H ;是否显示第一位的标志位
MOV 63H,#11H ;显示“上”
MOV 62H,2EH
MOV 61H,2DH
MOV 60H,2CH
LCALL DELAY
JNB P1.3,TUI ;再次中断时,退出
LJMP LOOP1
;==========下限温度调整===========
LOOP2: CLR EX0
JNB P1.3,$
MOV 62H,2BH
MOV 61H,2AH
MOV 60H,29H
JB P1.2,L2
MOV A,2BH
ADD A,#01
DA A
MOV 2BH,A
CJNE A,#10H,L1
MOV 2BH,#00
L1: JNB P1.2,$
L2: JB P1.1,L4
MOV A,2AH
ADD A,#01H
DA A
MOV 2AH,A
CJNE A,#10H,L3
MOV 2AH,#00
L3: JNB P1.1,$
L4: JB P1.0,L5
MOV A,29H
ADD A,#01
DA A
MOV 29H,A
CJNE A,#10H,L5
MOV 29H,#00
L5: JNB P1.0,$
SETB 30H ;是否显示第一位的标示位
MOV 63H,#0FH ;显示“下”
MOV 62H,2BH
MOV 61H,2AH
MOV 60H,29H
LCALL DELAY
JNB P1.4,TUI ;再次中断时,退出
LJMP LOOP2
TUI: MOV A,2BH
CLR C
CJNE A,2EH,AA ;比较上限是否低于下限
MOV A,2AH
CJNE A,2DH,AA
MOV A,29H
CJNE A,2CH,AA
LJMP XXX ;正常
AA: JNC ERRO ;上限低于下限,跳转
XXX: SETB EX0
MOV A,@R0
LCALL XUAN
LJMP WAIT
ERRO: MOV 63H,#0EH ;显示“ERRO“
MOV 62H,#15H
MOV 61H,#15H
MOV 60H,#0H
SETB 30H
SETB 01H
EEEE: LCALL DELAY
JNB P1.3,XX1 ;是否重新调整
JNB P1.4,XX2
LJMP EEEE
XX1: LJMP LOOP1
XX2: LJMP LOOP2
;==========显示数据转换=========
Xian: MOV A,@R0
MOV B,#100
MUL AB
MOV R3,A
MOV A,B
MOV B,#10
DIV AB
MOV R1,#62H
MOV @R1,A
DEC R1
MOV @R1,B
MOV A,R3
MOV B,#10
MUL AB
DEC R1
MOV @R1,B
CLR 30H
ACALL DELAY
MOV A,2EH
CJNE A,62H,E1
MOV A,2DH
CJNE A,61H,E1
MOV A,2CH
CJNE A,60H,E1
LJMP E2
E1: JC SHANG_BAO
LJMP E2
;======超上限温度报警======
SHANG_BAO:
SETB P1.7
SETB P1.6
CLR P1.5
LJMP X2
E2: CLR P1.5
CLR P1.6
CLR P1.7
X1: MOV A,2BH
CJNE A,62H,E3
MOV A,2AH
CJNE A,61H,E3
MOV A,29H
CJNE A,60H,E3
LJMP E4
E3: JNC XIA_BAO
LJMP E4
;======低于下限温度报警======
XIA_BAO:SETB P1.7
SETB P1.5
CLR P1.6
LJMP X2
E4: CLR P1.5
CLR P1.6
CLR P1.7
X2: CLR 30H
ACALL DELAY
;========串口通信=========
MOV R3,#30H ;转ASCII码
MOV A,62H
ADD A,R3
DA A
MLP3: JBC TI,MLP2 ;当TI为1时清0
SJMP MLP3
MLP2: MOV SBUF,A
MOV A,61H
ADD A,R3
DA A
MLP5: JBC TI,MLP4
SJMP MLP5
MLP4: MOV SBUF,A
MOV A,#46 ;小数点
MLP8: JBC TI,MLP9
SJMP MLP8
MLP9: MOV SBUF,A
MOV A,60H
ADD A,R3
DA A
MLP7: JBC TI,MLP6
SJMP MLP7
MLP6: MOV SBUF,A
MOV A,#32
MLP10: JBC TI,MLP11
SJMP MLP10
MLP11: MOV SBUF,A
RET
;==========延时加显示=========
DELAY: MOV R3,#0A0H
D00: ACALL DISPLAY
DJNZ R3,D00
RET
DISPLAY:JNB 30H,DD
MOV 30H,#40
MOV DPTR,#TAB0
MOV A,63H
MOVC A,@A+DPTR
MOV DPTR,#0F8FFH
D0: MOVX @DPTR,A
DJNZ 30H,D0 ;千位
DD: MOV 30H,#40
MOV DPTR,#TAB0
MOV A,62H
MOVC A,@A+DPTR
MOV DPTR,#0F9FFH
D1: MOVX @DPTR,A
DJNZ 30H,D1 ;百位
MOV 30H,#40
MOV DPTR,#TAB0
MOV A,61H
MOVC A,@A+DPTR
JB 01H,TT
ADD A,#80H
TT: MOV DPTR,#0FAFFH
D2: MOVX @DPTR,A
DJNZ 30H,D2 ;十位
MOV 30H,#40
MOV DPTR,#TAB0
MOV A,60H
MOVC A,@A+DPTR
MOV DPTR,#0FBFFH
D3: MOVX @DPTR,A
DJNZ 30H,D3 ;个位
RET
TAB0:DB3FH,06H,5BH,4FH,66H,6DH,7DH,07H,
; 0 1 2 3 4 5 6 7
7FH,6FH,77H,7CH,39H,5EH,79H,71H
; 8 9 A B C D E F
DB 76H,78H,38H,6EH,00H ,77H,
; H K L Y 无 R
DELAY12: MOV R4,00H
MOV R5,00H
X3: DJNZ R4,$
DJNZ R5,X3
RET
;-------中断0服务程序-------
INT0: PUSH A
PUSH PSW
MOV DPTR,#0BFFFH
MOVX A,@DPTR ;读A/D转换结果
MOV 2FH,#0FFH
CLR CY ;程序调整高低位
RLC A
JC N1
CLR 78H
N1: RLC A
JC N2
CLR 79H
N2: RLC A
JC N3
CLR 7AH
N3: RLC A
JC N4
CLR 7BH
N4: RLC A
JC N5
CLR 7CH
N5: RLC A
JC N6
CLR 7DH
N6: RLC A
JC N7
CLR 7EH
N7: RLC A
JC N8
CLR 7FH
N8: MOV A,2FH
MOV @R0,A
SETB 00H
POP PSW
POP A
RETI
;=======延时=======
DELAY1: MOV R6,#60
DE1: MOV R7,#248
MOV R7,$
DJNZ R6,DE1
RET
END
完了,可能不好理解。
当初通宵写得,写得很乱,用汇编写得也好痛苦!!!
用户224440 2009-5-15 19:10
用户395214 2008-12-7 21:56
用户147927 2008-5-12 13:34
用户138790 2008-4-11 15:49
你好 可以把你的这个论文还有程序给我发来吗?我在写毕业设计 谢谢!!!o(∩_∩)o...
ynangel@163.com我的邮箱谢谢你了 主要是程序哦!!!!!
用户1398162 2007-8-24 14:11
是完整的,用的是伟福
用户15267 2007-8-21 16:04
程序不完整啊!!你是用什么软件调的????
用户1398162 2007-8-7 18:01
用户1462848 2007-8-7 11:26
用户1398162 2007-8-2 11:34
呵呵,欢迎发上来,多多交流!!!
用户6061 2007-8-1 19:35
支持c语言~~~
改天我把c语言版的发上来!