Using ADC0832 to Make a Digital Voltage Meter

Publisher:VelvetSoulLatest update time:2021-03-18 Source: elecfansKeywords:ADC0832 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

;******************************************************************
;* Description: *
;*           ADC0832 digital voltmeter digital tube display *
;* *
;* Adjust the potentiometer next to ADC0832
, and the digital tube will display the size of the ADC0832 conversion value * ;* *
;* *
;**********************************************************************


           AD_CLK EQU P1.0
           AD_DAT EQU P1.1
           AD_CS EQU P3.4
        DISSTART EQU 30H ;Display unit first address
        LED_DATA EQU P0 ​​;Digital tube data definition
            ORG 0000H
            JMP START

;--------------------------------------------------------
START: MOV SP,#60H
            MOV A,#00H
            MOV 20H,A
            MOV P0,#0FFH
            MOV P2,#0FFH

START1: CALL AD_CONV
            CALL AD_CHULI
            CALL QUSHU
            CALL ADPLAY
            JMP START1
;---------------------------------------------------------
AD_CONV: ;ADC0832 initialization
            SETB AD_CS ;A conversion cycle starts
            CLR AD_CLK
            CLR AD_CS ;CS is set to 0, chip select is valid
            SETB AD_DAT ;DI is set to 1, start bit
            SETB AD_CLK ;The first pulse
            CLR AD_DAT ;Add a DI inversion operation before the negative jump
            CLR AD_CLK
            SETB AD_DAT ;DI is set to 1, set to single channel
            SETB AD_CLK ;The second pulse
            CLR AD_DAT ;***
            CLR AD_CLK ;
            CLR AD_DAT ;DI is set to 0, select channel 0
            SETB AD_CLK ;The third pulse
            SETB AD_DAT ;***
            CLR AD_CLK
            NOP
            SETB AD_CLK ;The fourth pulse
            MOV R1,#08H ;Counter initial value, read 8-bit data,
AD_READ: CLR AD_CLK ;Falling edge
            MOV C,AD_DAT ;Read DO terminal data
            RLC A ;C moves into A, high bit first
            SETB AD_CLK ;The next pulse
            DJNZ R1,AD_READ ;Continue
            SETB AD_CS
            MOV 20H,A ;Conversion result is sent to 20H
            RET
;------------------------------------------------------
AD_CHULI:
            CLR C
            MOV R5,#00H ;Decimal conversion low register
            MOV R4,#00H ;Decimal conversion high register
            MOV R3,#08H ;Number of decimal adjustment
            MOV A,20H
AD_CHULI1:
            RLC A
            MOV R2,A
            MOV A,R5
            ADDC A,R5
            DA A
            MOV R5,A
            MOV A,R4
            ADDC A,R4
            MOV R4,A
            MOV A,R2
            DJNZ R3,AD_CHULI1
            MOV A,R5
            ADD A,R5
            DA A
            MOV R5,A
            MOV A,R4
            ADDC A,R4
            DA A
            MOV R4,A
            RET
;-------------------------------------------------
QUSHU: MOV A,R5
            ANL A,#0FH
            MOV DISSTART,A
            MOV A,R5
            ANL A,#0F0H
            SWAP A
            MOV DISSTART+1,A
            MOV A,R4
            ANL A,#0FH
            MOV DISSTART+2,A
            MOV A,R4
            ANL A,#0F0H
            MOV DISSTART+3,A
            RET
;--------------------------------------------------
ADPLAY: PUSH PSW
            CLR PSW.3
            SETB PSW.4

            MOV R0,#DISSTART ;Start filling display unit
            MOV R2,#03H ;Fill 3 bits in total
DISP1: MOV A,@R0 ;Get current bit address
            MOV DPTR,#TAB_NU ;Get table header
            MOVC A,@A+DPTR ;Get coded data
            MOV @R0,A ;Save coded data
            INC R0 ;point to the next conversion data
            DJNZ R2,DISP1 ;continue conversion until completed

            MOV R0,#DISSTART ;get the display unit first address
            MOV R1,#07FH ;start from the first digital tube
            MOV R2,#03H ;display 3 digital tubes in total
DISP2: MOV LED_DATA,@R0 ;read the display unit data
            MOV P2,R1 ;start to display the current bit
            MOV A,R1 ;prepare to display the next bit
            RR A ;
            MOV R1,A ;next bit
            INC R0 ;get the next unit address
            JNB ACC.5,DISP3 ;add decimal point to the third digital tube
            JMP DISP4
DISP3: MOV A,@R0
            ANL A,#7FH
            MOV @R0,A
DISP4: LCALL DELAY5MS ;delay 2 MS
            DJNZ R2,DISP2 ;repeat to display the next
            POP PSW
            RET ;display completed, return
;---------------------------------------------------
DELAY5MS:
         MOV R6,#10
  DEL1: MOV R7,#100
            DJNZ R7,$
            DJNZ R6,DEL1
            RET
;-------------------------------------------------
TAB_NU:
    DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H
    DB 80H,90H,88H,83H,0C6H,0A1H,86H,8EH


Keywords:ADC0832 Reference address:Using ADC0832 to Make a Digital Voltage Meter

Previous article:Knowledge of transformer detection methods
Next article:Tube voltmeter - for measuring pulse voltage

Recommended ReadingLatest update time:2024-11-15 13:38

Section 50: Using ADC0832 to collect voltage signals, using the average method and interval method to perform software filtering
Opening remarks: ADC0832 is a commonly used 8-bit AD sampling chip, which can convert external analog voltage signals into digital signals, and then send them to the microcontroller for conversion, display and other processing. This section will teach you five knowledge points: The first one is the resolution algo
[Microcontroller]
Latest Test Measurement 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号