1. Digital tube display principle:
The digital tube is actually composed of 8 LEDs, divided into a, b, c, d, e, f, g, dp, and the digital tube is divided into common cathode (left, high level lights up) and common anode (right, low level lights up). Lighting up the corresponding LED can display the corresponding number. The common cathode coding table is as follows:
0x3f , 0x06 , 0x5b , 0x4f , 0x66 , 0x6d 、0x7d , 0x07 , 0x7f , 0x6f , 0x77 , 0x7c,0x39 , 0x5e , 0x79 , 0x71 , 0x00
They correspond to 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f respectively, while 0x00 is not displayed.
Note: For example, to display 0, abcdef must all be 1, that is, 0011 1111, which is 0x3f in hexadecimal, and so on.
In order to display numbers or characters, they must be encoded. The seven-segment digital tube plus a decimal point has a total of 8 segments. Therefore, the encoding provided for the LED display is exactly one byte. There are two working modes of LED displays: static display mode and dynamic display mode.
2. Static Display Principle
The characteristic of static display is that each segment of the digital tube must be connected to an 8-bit data line to maintain the displayed glyph code. After the glyph code is input once, the displayed glyph can be maintained until a new glyph code is input. The advantage of this method is that it takes up less CPU time and the display is easy to monitor and control. The disadvantage is that the hardware circuit is relatively complex and the cost is high.
Schematic diagram of eight-digit digital tube and 74HC573
D74HC138 decoder schematic diagram
3. Use of 74H573 latch (control segment selection)
OE is the enable terminal. When it is low, the latch starts working.
VCC and GND are power supply and ground
LE is the latch terminal. When LE is at a high level, Q0~Q7 are in the same state as D0~D7 and are in a direct connection state.
When LE is at a low level, Q0~Q7 latch data. No matter how D0~D7 changes, Q0~Q7 maintain the state before latching.
code show as below:
sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;
u8 code smgduan[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; //Display the value of 0~F
void main()
{
LSA=0;
LSB=0;
LSC=0; //Control the Y0 output of 38 decoder to low level
P0=smgduan[0];
while(1);
}
3. Dynamic digital tube
The characteristic of dynamic display is that the segment selection lines of all digital tubes are connected in parallel, and the bit selection line controls which digital tube is effective. The selected digital tube adopts dynamic scanning display. The so-called dynamic scanning display is to send the font code and the corresponding bit selection to each digital tube in turn, and use the afterglow of the light-emitting tube and the visual retention of the human eye to make people feel as if each digital tube is displaying at the same time. The brightness of dynamic display is worse than that of static display, so when selecting the current limiting resistor, it should be slightly smaller than that in the static display circuit.
3-8 decoder---D74HC138 (control bit selection)
74HC138D is a three-channel input, eight-channel output decoder, referred to as 3-8 decoder, mainly used in consumer electronics products
From the truth table we can see that:
The reverse rule is actually octal, 000 corresponds to Y0, 001 corresponds to Y1, 010 corresponds to Y2, and so on. In this way, the bit selection operation of the corresponding digital tube can be realized.
code show as below:
sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;
u8 code smgduan[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; //Display the value of 0~F
/***********************************************************************************
* Function name: delay
* Function : Delay function, when i=1, the delay is about 10us
***********************************************************************************/
void delay(u16 i)
{
while(i--);
}
/***********************************************************************************
* Function name: DigDisplay
* Function : Digital tube dynamic scanning function, cyclic scanning 8 digital tube displays
***********************************************************************************/
void DigDisplay()
{
u8 i;
for(i=0;i<8;i++)
{
switch(i) //bit selection, select the digital tube to light up,
{
case(0):
LSA=0;LSB=0;LSC=0; break;//display bit 0
case(1):
LSA=1;LSB=0;LSC=0; break;//display the first bit
case(2):
LSA=0;LSB=1;LSC=0; break;//display the second digit
case(3):
LSA=1;LSB=1;LSC=0; break;//display the third bit
case(4):
LSA=0;LSB=0;LSC=1; break;//display the 4th bit
case(5):
LSA=1;LSB=0;LSC=1; break;//display the 5th bit
case(6):
LSA=0;LSB=1;LSC=1; break;//display the 6th bit
case(7):
LSA=1;LSB=1;LSC=1; break;//display the 7th bit
}
P0=smgduan[i]; //Send segment code
delay(100); //Scan after a certain period of time
P0=0x00; //Blanking
}
}
void main()
{
while(1)
{
DigDisplay(); //Digital tube display function
}
}
Previous article:Serial port principle and reference code of C51/C52 microcontroller
Next article:Introduction and implementation of C51/C52 microcontroller interrupt (EXTI) (Part 2)
- 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?
- Can the almighty gods help me find what IC this is?
- ADC12_A initialization parameters
- Xianji official data package: Review of Xianji HPM6750
- Brushless DC Motor Control System
- How to set read protection for TM4C123
- EEWORLD University Hall----Live Replay: TI's new generation C2000? microcontroller
- OEM or research lab? Where does innovation come from?
- Solution to DSP5509A not being able to connect to the emulator
- Zhongke Bluexun AB32VG1 development board---based on RT-Thread system--button feeding dog sharing
- Complete solution for automotive-grade LiDAR testing and verification