微型计算机控制技术第9章习题答案(共9页).doc
精选优质文档-倾情为你奉上9-1 设计一个智能温度检测仪,要求具有检测、显示、键盘、通信功能。68K+12V10KAD5904.7K15K20K12V0.01f 5V+5V6MHZ C2 C1=30pf 10f +5V10K74LS04174LS02控制3#炉 控制2#炉 75452 220V 1#炉 100 0.01f 330 330 3+5V5K×311 1112 10+5V26+3245141313+5VP2.6ALEP0TXD WRRDRXD89C51P1.7P1.6P1.5 P2.7P1.0 P3.2RSTP1.1XTAK2P1.2XTAL1G Q074LS373D0D7 Q1D0D7VCCVR+ALESTARTOEEOC IN0ABC8255A+5Va dp a dp · · CS PB7A0 PB0A1PA0D0D7 WR PA0RD23 +56 1187 4 C1+ VCC V+C1- V-C2+C2- T1INT1out R1outR1INR1outPC机RXDTXD+5V一台智能温度检测仪,自动控制一个温室的温度要求如下: 要求温室温度为三档,第一档为室温,第二档为400C,第三档为500C,要求温度控制误差2°C 温度检测程序:温度检测程序的功能是连续进行4次A/D转换求取转换结果的平均值,存入50H单元.温度检测程序清单:WIJC:MOV 50H,#00HMOV B,#00HMOV R6,#04HCLR P2.7W:MOVX R0,ANOPNOPJNB P3.2,$MOVX A,R0ADD A,50HMOV 50H,AJNC W1INC BW1: CJNZ R6,W CLR CXCH A,BRRC AXCH A,BRRC ACLR CXCH A,BRRC AXCH A,BRRC AMOV 50H,ASETB P2.7RET标度变换程序:BDBH:MOV A,50HMOV B,#04HDIV AB MOV B,#0AHDIV ABMOV 30H,AMOV 31H,BRET显示程序:DISP: CLR P2.6MOV R0,#00HMOV R1,#30HMOV DPTR,#TABLP:MOV A,R1MOVC A,A+DPTRMOVX R0,AINC R0INC R1CJNE R1,#32H,LPSETB P2.6RETTAB:DB 0C0H ,0F9H, 0A4HDB 0B0H, 99H, 92HDB 82H, 0F8H, 80HDB 90H DSQ0:MOV TH0,#02HMOV TL0,#18HDJNZ R7,EXITMOV R7,#0E7HACALL WBJCACALL BDBHACALL DISPACALL CONT EXIT:RET温度控制程序清单:CONT: MOV A,50HCLR CSUBB A,51HJC H0SUBB A,#04HJNC H1RETH1: JNB P1.0,H2CLR P1.0RETH2: JNB P1.1,H3 CLR P1.1 RETH3: CLR P1.2RETH0: CPL AINC ACJNE A,#04H,H5H5: JNC H6RETH6: JB P1.2 ,H7RETH7:JB P1.1, H8 SETB P1.1 RETH8:SETB P1.0 RETKEY: JB P1.7, L1LCALL YS20MSJB P1.7, $MOV 51H,#50HL2: JB P1.6, L3 LCALL YS20MS JB P1.6, L3JNB P1.6, $MOV 51H,#0AHL3: JB P1.5, L4 LCALL YS20MS JNB P1.5, L4 JNB P1.5, $MOV 51H, #0C8HL4:RET主程序:ORG 0000HAJMP WAINORG 000BHAJMP DSQ0ORG 0023HAJMP TXIDORG 0030HMAIN:MOV SP,#60HMOV P1,#0F0HCLR P2.6MOV R0,#03HMOV A,#80HMOV R0,ASETB P2.6MOV TMOD,#21HMOV TH0,#02HMOV TH1,#18HSETB ET0MOV TH1,#0FDHMOV TL1,#0FDHANL PCON,#7FHMOV SCON,#50HCLR ET1SETB PS CLR PT0MOV R7,#0E7HMOV 51H,#50HSETB TR1SETB TR0SETB ES SETB EALOOP:LCALL KEYLJMP LOOP通信程序:串口和微机通信:微机始终是主动的,当单片机接收到一个数据后来判断,如果接收到是01H,就把单片机的检测值发送给微机,如果接收到是02H,就把从微机接收到的给定值,送给单片机的给定单元51H。TXID:CLR ESJBC RI COMMSETB ESRETICOMM:MOV A,SBUFCJNE A,#01H,RECEIVECLR TIMIV A,50HMOV SBUF ,AJNB TI,$CLR TISETB ESRETIRECEIVE:CJNE A,#02H,ERROR CLR RIMOV A,SBUFMOV 51H,AERROR: ··· RETI9-4 设计一台自动打包机。专心-专注-专业