Why can't the microcontroller directly drive the relay and solenoid valve?

Publisher:脑洞飞翔Latest update time:2019-05-20 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Note: This article is for microcontroller beginners.
Why write an article?
Although this question is not worth mentioning for electronics novices, there are too many people who ask this question for those who are just starting to learn microcontrollers. In the past, I always explained it to you one by one, but the repetitive work is really meaningless. It seems very necessary to explain it here in a unified way.

Since you are a beginner, I have to briefly introduce what a relay is.


(This is a relay I have on hand)
A relay is a switch that is controlled by a coil inside it. When the coil is energized, the relay is energized and the switch is activated.


Some people will ask what is a coil? Look at the picture above, pin 1 and pin 2 are the two pins of the coil, pin 3 and pin 5 are now connected, and pin 3 and pin 2 are not connected. If you energize pin 1 and pin 2, you will hear a sound from the relay, and then pin 3 and pin 4 will be connected.
For example, if you want to control the on and off of a line, you can deliberately break the line, connect one end to pin 3 and the other end to pin 4, and then control the on and off of the line by energizing and de-energizing the coil.
How much voltage should be added to pin 1 and pin 2 of the coil?
This question requires looking at the front of the relay you are using. For example, you can see that the one I am using now is 05VDC, so you can pass 5V to the coil of this relay, and the relay will be attracted.
How to add voltage to the coil?
Finally, let's get to the point.
You can directly use your hands to hold the 5V and GND wires and connect them directly to the two pins of the relay coil, and you will hear a sound.
So how do you add voltage to it using a single-chip microcomputer? We know that the pins of a single-chip microcomputer can output 5V. Is it okay to directly connect the relay coil with the pins of the single-chip microcomputer?
The answer is of course no.
Why?
No matter how things change, they still follow Ohm's law.
Use a multimeter to measure the resistance of the relay coil.


For example, the resistance of my relay coil is about 71.7 ohms. If 5V voltage is applied, the current is 5 divided by 71.7, which is about 0.07A, or 70mA. Remember, the maximum output current of the ordinary pin of our microcontroller is 10mA, and the maximum output current of the high-current pin is 20mA (refer to the datasheet of the microcontroller).
You see, although it is 5V, the output current capacity is limited and cannot reach the current to drive the relay, so it cannot directly drive the relay.
At this time, you need to find a way. For example, use the transistor S8050 to drive. The circuit diagram is as follows.


According to the datasheet of S8050, S8050 is an NPN transistor. The maximum allowable current of ICE is 500mA, which is much greater than 70mA. Therefore, there is absolutely no problem in driving the relay with S8050.
As shown in the figure above, ICE is the current flowing from C to E, which is the current in the same line as the relay coil. The NPN transistor is a switch here. When the microcontroller pin outputs a high level of 5V, the ICE is turned on and the relay is attracted; when the microcontroller pin outputs a low level of 0V, the ICE is turned off and the relay is not attracted.
Similarly, the solenoid valve is also a load with very small resistance and high power. It is also necessary to select the appropriate driving component according to the above Ohm's law.
Do you understand?


Reference address:Why can't the microcontroller directly drive the relay and solenoid valve?

Previous article:STC MCU controls BH1750 to measure light intensity
Next article:STC MCU 1602 display clock

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号