The principle of single chip microcomputer control relay
As an old industrial city, there are not many enterprises in Zigong in terms of embedded development and single-chip computer design. Here is the principle of single-chip computer control relay.
First look at the relay drive
Typical relay drive circuit diagrams, such diagrams can be found everywhere on the network, and the same circuit diagrams are usually found in standard textbooks.
MCU is a weak electrical device, in general, they mostly work at 5V or even lower. Driving current is below mA level. It is obviously not feasible to use it in some high-power situations, such as controlling motor. Therefore, there must be a link to connect. This link is called "power drive". Relay drive is a typical and simple power drive link. Here, relay drive is a typical and simple power drive link. Relay drive contains two meanings: one is to drive relay, because relay itself is a power device for MCU; the other is to drive other loads, such as relay can drive intermediate relay, can directly drive contactor, so relay drive is the interface between MCU and other high-power loads. This is very important, because it has always let me. Their electrical engineers (I mean those who haven't studied the corresponding electronic technology) are puzzled by how a small chip can have such powerful power to control something as powerful as a motor.
It's easy to understand the circuit diagram and understand the circuit first. So please follow my train of thought and there should be no problem.
First of all, the transistor inside is very important. The transistor is a very important component in the electronic circuit. How to understand the transistor?
Simply put, the transistor has two functions: amplification and switching. (Strictly speaking, switching is the limit of amplification, but that's OK. It's easier to understand the working principle of the transistor by separating the two. Here, we only know its switching function related to this circuit.
C51 Single Chip Microcomputer Relay Circuit
We think of the transistor as a faucet. The Vcc is the pool and the relay is a turbine. Then the GND is any lower than the pool. The transistor is the faucet and its handle is the pin with resistance.
Now, one of the output pins of the relay circuit needs to be controlled by a single chip computer is a "hand". When the output pin of the single chip computer is low, it is like a "hand" turning on the triode "faucet". Water flows down from the top and the relay "turbine" begins to rotate. Conversely, if the output level is high, the "hand" will turn off the "faucet", and the relay "turbine" will turn off because there is no water. If it flows down, it will stop.
Simple understanding and memory is: the transistor is a switch device, in fact you can really think of it as a switch, but it is not controlled by hand, but by voltage (current) control, therefore, the transistor is sometimes referred to as an electronic switch (different from mechanical switch).
Another thing on the diagram is the protective diode. If you don't need to understand it deeply, you don't have to chase why it exists. But you must remember that it usually exists when a relay is driven by a triode. It is important to pay special attention to its connection method: the cathode at both ends of the relay must be connected to Vcc.