One-stop Electronic Manufacturing Services, help you easily achieve your electronic products from PCB & PCBA

Can single-chip microcomputer drive relay and solenoid valve directly?

Although this problem is not worth mentioning for the electronic old white, but for the beginner microcontroller friends, there are too many people who ask this question. Since I am a beginner, I also need to briefly introduce what a relay is.

dtrfd (1)

A relay is a switch, and this switch is controlled by a coil inside it. If the coil is energized, the relay pulls in and the switch acts.

dtrfd (2)

Some people also ask what is a coil? Look at the figure above, pin 1 and pin 2 are the two pins of the coil, pin 3 and pin 5 are now through, and pin 3 and pin 2 are not. If you plug in pin 1 and pin 2, you’ll hear the relay go off, and then pin 3 and pin 4 will go off. 

For example, if you want to control the on-off of a line, you can deliberately break the line, one end is connected to the 3 feet, one end is connected to the 4 feet, and then by powering and powering off the coil, you can control the on-off of the line. 

How much voltage is applied to pin 1 and pin 2 of the coil? 

This problem needs to look at the front of the relay you are using, such as the one I am using now, you can see that it is 05VDC, so you can give 5V to the coil of this relay, and the relay will draw. 

How to add coil voltage? We finally got to the point. 

You can directly use two hands to hold the 5V and GND wire directly to the two pins of the relay coil, you will hear the sound. 

So how do we voltage him with a microcontroller? We know that the single chip microcomputer pin can output 5V, is it not directly connected with the single chip microcomputer pin relay coil, it is OK? 

The answer is of course not. Why is that? 

It’s still Ohm’s law.

Use a multimeter to measure the resistance of the relay coil.

dtrfd (3)

For example, the resistance of my relay coil is about 71.7 ohms, adding 5V voltage, the current is 5 divided by 71.7 is about 0.07A, which is 70mA. Remember, the maximum output of the ordinary pin of our single chip microcomputer is 10mA current, and the maximum output of the large current pin is 20mA current (this can refer to the datasheet of the single chip microcomputer).

See, although it is 5V, the output current capacity is limited, and it cannot reach the current of the driving relay, so it cannot directly drive the relay. 

That’s when you need to figure something out. For example, use a triode S8050 drive. The circuit diagram is as follows.

dtrfd (4)

Look at the S8050 datasheet, S8050 is an NPN tube, the maximum allowable current of ICE is 500mA, far greater than 70mA, so there is absolutely no problem with the S8050 drive relay. 

If you look at the figure above, ICE is the current flowing from C to E, which is the current in a line with the relay coil. NPN triode, here is a switch, MCU pin output 5V high level, ICE on the relay will be drawn; SCM pin output 0V low level, ICE is cut off, the relay does not draw. 

In the same way, the solenoid valve is also a load with small resistance and large power, and it is also necessary to select the appropriate driving components in accordance with the above Ohm’s law method.


Post time: Jul-12-2023