A magical journey into the world of microcontrollers[Copy link]
Entering the world of single-chip microcomputers
Nowadays, everyone is familiar with computers. From the overwhelming advertisements for computer learning classes to the notice that computer knowledge is required for employment, we have consciously or unconsciously entered the world of computers. But there is another type of computer that we may not be familiar with, and it is right in front of us, that is, the single-chip microcomputer. As the name suggests, a single-chip microcomputer integrates a computer into a chip. Because of this, it has penetrated into various places such as electric rice cookers, washing machines, video recorders, telephones, cars, trains, airplanes, rockets, medical equipment, and even single-chip microcomputers are working silently in microcomputers. Therefore, it is very meaningful to understand the working principle of single-chip microcomputers and master their use methods. Starting from this issue, this magazine will systematically and popularly introduce this knowledge.
1. From transistors to single-chip microcomputers
In order to have a comparison, before taking the single-chip microcomputer train, let's review the traditional electronic world that we are already familiar with. In the traditional electronic world, electron tubes have been retired for a long time. Although "tube amplifiers" are now popular among audio enthusiasts, electron tubes have left the stage far away in the control field, and we will no longer spend time discussing them. Transistors are familiar equipment for electronics enthusiasts. We are very familiar with the rectification principle of diodes and the amplification principle of triodes, but are we also familiar with the logic circuits they constitute? Let's do a brief review together.
How does the AND gate circuit composed of diodes work? Readers may wish to describe it first to see if we think the same. When A and B are both connected to the ground, the C end is very small because both diodes are turned on. The conduction voltage drop of the diode is approximately 0 volts, that is, it is at a low level. When A is grounded and B is connected to +5V, there is no fundamental change at the C end. This is because the conduction of diode D1 makes point C still at a low level. Although point B is connected to +5V, D2 is not turned on, so point C is still at a low level. The same is true when A is connected to +5V and B is grounded. Only when A and B are connected to +5V at the same time, the two diodes are not turned on, and point C rises to +5V.
The conclusion is: If only one of the input terminals of the AND gate circuit is connected to a low level, the output will be a low level. Only when all input terminals are connected to a high level, the output will be a high level. Simply put, A is high and B is high, the output will be high. Changing the circuit connection method will form an OR gate circuit. The working principle will not be repeated here. Only the conclusion is written here: As long as one of the input terminals of the OR gate circuit is connected to a high level, the output will be a high level. Only when all input terminals are connected to a low level, the output will be a low level. Simplified to: A is high or B is high, the output is high.
There is also a "not" gate circuit: when the input is high, the output is low; when the input is low, the output is high. A transistor can be used to form a not gate circuit. When the base input of the transistor is high, the transistor is saturated, and the collector output is approximately 0V, that is, a low level; conversely, when the base is connected to a low level, the transistor is cut off, and the collector output is close to +5V, which is a high level. The input and output are always opposite, so it is called a not gate.
AND, OR, and NOT circuits are the basic forms of logic circuits. From the theory, we know that all logic circuits can be formed by the combination of these three basic logic circuits. In order to highlight the logical relationship between circuits in logic circuits, we no longer care about what device is used to generate the logical relationship, nor do we consider whether the input of the circuit is connected to the base of the transistor or the anode of the diode, but use a logic symbol to represent the connection between them. The symbols corresponding to the three basic logic circuits are marked at the bottom of the figure.
With the advancement of technology and the needs of social development, the logic circuit directly composed of transistors can no longer meet the needs in terms of volume and function, so integrated circuits were produced. Early integrated circuits-a chip integrated several or dozens of transistors, which was called a small-scale integrated circuit. Later, the integration level was increased to hundreds or thousands of transistors, which was called a large-scale integrated circuit. Now a chip can integrate the equivalent of hundreds of thousands, millions or more transistors, which is called a very large-scale integrated circuit. In this way, starting from the time of the electron tube, electronic circuits have undergone four generations of changes.
From the perspective of integrated circuits, the performance is greatly improved compared to transistors, the size is greatly reduced, and the functions are more complete. For example, there are different series such as LLS and HC for the 74-type gate circuit, and each series has hundreds of varieties. They can be used to combine various circuits. The emergence of logic integrated circuits has laid the foundation for the widespread application of logic circuits.
Logic circuits can be divided into two types: combinational circuits and sequential circuits. The single AND, OR, and NOT gate circuits introduced above belong to "combinational circuits". The characteristics of this type of circuit are: the output state follows the input state change, and once the input state changes, the output changes immediately. And the output state and the input state correspond one to one: each input state corresponds to a unique output state.
Another type of logic circuit is called "sequential circuit"; the output of this type of circuit is not only related to the input state at the time, but also to the previous state. The counter is a typical sequential circuit. Every time the input end of the counter receives a pulse, the state of the output end changes once, and the output state is related to the previous state. Take 74LS161 as an example. This integrated circuit has a clock input end, four output ends, and some auxiliary ends. When the circuit is connected according to the device regulations, the output state changes once for each pulse input at the clock end. After the initial reset, the four output ends QA, QB, QC, and QD are all 0. After the first pulse arrives, QA=1, and the rest of the outputs are still 0. After the second pulse arrives, QA=0, QB=1, and the rest are 0. Input pulses in sequence.
It can be seen that the output has different changes when the signal enters from the same input terminal. The application of counters is very wide. Connecting the front end to a mechanical switch or a photoelectric switch can be used as a pipeline product count; using the standard time pulse as input, it can be used as an accurate timer.
Due to the limitations of the column, the basic part cannot be written in a lot and in detail. Those knowledge can be obtained from similar learning materials such as triode principle and digital circuit knowledge, and cannot be completely included in the scope of this column. For the same reason, the principle of the single-chip microcomputer will not be a comprehensive and systematic explanation, but from the user's perspective, the most basic and most common content will be briefly introduced to achieve the purpose of "people's door".
It is expected that by reading this column and combining basic exercises, you can master the basic knowledge of single-chip microcomputers; learn the basic methods of using single-chip microcomputers; be able to read simple programs (dozens of lines); and write basic programs (hundreds of lines), laying the foundation for further study. One point that needs to be emphasized is that computers (including single-chip microcomputers, of course) are a very practical technology. You must understand the basic principles through practice. At least you must practice the experiments introduced in the article yourself. It is best to draw inferences from one example and verify the knowledge you have learned with your own program. You can experience the situation through practice. If there are any difficulties, I am willing to overcome them with you and enter the world of single-chip microcomputers together.
When the train to the world of single-chip microcomputers is about to start, please check whether the train number, date, and direction you want to take are consistent with this train. If there is an error, please change it in time to avoid delaying your trip.