Single Chip Microcomputer (IV): The Helplessness of Digital Tube
There was a beautiful village called LED Paradise, which was full of all kinds of LEDs. They lined up to flash, or sat on the top of the hill to watch the lights, or cuddled up to each other with happy and shy blushes on their faces.
In short, they are happy because they can do whatever they want. However, one day, the electronic kingdom is going to hold a sports meeting, and the LED family has to complete the task of timing and counting. In desperation, some LEDs are arranged in the shape of 8 and accept the command of the single-chip computer. The innocent and simple LEDs are very obedient. They have completed the tasks assigned by the country seriously. They are glorious. In order to reward them, the king gave the participants their own new village and gave them beautiful clothes. However, they are not happy because the clothes they put on cannot be taken off, and they are not allowed to flash as they please. They are envied by outsiders, but who knows that what they want is freedom, and they want to reunite with their eagerly awaited family, but they can only stay and wait for orders in the village, and this village is called digital tube.
From the fairy tale above, we know that the digital tube comes from LED, so Baidu Encyclopedia says that "digital tube, also known as LED digital tube, is a semiconductor light-emitting device, and its basic unit is the light-emitting diode." So can the digital tube be controlled like the LED? This is necessary.
There are two types of digital tubes, one is called common cathode digital tube, the other is called common anode digital tube. The so-called common cathode and common anode refers to the connection method of LED in digital tube, whether to connect them all to ground or to VCC. If they are all grounded, it is common cathode, and if they are all connected to Vcc, it is common anode. I wonder if anyone will ask why we have to connect them the same? Of course, we can connect them differently, but why should we add unnecessary trouble to ourselves? The connection method of single-chip microcomputer and digital tube is like connecting multiple LEDs to single-chip microcomputer. It also needs to connect resistors, which is exactly the same as LED.
If the digital tube is called a digital coding tube, I wonder if it is appropriate. What is coding? It is the process of converting information from one form or format to another. In fact, it is the same as sticking out a thumb to indicate a stick. So the control of the digital tube is the realization of coding.
If this is a common anode digital tube, the low level lights up. And ABCDEFGDP are connected to P0~P7 respectively. Then, when you want to display 1, just let the BC segment light up, that is, connect the low level. That is, P0=0xf9
. If this is a common cathode digital tube, the high level lights up. When you want to display 1, just let the BC segment light up, that is, connect the high level. That is, P0=0x06.
When we want to represent 0~9, we just let the digital tube specify a certain section of light. And this specification is what we call coding, as follows (0-F coding):
Common anode: 0xc0
, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90, 0x88, 0x83, 0xc6, 0xa1, 0x86, 0x8e Common cathode
: 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71
The digital tube is helpless. For the above-mentioned digital tube, it is OK, but it does not flash. Some are on and some are off. But at the beginning of LED, it flashes by nature, and flashing can show its beauty. But the king is like this. If he says you can't flash, then you don't flash. However, the microcontroller is still pretty good. He makes the digital tube flash, but the flashing is more subtle. But why does the microcontroller help the digital tube flash?
It's very simple. The MCU has only 32 IO ports. If the digital tubes are not allowed to flash, it can only control four. Such low efficiency will be punished by the king. One day, the MCU heard that the king scolded the neon lights that flashed a hundred times per second, saying that they did not flash. Then the MCU smiled knowingly wow~ ⊙o⊙.
He connected the eight segment selectors of the four digital tubes to the P0 port, and each bit to the other ports, so that the flashing frequency of the digital tubes is greater than 100HZ. In this way, the digital tubes will not lose their flashing nature, and the MCU can complete the task. I will not let you see it, I will not let you see it O(∩_∩)0! I am the dynamic display
The specific connection method is as follows:
This is like controlling LED lights. The four-digit digital tube has 32 LEDs divided into four groups, each group has eight LEDs, but the predetermined number of flashes will be released before the next group, but the flashing frequency is relatively high, and we can't see it clearly.
However, the unreasonable king was still not satisfied with the task completed by the microcontroller, and asked him to do more work, but there were not enough pins, what to do? So he found a 38 encoder. The 38 encoder enables the microcontroller to control 8 LEDs with 3 IO ports.
Welcome to watch:
Microcontroller Notes (I): Don’t build a platform on quicksand
Microcontroller Notes (II): Introduction to Microcontrollers
Microcontroller Notes (Part 3): LEDs are flashing everywhere
Recommended recent content:
Miscellaneous talks on rectification (I)
Miscellaneous talks on rectification (Part 2)
Miscellaneous talks on rectification (Part 3)