久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费
標題:
51單片機萬用表Proteus仿真+匯編程序
[打印本頁]
作者:
xiuye_tao
時間:
2016-5-10 19:49
標題:
51單片機萬用表Proteus仿真+匯編程序
51單片機萬用表仿真,原理圖如下:
0.png
(51.1 KB, 下載次數: 83)
下載附件
2016-5-10 21:01 上傳
仿真及完整程序的下載地址:
實用萬用表.rar
(33.37 KB, 下載次數: 64)
2016-5-10 21:12 上傳
點擊文件名下載附件
萬用表
下載積分: 黑幣 -5
c語言版本的單片機萬用表51黑下載:
http://m.zg4o1577.cn/bbs/dpj-50069-1.html
萬用表的程序源碼如下:
org 0000h ;單片機復位地址
ajmp main ;轉移到主程序處
org 0100h ;main被定位在0x0100處
main: mov sp,#80h ;初始化堆棧指針
mov DPTR,#0E000h
mov A,#00h
movx @DPTR,A
setb C
mov P3.0,C
call DELAY_5ms
JUDGE: mov A,P1 ;判斷測量種類
anl A,#0Fh
cjne A,#00h,NON_CAP
call CAP_MEA
NON_CAP: cjne A,#01h,NON_V
call V_MEA
NON_V: cjne A,#02h,NON_A
call A_MEA
NON_A: call R_MEA
CAP_MEA: mov A,#00h ;測量電容
clr C
mov P3.0,C
DELAY_1S: mov R5,#2Eh ;設置R5初始計數值
DELAY_1S1: mov R6,#58h ;設置R6初始計數值
DELAY_1S2: mov R7,#7Ah ;設置R7初始計數值
DELAY_1S3: djnz R7,DELAY_1S3 ;延時時間為 Time=( ( (R7*2)+2+1 )*R6+2+1 )*R5+1
djnz R6,DELAY_1S2 ;
djnz R5,DELAY_1S1 ;
setb C
nop
nop
mov P3.0,C
READC: mov P2,#00h
setb C
mov P3.1,C
nop
clr C
mov P3.1,C
nop
call DELAY_5ms
mov DPTR,#0000h
movx A,@DPTR
mov B,A ;防止數據溢出
mov A,#0E6h
subb A,B
jc LARGERC
mov B,A
subb A,#31h
jc MIDDLEC
LESSC: mov A,#30h
ajmp CALCULATEC
LARGERC: mov A,#00h
ajmp CALCULATEC
MIDDLEC: mov A,B
CALCULATEC: mov R1,#40h
mov @R1,#00h
inc r1
mov @R1,#0BFh
inc r1
mov DPTR,#TABLE1 ;查找表格
movc A,@A+DPTR
mov B,A
mov @R1,#0BFh
anl A,#0F0h
swap A
mov DPTR,#SEGMENT7
movc A,@A+DPTR
mov @r1,A
inc r1
mov A,B
anl A,#0Fh
mov DPTR,#SEGMENT7
movc A,@A+DPTR
mov @r1,A
LOOPC: call DISPLAY
ajmp LOOPC
ret
V_MEA: mov A,#00h ;測量電壓
READV: mov P2,#20h
setb C
mov P3.1,C
nop
clr C
mov P3.1,C
nop
call DELAY_5ms
mov DPTR,#2000h
movx A,@DPTR
mov R2,#00h
mov R3,A
mov R6,#01h
mov R7,#0F4h
call MULD2 ;乘以500
clr C
mov A,r5
add A,#60h ;加96修正
mov r5,A
mov A,r4
addc A,#00h
mov r4,A
mov A,r3
addc A,#00h
mov r3,A
mov A,r2
addc A,#00h
mov r2,A
mov r0,#30h
mov r1,#34h
mov A,R2
mov @r1,A
inc r1
mov A,R3
mov @r1,A
inc r1
mov A,R4
mov @r1,A
inc r1
mov A,R5
mov @r1,A
inc r1
mov @r1,#00h
inc r1
mov @r1,#00h
inc r1
mov @r1,#00h
inc r1
mov @r1,#0FFh
call DIVD4 ;除以255
mov r1,#38h
mov @r1,#00h
inc r1
mov @r1,#00h
inc r1
mov @r1,#00h
inc r1
mov @r1,#0Ah
call DIVD4
mov 43h,33h
call DIVD4
mov 42h,33h
call DIVD4
mov 41h,33h
mov r0,#40h
mov @r0,#00h
inc r0
mov A,41h
mov DPTR,#SEGMENT7
movc A,@A+DPTR
orl A,#80h
mov @r0,A
inc r0
mov A,42h
mov DPTR,#SEGMENT7
movc A,@A+DPTR
mov @r0,A
inc r0
mov A,43h
mov DPTR,#SEGMENT7
movc A,@A+DPTR
mov @r0,A
LOOPV: call DISPLAY
nop
ajmp LOOPV
ret
A_MEA: mov A,#00h ;測量電流
READA: mov P2,#40h ;采樣
setb C
mov P3.1,C
nop
clr C
mov P3.1,C
nop
call DELAY_5ms
mov DPTR,#4000h
movx A,@DPTR ;讀取采樣值
mov B,A
mov A,#0B6h
clr C ;以下根據范圍設置數值以防溢出
subb A,B
jc LARGERA
mov A,B
subb A,#16h
jc LESSA
ajmp MIDDLEA
LARGERA: mov A,#0B6h
ajmp CALCULATEA
LESSA: mov A,#16h
ajmp CALCULATEA
MIDDLEA: mov A,B
CALCULATEA: mov r2,#0C3h
mov r3,#50h
mov r6,#00h
mov r7,A
call MULD2 ;乘以50000
clr C
mov A,r5
subb A,#70h ;以下減去102000
mov r5,A
mov 37h,A
mov A,r4
subb A,#8Eh
mov r4,A
mov 36h,A
mov A,r3
subb A,#01h
mov r3,A
mov 35h,A
mov A,r2
subb A,#00h
mov r2,A
mov 34h,A
mov r0,#30h
mov r1,#38h
mov @r1,#00h
inc r1
mov @r1,#01h
inc r1
mov @r1,#5Eh
inc r1
mov @r1,#0A0h
call DIVD4 ;除以89760
mov r1,#38h
mov @r1,#00h
inc r1
mov @r1,#00h
inc r1
mov @r1,#00h
inc r1
mov @r1,#0Ah
mov DPTR,#SEGMENT7
call DIVD4
mov A,33h
movc A,@A+DPTR
mov 43h,A
call DIVD4
mov A,33h
movc A,@A+DPTR
mov 42h,A
call DIVD4
mov A,33h
movc A,@A+DPTR
cjne A,#3Fh,NOTEQU
mov A,#00h
NOTEQU: mov 41h,A
mov 40h,#00h
LOOPA: call DISPLAY
nop
ajmp LOOPA
ret
R_MEA: mov A,#00h ;測量電阻
READR: mov P2,#60h ;采樣
setb C
mov P3.1,C
nop
clr C
mov P3.1,C
nop
call DELAY_5ms
mov DPTR,#6000h
movx A,@DPTR ;讀取采樣值
mov R2,#00h
mov R3,A
mov R6,#03h
mov R7,#0E8h
call MULD2 ;乘以1000
mov r0,#30h
mov r1,#34h
mov A,R2
mov @r1,A
inc r1
mov A,R3
mov @r1,A
inc r1
mov A,R4
mov @r1,A
inc r1
mov A,R5
mov @r1,A
inc r1
mov @r1,#00h
inc r1
mov @r1,#00h
inc r1
mov @r1,#00h
inc r1
mov @r1,#0FFh
call DIVD4 ;除以255
mov r1,#38h
mov @r1,#00h
inc r1
mov @r1,#00h
inc r1
mov @r1,#00h
inc r1
mov @r1,#0Ah
mov DPTR,#SEGMENT7
call DIVD4 ;連續進行4次除以10的操作
mov A,33h ;取得10進制值
movc A,@A+DPTR
mov 43h,A
call DIVD4
mov A,33h
movc A,@A+DPTR
mov 42h,A
call DIVD4
mov A,33h
movc A,@A+DPTR
mov 41h,A
call DIVD4
mov A,33h
movc A,@A+DPTR
cjne A,#3Fh,NONZERO
mov A,#00h
NONZERO: mov 40h,A
LOOPR: call DISPLAY
nop
ajmp LOOPR
ret
DELAY_5ms: mov R5,#01h ;設置R5初始計數值
DELAY_5ms1: mov R6,#16h ;設置R6初始計數值
DELAY_5ms2: mov R7,#70h ;設置R7初始計數值
DELAY_5ms3: djnz R7,DELAY_5ms3 ;延時時間為 Time=( ( (R7*2)+2+1 )*R6+2+1 )*R5+1
djnz R6,DELAY_5ms2 ;
djnz R5,DELAY_5ms1 ;
ret
TABLE1: DB 10h,11h,12h,14h,15h,16h,17h,18h ;電容量表格0.1uF---1uF
DB 20h,22h,24h,25h,27h,28h,30h,31h
DB 33h,34h,35h,36h,38h,40h,41h,43h
DB 45h,47h,50h,52h,55h,57h,59h,60h
DB 61h,63h,65h,68h,70h,72h,75h,77h
DB 80h,82h,85h,88h,90h,93h,95h,97h
DB 99h
SEGMENT7: DB 3Fh ;7段數碼管字符0的abcdefg的值,a在最低位,最高位始終保留為0
DB 06h ;7段數碼管字符1的abcdefg的值
DB 5Bh ;7段數碼管字符2的abcdefg的值
DB 4Fh ;7段數碼管字符3的abcdefg的值
DB 66h ;7段數碼管字符4的abcdefg的值
DB 6Dh ;7段數碼管字符5的abcdefg的值
DB 7Dh ;7段數碼管字符6的abcdefg的值
DB 07h ;7段數碼管字符7的abcdefg的值
DB 7Fh ;7段數碼管字符8的abcdefg的值
DB 6Fh ;7段數碼管字符9的abcdefg的值
; 3Fh======0 0 1 1 1 1 1 1
; h g f e d c b a
; a
; ■■■■■
; ■ ■
; f■ ■b
; ■ g ■
; ■■■■■
; ■ ■
; e■ ■c
; ■ ■
; ■■■■■
; d
DISPLAY: mov DPTR,#0E000h ;寫第一位數碼管
mov r1,#40h
mov A,@r1
movx @DPTR,A
setb C
mov P3.2,C
clr C
mov P3.2,C
call DELAY_5ms
setb C
mov P3.2,C
inc r1
mov A,@r1 ;寫第二位數碼管
movx @DPTR,A
setb C
mov P3.3,C
clr C
mov P3.3,C
call DELAY_5ms
setb C
mov P3.3,C
inc r1
mov A,@r1 ;寫第三位數碼管
movx @DPTR,A
setb C
mov P3.4,C
clr C
mov P3.4,C
call DELAY_5ms
setb C
mov P3.4,C
inc r1
mov A,@r1 ;寫第四位數碼管
movx @DPTR,A
setb C
mov P3.5,C
clr C
mov P3.5,C
call DELAY_5ms
setb C
mov P3.5,C
ret
DEBUG_OUT: mov DPTR,#0E000h ;調試輸出
movx @DPTR,A
D_LOOP: setb C
mov P3.5,C
clr C
mov P3.5,C
ajmp D_LOOP
ret
;雙字節二進制無符號數乘法
;被乘數在R2(高位)、R3(低位)中,乘數在R6(高位)、R7(低位)中。
;乘積在R2(高位)、R3、R4、R5(低位)中。
;用到累加器A,B,PSW,R2~R7。
;永遠不會產生進位。
;在出口時總是清除C。
;若結果超出2個字節范圍則OV=1。
;無需調用其它子程序。
MULD2:
MOV A,R3
MOV B,R7
MUL AB
MOV R4,B
MOV R5,A
MOV A,R3
MOV B,R6
MUL AB
ADD A,R4
MOV R4,A
CLR A
ADDC A,B
MOV R3,A
MOV A,R2
MOV B,R7
MUL AB
ADD A,R4
MOV R4,A
MOV A,R3
ADDC A,B
MOV R3,A
CLR A
RLC A
XCH A,R2
MOV B,R6
MUL AB
ADD A,R3
MOV R3,A
MOV A,R2
ADDC A,B
MOV R2,A
ORL A,R3
JZ MULD21
SETB OV
RET
MULD21:
CLR OV
RET
;四字節無符號數除法
;R0存放著被除數,除數,商數的地址。
;從R0開始的連續四個字節為結果的余數,入口時可以為任意,但在出口時發生變化。
;其后的連續4個字節在入口時是被除數,出口時是商數。
;再其后的連續四個字節在入口時是除數,出口時保持不變。
;用到累加器A,B,PSW,R0~R7。
;如果除數為零,則置OV=1標志,否則清零。
;在出口時總是清除C,請注意!
;無需調用其它子程序。
DIVD4:
MOV A,R0
MOV B,A
ADD A,#08h
MOV R1,A
MOV A,#00h
ORL A,@R1
INC R1
ORL A,@R1
INC R1
ORL A,@R1
INC R1
ORL A,@R1
JZ DIVD45
MOV R1,B
MOV R2,#04h
DIVD41:
MOV @R1,#00h
INC R1
DJNZ R2,DIVD41
MOV R3,#20h
DIVD42:
MOV R2,#08h
MOV A,B
MOV R0,A
ADD A,#07h
MOV R1,A
CLR C
DIVD43:
MOV A,@R1
RLC A
MOV @R1,A
DEC R1
DJNZ R2,DIVD43
MOV A,R0
ADD A,#03h
MOV R1,A
MOV A,R0
ADD A,#0Bh
MOV R0,A
MOV A,@R1
SUBB A,@R0
MOV R4,A
DEC R1
DEC R0
MOV A,@R1
SUBB A,@R0
MOV R5,A
DEC R1
DEC R0
MOV A,@R1
SUBB A,@R0
MOV R6,A
DEC R1
DEC R0
MOV A,@R1
SUBB A,@R0
MOV R7,A
JC DIVD44
MOV A,B
MOV R0,A
ADD A,#03h
MOV R1,A
MOV A,R4
MOV @R1,A
DEC R1
MOV A,R5
MOV @R1,A
DEC R1
MOV A,R6
MOV @R1,A
DEC R1
MOV A,R7
MOV @R1,A
MOV A,R0
ADD A,#07h
MOV R1,A
INC @R1
DIVD44:
DJNZ R3,DIVD42
MOV R0,B
CLR OV
CLR C
RET
DIVD45:
SETB OV
CLR C
RET
end
復制代碼
作者:
Dsimple
時間:
2016-11-28 15:42
wetyhdutdutyidftityd
作者:
a25575703
時間:
2017-12-28 05:17
樓主厲害!
作者:
AGC4@
時間:
2020-5-7 11:28
樓主的程序能滿足我這個題目以下的要求嗎?電阻、電容和電感測試儀 簡易電阻、電容和電感測試儀 (1)任務 設計并制作一臺數字顯示的電阻、電容和電感測試儀。 (2)要求 ①測量范圍:電阻100Ω~1MΩ,電容100pF~1uF,電感100uH~10mH; ②測量精度為:±5%; ③用LCD為顯示器,顯示其值; ④其他功能。
歡迎光臨 (http://m.zg4o1577.cn/bbs/)
Powered by Discuz! X3.1
主站蜘蛛池模板:
黄色成人av
|
精品视频一区二区三区四区
|
www.青青草
|
激情久久五月天
|
久久99精品久久久久久琪琪
|
日韩av免费在线播放
|
欧美三级精品
|
一级毛片免费播放
|
玖玖精品视频
|
日韩精品视频一区二区三区
|
青青草免费在线
|
在线观看小视频
|
日韩成人在线观看视频
|
特黄视频
|
三上悠亚激情av一区二区三区
|
免费在线看a
|
激情婷婷综合
|
日韩天堂网
|
男人的天堂亚洲
|
日日操日日干
|
国产成人精品av
|
欧美成人高清
|
欧美综合久久
|
精品久久一区二区三区
|
99久久国产视频
|
九九九视频
|
欧美亚洲一区二区三区
|
日本不卡一区二区
|
91视频在
|
久久性色
|
日韩欧美小视频
|
欧美日韩高清在线
|
国产裸体永久免费视频网站
|
日本在线看片
|
欧美日韩在线精品
|
国产精品福利一区
|
午夜高清
|
在线免费看黄色
|
日韩精品在线观看视频
|
欧美顶级黄色大片免费
|
中文字幕在线观看一区二区三区
|