Now let's use the two digital tubes on the experiment board to do an experiment to display the numbers 00 to 99 in a loop. First, complete the necessary hardware part.
Digital tubes are divided into common cathode and common anode types. Both can be driven by microcontrollers, but the driving methods are different, and the corresponding display codes of 0 to 9 are exactly the opposite.
First, let's introduce the single-chip microcomputer driving method of two common anode digital tubes. The circuit is as follows:
Netizens can see that: P2.6 and P2.7 ports control the power supply of tens and ones of the digital tube respectively. When the corresponding port becomes a low level, the corresponding transistor will be turned on, and +5V will supply power to the corresponding bit of the digital tube through the IN4148 diode and the driving transistor. At this time, as long as the P0 port sends out the digital display code, the digital tube can display the number normally.
Because two different digits need to be displayed, a dynamic scanning method must be used. That is, the ones digit is displayed for 1 millisecond first, and then the tens digit is displayed for 1 millisecond, and this cycle continues. In this way, as long as the scanning time is less than 1/50 second, the two different digits will be stably displayed due to the visual residual effect of the human eye.
Next, we will introduce a single-chip microcomputer driving method for common cathode digital tubes. The circuit is as follows:
Netizens can see that +5V directly supplies power to the 8 segments of the digital tube through a 1K resistor, and the P2.6 and P2.7 ports control the power supply of the tens and ones of the digital tube respectively. When the corresponding port becomes low level, the corresponding bit can absorb current. The data output by the P0 port of the microcontroller is equivalent to short-circuiting the digital segments that the digital tube does not want to display to the ground, so that the digital tube will display the required numbers.
Netizens can see that the hardware of common cathode digital tubes is simpler, so in mass production, the hardware overhead is small, PCB area is saved, welding workload is reduced, and overall cost is reduced. Therefore, the use of common cathode digital tubes is more conducive to mass production. The test boards sold now all use common cathode digital tubes.
The following is an assembly language program that uses the two-digit digital tube of the AT89C51 experimental board to display 00~99 in a loop.
a_bit equ 20h ; memory location for storing the single digit of the digital tube
b_bit equ 21h ; memory location for storing the ten digit of the digital tube
temp equ 22h ;Counter value is stored in memory location
star: mov temp, #0; initialize the counter, starting from 0
stlop: acall display; call display subroutine
inc temp; add 1 to the counter
mov a,temp
cjne a,#100,next ; Determine whether the counter is full of 100?
mov temp, #0; reset to zero when it reaches 100 and start over
next: ljmp stlop; loop execution if not satisfied
; Display subroutine
display: mov a, temp; convert the hexadecimal number in temp to decimal
mov b, #10; decimal/10=decimal
div ab
mov b_bit, a; the tens bit is in a
mov a_bit, b ; the ones bit is in b
mov dptr, #numtab; specify the start address of the table lookup
mov r0, #4
dpl1: mov r1, #250;
dplop: mov a, a_bit; get the unit digit
MOVC A, @A+DPTR; check the 7-segment code of the single digit
mov p0, a ; send out the 7-segment code of the unit digit
clr p2.7 ; open the single digit display
acall d1ms ;display 162 microseconds
setb p2.7; turn off the units display to prevent ghosting
mov a, b_bit ; get the tens digit
MOVC A, @A+DPTR; check the 7-segment code of the ten-digit number
mov p0, a ; send out the ten-digit 7-segment code
clr p2.6 ; open ten-digit display
acall d1ms ;display 162 microseconds
setb p2.6; turn off the ten-digit display to prevent ghosting
djnz r1, dplop; loop executed 250 times
djnz r0, dpl1; loop execution 250X4=1000 times
ret
;2+2X80=162 microseconds, delay is calculated based on 12MHZ
D1MS: MOV R7, #80
DJNZ R7, $
RET
;The 7-segment digital tube 0 to 9 digits on the experimental board display the common cathode code
numtab: DB 0CFH, 03H, 5DH, 5BH, 93H, 0DAH, 0DEH, 43H, 0DFH, 0DBH
end
;If it is a common anode digital tube display code
numtab: DB 30H, 0FCH, 0A2H, 0A4H, 06CH, 25H, 21H, 0BCH, 20H, 24H
Previous article:Detailed explanation of the classic experimental examples of single-chip microcomputers (with source code) (Part 2)
Next article:Detailed explanation of the classic experimental examples of single-chip microcomputers (with source code) (IV)
Recommended ReadingLatest update time:2024-11-16 16:32
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
- High signal-to-noise ratio MEMS microphone drives artificial intelligence interaction
- Advantages of using a differential-to-single-ended RF amplifier in a transmit signal chain design
- ON Semiconductor CEO Appears at Munich Electronica Show and Launches Treo Platform
- ON Semiconductor Launches Industry-Leading Analog and Mixed-Signal Platform
- Analog Devices ADAQ7767-1 μModule DAQ Solution for Rapid Development of Precision Data Acquisition Systems Now Available at Mouser
- Domestic high-precision, high-speed ADC chips are on the rise
- Microcontrollers that combine Hi-Fi, intelligence and USB multi-channel features – ushering in a new era of digital audio
- Using capacitive PGA, Naxin Micro launches high-precision multi-channel 24/16-bit Δ-Σ ADC
- Fully Differential Amplifier Provides High Voltage, Low Noise Signals for Precision Data Acquisition Signal Chain
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- [Shanghai Hangxin ACM32F070 development board + touch function evaluation board evaluation] Transplant RT-Thread Nano
- Since it is so similar to inductors, why can you only use ferrite beads in your circuit?
- Device tree interrupt node
- Can CC2541 support 10 external interrupts?
- PCB failure analysis and some cases
- Evaluation report summary: Nengdian Technology capacitive and photoelectric liquid level sensors
- Xunwei i.MX6ULL Terminator Mfgtools Modify Only Burn Uboot, Kernel, File System
- How to choose the flow capacity
- ADRV9002 Dual Narrow Bandwidth RF Transceiver
- Help, STM32 address data acquisition HardFault_Handler