微型计算机控制技术第9章习题答案.doc
《微型计算机控制技术第9章习题答案.doc》由会员分享,可在线阅读,更多相关《微型计算机控制技术第9章习题答案.doc(9页珍藏版)》请在冰点文库上搜索。
9-1设计一个智能温度检测仪,要求具有检测、显示、键盘、通信功能。
68K
+12V
10K
AD590
4.7K
15K
20K
-12V
0.01μf
-5V
+5V
6MHZ
C2
C1=30pf
10μf
+5V
10K
74LS04
1
74LS02
控制3#炉
控制2#炉
75452
220V
~
1#炉
100Ω
0.01μf
330Ω
330Ω3
+5V
5K×3
1111
1210
+5V
2
6
+
-
3
2
4
5
14
13
1
3
+5V
P2.6
ALE
P0
TXDWR
RD
RXD
89C51
P1.7
P1.6
P1.5P2.7
P1.0P3.2
RST
P1.1
XTAK2
P1.2
XTAL1
GQ0
74LS373
D0~D7Q1
D0~D7
VCC
VR+
ALE
START
OE
EOC
IN0
A
B
C
8255A
+5V
adpadp
┇
┇
·
·
CSPB7
A0
PB0
A1
PA0
D0~D7
WRPA0
RD
2
3+
5
6
11-
8
7
4
+
C1+VCC
V+
C1-V-
C2+
C2-T1IN
T1out
R1out
R1IN
R1out
PC机
RXD
TXD
+5V
一台智能温度检测仪,自动控制一个温室的温度要求如下:
①要求温室温度为三档,第一档为室温,第二档为400C,第三档为500C,要求温度控制误差2°C
②温度检测程序:
温度检测程序的功能是连续进行4次A/D转换求取转换结果的平均值,存入50H单元.
温度检测程序清单:
WIJC:
MOV50H,#00H
MOVB,#00H
MOVR6,#04H
CLRP2.7
W:
MOVX@R0,A
NOP
NOP
JNBP3.2,$
MOVXA,@R0
ADDA,50H
MOV50H,A
JNCW1
]INCB
W1:
CJNZR6,W
CLRC
XCHA,B
RRCA
XCHA,B
RRCA
CLRC
XCHA,B
RRCA
XCHA,B
RRCA
MOV50H,A
SETBP2.7
RET
标度变换程序:
BDBH:
MOVA,50H
MOVB,#04H
DIVAB
MOVB,#0AH
DIVAB
MOV30H,A
MOV31H,B
RET
显示程序:
DISP:
CLRP2.6
MOVR0,#00H
MOVR1,#30H
MOVDPTR,#TAB
LP:
MOVA,@R1
MOVCA,@A+DPTR
MOVX@R0,A
INCR0
INCR1
CJNER1,#32H,LP
SETBP2.6
RET
TAB:
DB0C0H,0F9H,0A4H
DB0B0H,99H,92H
DB82H,0F8H,80H
DB90H
DSQ0:
MOVTH0,#02H
MOVTL0,#18H
DJNZR7,EXIT
MOVR7,#0E7H
ACALLWBJC
ACALLBDBH
ACALLDISP
ACALLCONT
EXIT:
RET
温度控制程序清单:
CONT:
MOVA,50H
CLRC
SUBBA,51H
JCH0
SUBBA,#04H
JNCH1
RET
H1:
JNBP1.0,H2
CLRP1.0
RET
H2:
JNBP1.1,H3
CLRP1.1
RET
H3:
CLRP1.2
RET
H0:
CPLA
INCA
CJNEA,#04H,H5
H5:
JNCH6
RET
H6:
JBP1.2,H7
RET
H7:
JBP1.1,H8
SETBP1.1
RET
H8:
SETBP1.0
RET
KEY:
JBP1.7,L1
LCALLYS20MS
JBP1.7,$
MOV51H,#50H
L2:
JBP1.6,L3
LCALLYS20MS
JBP1.6,L3
JNBP1.6,$
MOV51H,#0AH
L3:
JBP1.5,L4
LCALLYS20MS
JNBP1.5,L4
JNBP1.5,$
MOV51H,#0C8H
L4:
RET
主程序:
ORG0000H
AJMPWAIN
ORG000BH
AJMPDSQ0
ORG0023H
AJMPTXID
ORG0030H
MAIN:
MOVSP,#60H
MOVP1,#0F0H
CLRP2.6
MOVR0,#03H
MOVA,#80H
MOV@R0,A
SETBP2.6
MOVTMOD,#21H
MOVTH0,#02H
MOVTH1,#18H
SETBET0
MOVTH1,#0FDH
MOVTL1,#0FDH
ANLPCON,#7FH
MOVSCON,#50H
CLRET1
SETBPS
CLRPT0
MOVR7,#0E7H
MOV51H,#50H
SETBTR1
SETBTR0
SETBES
SETBEA
LOOP:
LCALLKEY
LJMPLOOP
通信程序:
串口和微机通信:
微机始终是主动的,当单片机接收到一个数据后来判断,如果接收到是01H,就把单片机的检测值发送给微机,如果接收到是02H,就把从微机接收到的给定值,送给单片机的给定单元51H。
TXID:
CLRES
JBCRICOMM
SETBES
RETI
COMM:
MOVA,SBUF
CJNEA,#01H,RECEIVE
CLRTI
MIVA,50H
MOVSBUF,A
JNBTI,$
CLRTI
SETBES
RETI
RECEIVE:
CJNEA,#02H,ERROR
CLRRI
MOVA,SBUF
MOV51H,A
ERROR:
·
·
·
RETI
9-4设计一台自动打包机。