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?
Previous article:STC MCU controls BH1750 to measure light intensity
Next article:STC MCU 1602 display clock
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- NeoPixel Array Simulator
- 【Power amplifier application】 Lamb wave signal analysis based on dry-coupled ultrasonic testing
- Answer the questions and get a gift | Rochester Electronics will help you solve the problems of the entire semiconductor cycle
- C language (vd6.0) sleep function usage and delay usage
- Battery applications in medical monitoring and the changing environment
- Extract LEF
- Case study of the method to solve the distortion of high-frequency pulse signal measured by oscilloscope
- DA output voltage accuracy cannot be achieved
- Serial communication details
- TI Power Supply Learning and Growth Road: DC-DC/AC-DC Control Circuit