Assembly language design of digital voltage meter digital tube based on 51 single chip microcomputer and ADC0808

Publisher:真情相伴Latest update time:2022-01-10 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Preface

Hello everyone, the last blog post was about a digital voltmeter based on the 51 single-chip microcomputer and ADC0808, but it used C language. This chapter will talk about using assembly language to achieve voltage measurement, also using digital tube display.


hardware design

The MCU used in this design is also a 51 single-chip microcomputer, the ADC also uses TI's ADC0808, and the display part uses a 4-bit digital tube. The final test voltage range is 0~5V. This time the accuracy is improved to about 0.01V. The simulation diagram is as follows:

The lower right is the simulated input voltage

insert image description here

Some of the assembly code is as follows: (Detailed comments in the code for easy reading)


    LED_0 EQU 30H ; Percentile

        LED_1 EQU 31H ; tenth place

        LED_2 EQU 32H ; Units digit

        LED_3 EQU 33H ; Tens place

        ADC EQU 35H

        CLOCK BIT P1.4 ; define 0808 clock bit

        ST BIT P1.5

        EOC BIT P1.6

        OE BIT P1.7

ORG 0000H

LJMP START

ORG 000BH

LJMP INT_T0

        ORG 30H

START: MOV LED_0,#00H

MOV LED_1,#00H

MOV LED_2,#00H

MOV DPTR,#TABLE ; Assign table value to DPTR

MOV TMOD,#02H ;Timer selection mode 2

MOV TH0,#0F5H ; To prevent the digital tube from flickering, the setting can be set to a number less than or equal to 245

MOV TL0,#00H

MOV IE,#82H ; Open T0 interrupt

SETB TR0 ;T0 starts counting

WAIT: CLR ST

SETB ST ; Rising edge clears SAR (SAR is used to store transient digital quantities during A/D conversion)

CLR ST ; Falling edge starts ADC operation

JNB EOC,$ ; Wait for conversion result

SETB OE ;ADC output

MOV ADC,P2 ; read AD conversion results

CLR OE

MOV A,ADC

MOV R7,A ; R7 stores the result of AD conversion

MOV LED_3,#00H ; Clear the tens digit

MOV LED_2,#00H ; Clear the ones place

MOV A,#00H

LOOP1: ADD A,#20H ; one bit of binary code corresponds to 100mV

DA A ; Convert the result into BCD code

JNC LOOP2 ; Cy is 0 to jump, Cy is 1 to continue execution

MOV R4,A ; R4 stores percentiles and tenths

INC LED_2 ; add 1 to the unit digit

MOV A,LED_2

CJNE A,#0AH,LOOP4 ; Jump if the unit digit is not 10, continue execution if it is 10

MOV LED_2,#00H ; position 0

INC LED_3 ; Tens digit plus 1

LOOP4: MOV A,R4

LOOP2: DJNZ R7, LOOP1 ; R7 minus 1, if not 0, jump, if 0, continue execution

ACALL BTOD1

LCALL DISP ;Call display subroutine

LJMP WAIT

ORG 0200H

BTOD1: MOV R6,A ; R6 stores the value of A after R7 is 0


File address:

Link: https://pan.baidu.com/s/146k5nKjulFsZeTJUKEvQDQ

Extraction code: cukz

Reference address:Assembly language design of digital voltage meter digital tube based on 51 single chip microcomputer and ADC0808

Previous article:Design of automatic digital voltmeter based on 51 single chip microcomputer and ADC0808 ADC0809
Next article:Automatic digital voltage meter digital tube display based on 51 single chip ADC0808

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号