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
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
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
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- China Chip Recruitment. Listed on Shanghai Science and Technology Innovation Board, focusing on the research and development of IoT wireless communication chips and solutions. Salary open + stock
- TI's Ultrasonic Sensing Technology for Flow Measurement
- [Visible] Intangible necessities
- Purgatory Legend-RAM War.pdf
- AD19, making 3D animation, "The 3D Movie Panel is disabled in 2D" How to solve it?
- Guitar Shaped Audio PCB Amplifier
- 26 "Wanli" Raspberry Pi car - program startup
- Simple example of DSP interrupt configuration
- 【McQueen Trial】McQueen's car goes through the maze
- Collection: Impedance matching and the basic principles of the Smith chart