[Diao Ye learns programming] Arduino hands-on (43) --- single relay module 2

insert image description here

The reference to 37 sensors and modules has been widely circulated on the Internet. In fact, there must be more than 37 sensor modules compatible with Arduino. In view of the fact that I have accumulated some sensors and modules on hand, according to the concept of practice (hands-on try), for the purpose of learning and communication, I am going to do experiments one by one here, and will record them regardless of whether they are successful or not. It is a difficult problem, and I hope to be able to throw bricks and spark jade.

[Arduino] 168 kinds of sensor module series experiment (data + code + graphics + simulation)
Experiment 43: 5V low level trigger single relay module (single module normally closed and normally open type)

insert image description here

insert image description here

Relevant information of single-channel relay module (knowledge points)
1. Electricity and magnetism
1. Explanation of electricity and magnetism—from a scientific point of view, electromagnetic waves are a kind of energy, and any object that can release energy , will emit electromagnetic waves. Electricity and magnetism can be said to be two sides of one body, changing electricity will produce magnetism, and changing magnetism will produce electricity. Electromagnetic fluctuations are like waves generated by the breeze blowing on the surface of the water, so they are called electromagnetic waves, and the number of times it changes per second is the frequency. When the frequency of electromagnetic waves is low, it can only be transmitted through tangible conductors; when the frequency gradually increases, electromagnetic waves will spill out of the conductors, and energy can be transmitted outward without a medium. This is a kind of radiation. For example, the distance between the sun and the earth is very far, but when we are outdoors, we can still feel the light and heat of the warm sun. This is like the principle of "electromagnetic radiation transfers energy through radiation phenomena". Generators, transformers and other important power equipment are made directly by the principle of electromagnetic induction. They are used to establish power systems, convert various energy sources (coal, oil, hydraulic power, etc.) development of social productive forces.

insert image description here

2. The discovery of electricity and magnetism—Historically, electricity and magnetism were discovered and studied separately. A long time ago, the ancient Greek scientist Thales made a series of observations about static electricity. From these observations, he concluded that friction made the amber magnetized. This is very different from the properties of ores like magnetite; magnetite is naturally magnetic. The magnetite was first discovered in China, and ancient Chinese scientists invented Sinan and the compass. Later, the connection between electricity and magnetism was discovered, such as the current magnetic effect discovered by Danish Oersted (HCOersted) and the law of interaction between electric current and electric current discovered by Frenchman Ampere. Later, Faraday proposed the law of electromagnetic induction, so that electricity and magnetism are integrated.

In the middle of the 19th century, Maxwell proposed a unified electromagnetic field theory, realizing the second great synthesis of physics. The laws of electromagnetism are completely different from the laws of mechanics. According to Newton's conception, the interaction considered by mechanics, especially the gravitational interaction, is an interaction at a distance, and there is no problem of force transmission (of course, from a modern point of view, gravity should also have a transmission problem), while electromagnetic interaction is field interaction. From the action of particles at a distance to the "field interaction" of electromagnetic fields, there is a great change in concept. Field effects are highlighted.

The continuous interaction of electric and magnetic fields causes the propagation of electromagnetic waves, which was confirmed by Hertz in the laboratory. Electromagnetic waves not only include radio waves, but actually include a wide spectrum, a very important part of which is light waves. In the past, optics was developed completely separately from electromagnetism. After the establishment of Maxwell's electromagnetic theory, optics became a branch of electromagnetism, and electricity, magnetism and optics were unified. This unification is of great technical significance. Almost all generators and motors are based on electromagnetic induction. The application of electromagnetic waves led to modern radio technology. Until now, electromagnetism still plays a leading role in technology. Therefore, electromagnetism has always maintained its important position in basic physics.

Electromagnetism involves what reference system to look at, and involves the electrodynamics of moving conductors. Intuitively speaking, "current, that is, the flow of charges produces magnetic effects", but judging whether charges flow involves the problem of the observer—the problem of the frame of reference. Optics is a part of electromagnetism, so this question can also be expressed as "what is the relationship between the propagation of light and the reference system". The Michelson-Morley experiment shows that the speed of light in vacuum is invariant in the inertial system. In this way, it is affirmed that electromagnetism obeys the same law in the inertial system. This actually led to what would later become Einstein's Special Theory of Relativity. Special relativity is basically a further development and extension of electromagnetism. The Michelson-Morley experiment could not be explained clearly in the 19th century, which is an important problem left over from the 19th century. The picture below shows the four kings of electromagnetism: Oersted, Ampere, Faraday and Maxwell.

insert image description here
3. Magnetic field——Magnetic field, a physical concept, refers to the field that transmits the magnetic force between objects. The magnetic field is a special field that is invisible and intangible. The magnetic field is not composed of atoms or molecules, but the magnetic field exists objectively. Magnetic fields have the radiation properties of wave particles. There is a magnetic field around the magnet, and the interaction between the magnets is based on the magnetic field as the medium, so the two magnets can function without physical contact. A special form of matter that exists in the space around an electric current, moving charge, magnet, or changing electric field. Since the magnetism of a magnet is derived from the current, and the current is the movement of charges, in a nutshell, the magnetic field is generated by moving charges or changes in the electric field. From the perspective of modern physics, the ultimate components that can form charges in matter are only electrons (with unit negative charge) and protons (with unit positive charge), so negative charges are point objects with excess electrons, and positive charges are point objects with A point object with excess protons. The real source of the magnetic field generated by moving charges is the magnetic field generated by moving electrons or moving protons. For example, the magnetic field generated by the current is the magnetic field generated by the electrons moving in the wire. The basic feature of a magnetic field is that it can exert a force on the moving charges in it, and the force or moment of the magnetic field on the current and on the magnet all comes from this. But modern theory shows that magnetic force is the relativistic effect of electric field force.

insert image description here
4. Electromagnetic field——Electromagnetic field is the medium of electromagnetic action, and it is a unified whole. Electric field and magnetic field are its two sides that are closely related and interdependent. A changing electric field produces a magnetic field, and a changing magnetic field produces an electric field. The changing electromagnetic field propagates through space in waves. Electromagnetic waves propagate at a finite speed, have exchangeable energy and momentum, the interaction between electromagnetic waves and objects, the mutual transformation between electromagnetic waves and particles, etc., all prove that electromagnetic fields are objectively existing substances, and their "special" lies in the fact that they have no static mass . The electromagnetic field theory with Maxwell's equations as the core is the theoretical basis of electrical engineering, electronics and information technology, and is an indispensable original knowledge for the development of high-tech in fields related to electromagnetic effects. Electromagnetic field theory reflects the unified essence of electromagnetic field in mathematical form, and is a perfect combination of physical laws and mathematical language.

insert image description here
2. Electromagnet (electromagnet)
1. Electromagnet is a device that generates electromagnetic force when electrified. A conductive winding matching its power is wound on the outside of the iron core. This current-carrying coil is magnetic like a magnet and is called an electromagnet. We usually make it into a bar or shoe shape to make the core easier to magnetize. In addition, in order to demagnetize the electromagnet immediately when it is powered off, we often use soft iron or silicon steel materials that demagnetize faster. Such an electromagnet is magnetic when energized, and the magnetism disappears when the power is turned off. The electromagnet is widely used in our daily life, and the power of the generator has been greatly improved due to its invention.

insert image description here
2. The principle of the electromagnet - when the iron core is inserted inside the energized solenoid, the iron core is magnetized by the magnetic field of the energized solenoid. The magnetized iron core also becomes a magnet, so that the magnetism of the solenoid is greatly enhanced because the two magnetic fields are superimposed on each other. In order to make the electromagnet more magnetic, the iron core is usually made into a hoof shape. But it should be noted that the winding direction of the coil on the shoe-shaped iron core is opposite, one side is clockwise, and the other side must be counterclockwise. If the winding directions are the same, the magnetization effects of the two coils on the iron core will cancel each other out, making the iron core non-magnetic. In addition, the iron core of the electromagnet is made of soft iron instead of steel. Otherwise, once the steel is magnetized, it will remain magnetic for a long time and cannot be demagnetized, and its magnetic strength cannot be controlled by the magnitude of the current, thus losing the advantages of the electromagnet. An electromagnet is a device that can pass current to generate magnetic force. It is a non-permanent magnet, and its magnetism can be easily activated or eliminated. Example: Large cranes use electromagnets to lift abandoned vehicles. When current passes through a wire, a magnetic field is generated around the wire. Using this property, when current is passed through the solenoid, a uniform magnetic field will be created inside the solenoid. If a ferromagnetic substance is placed in the center of the solenoid, the ferromagnetic substance will be magnetized and will increase the magnetic field. Generally speaking, the magnetic field generated by the electromagnet is related to the magnitude of the current, the number of coil turns and the ferromagnet in the center. When designing an electromagnet, attention will be paid to the distribution of coils and the selection of ferromagnets, and the magnitude of the current is used to control the magnetic field. Because the material of the coil has resistance, this limits the magnitude of the magnetic field that the electromagnet can generate, but with the discovery and application of superconductors, there will be opportunities to surpass the existing limitations.

insert image description here
3. The electromagnet has many advantages - the magnetism of the electromagnet can be controlled by on and off current; the magnitude of the magnetism can be controlled by the strength of the current or the number of turns of the coil; it can also be controlled by changing the resistance to control the current. Control the magnitude of the magnetism; its poles can be controlled by changing the direction of the current, and so on. That is: the strength of magnetism can be changed, the presence or absence of magnetism can be controlled, the direction of magnetic poles can be changed, and magnetism can disappear due to the disappearance of current. Electromagnet is an application of current magnetic effect (electric magnetism), which is closely related to life, such as electromagnetic relays, electromagnetic cranes, maglev trains, electronic door locks, intelligent channel turns, electromagnetic flowmeters, etc. The figure below shows an application of the electromagnet, the electric bell.

insert image description here
3. Relay (relay)
1. Concept - Relay (English name: relay) is an electrical control device, which makes the controlled quantity occur in the electrical output circuit when the change of the input quantity (excitation quantity) meets the specified requirements. An electrical appliance with predetermined step changes. It has an interactive relationship between the control system (also known as the input loop) and the controlled system (also known as the output loop). Usually used in automatic control circuits, it is actually an "automatic switch" that uses a small current to control the operation of a large current. Therefore, it plays the role of automatic adjustment, safety protection, and conversion circuit in the circuit. In the 18th century, scientists believed that electricity and magnetism were two incompatible physical phenomena. After the Danish physicist Oersted discovered the magnetic effect of current in 1820, the British physicist Faraday discovered the phenomenon of electromagnetic induction in 1831. These discoveries confirmed that electric energy and magnetic energy can be transformed into each other, which also laid the foundation for the birth of electric motors and generators; human beings entered the electrical age because of these inventions. In the 1830s, American physicist Joseph Henry invented the relay by using the phenomenon of electromagnetic induction when studying circuit control. The earliest relay is an electromagnetic relay, which uses the phenomenon that the magnetic force of the electromagnet is generated and disappeared under power-on and power-off to control the opening and closing of another circuit with high voltage and high current. Its appearance makes the remote control and protection of the circuit work be carried out smoothly. Generally speaking, a relay is a switch that controls a large current with a small current. Its working principle is simply understood as: using the drive circuit to generate electromagnetic attraction, and driving the contact of the load circuit to close through mechanical transmission, so that the load circuit is turned on. The relay is a great invention in the history of human science and technology. It is not only the basis of electrical engineering, but also an important foundation of electronic technology and microelectronic technology.

insert image description here
2. The structure of the relay - it is mainly composed of iron core, coil, armature (moving iron core), spring, moving contact, static contact and some terminals. Static contacts include normally closed contacts (moving contacts) and normally open contacts (moving contacts). The contact materials are usually copper, silver, gold and their alloys, among which platinum alloy is the best, such contacts have low contact resistance and are not easy to oxidize. For each contact of the electromagnetic relay, it can be understood and distinguished in this way: when the coil is not energized, the static contact in the off state is called "normally open contact", and the static contact in the on state is called "normally open contact". close contact". These two kinds of static contacts cooperate with the moving contacts (common contacts) respectively to form a complete set of changeover contacts to complete the "on" or "off" control task of the controlled circuit. And an electromagnetic relay can have groups of such contacts at the same time (each group can lack normally open or normally closed contacts), so as to realize synchronous control of multiple different loads. The schematic diagram of the internal structure of the relay is as follows.

insert image description here
3. The working principle of the relay - usually, the moving contact linked with the armature is connected with the normally closed contact. As long as a certain electric band is added to both ends of the coil, a certain current will flow through the coil, thereby generating an electromagnetic effect. The contact is separated from the normally closed contact and connected to the normally open contact. This process is called "pulling (action)" of the electromagnetic relay. When the coil is de-energized, the electromagnetic suction will also disappear, and the armature will return to its original position under the reaction force of the spring, so the movable contact and the normally closed contact are restored to be connected and separated from the normally open contact. The process is called "release (reset)" of the electromagnetic relay. It can be seen that with the power-on "pull-in" and power-off "release" of the electromagnetic relay, the "on" or "off" control of the controlled circuit can be easily realized through the contact group. Since there is no electrical connection between the working current passing through the coil and the contacts, the control circuit and the controlled circuit are completely isolated electrically.

insert image description here

insert image description here
It can be seen that the electromagnetic relay is a device that uses electromagnetic principles to control the on and off of the contact switch. It generally uses one electrical circuit to control another electrical circuit, which is also the origin of the word "relay". The biggest feature of the electromagnetic relay is that it can control a large current with a small current, control a high voltage with a low voltage, and control an alternating current with a direct current, etc. At the same time, it can realize electrical completeness between the control circuit and the controlled circuit isolation.

4. The main parameters of the relay——
(1) Nominal Coil Voltage (Rated Coil Voltage): It refers to the voltage required by the coil when the relay works normally. Depending on the type of relay, it can be AC ​​voltage or DC voltage.
(2) Coil Resistance (Coil Resistance): refers to the DC resistance of the coil in the relay, generally defined as the result measured at 20 degrees Celsius, and the value is positively correlated with temperature.
(3) Pick-Up Current: It refers to the minimum current at which the relay can generate a pick-up action. In normal use, the given current must be slightly greater than the pull-in current, so that the relay can work stably. As for the working voltage applied to the coil, generally do not exceed 1.5 times the rated working voltage, otherwise a large current will be generated and the coil will be burned.
(4) Drop-Out Current: refers to the maximum current for the relay to produce a release action. When the current in the pull-in state of the relay decreases to a certain extent, the relay will return to the release state without power, and the current at this time is much smaller than the pull-in current.
(5) Contact switching voltage and current (Maximum Switching Voltage/Current): refers to the voltage and current that the relay is allowed to load. It determines the size of the voltage and current that the relay can control, and it cannot exceed this value when used, otherwise it is easy to damage the contacts of the relay.
(6) The maximum carrying current of the contact (Maximum Carrying Current): Without considering the temperature rise, the maximum current that the relay contact can withstand is generally greater than the contact switching current.

insert image description here
5. Measurement of relays——
(1) Measuring contact resistance: Use the resistance file of the multimeter to measure the resistance of normally closed contacts and moving points, and the resistance value should be 0; while the resistance value of normally open contacts and moving points Just for infinity. From this, it can be distinguished which is a normally closed contact and which is a normally open contact.
(2) Measuring coil resistance: Use the multimeter R×10Ω file to measure the resistance value of the relay coil, so as to judge whether there is an open circuit in the coil.
(3) Measure the pull-in voltage and pull-in current: Find an adjustable voltage stabilized power supply and an ammeter, input a set of voltages to the relay, and connect an ammeter in series in the power supply circuit for monitoring. Slowly increase the power supply voltage, and record the pull-in voltage and pull-in current when hearing the pull-in sound of the relay. For accuracy, you can try several times and calculate the average value.
(4) Measure the release voltage and release current: also connect and test as above. When the relay pulls in, gradually reduce the supply voltage. When you hear the release sound of the relay again, record the voltage and current at this time, and also You can try several times to get the average release voltage and release current. Under normal circumstances, the release voltage of the relay is about 10~50% of the pull-in voltage. If the release voltage is too small (less than 1/10 of the pull-in voltage), it cannot be used normally, which will pose a threat to the stability of the circuit. , works unreliably.

insert image description here

6. The role of the relay - the relay is an automatic switching element with an isolation function. It is widely used in remote control, telemetry, communication, automatic control, mechatronics and power electronic equipment, and is one of the most important control elements. Relays generally have induction mechanisms (input parts) that can reflect certain input variables (such as current, voltage, power, impedance, frequency, temperature, pressure, speed, light, etc.); "Off" control actuator (output part); between the input part and the output part of the relay, there is an intermediate mechanism (drive part) for coupling and isolation of the input, function processing and driving the output part. As a control element, in a nutshell, the relay has the following functions:
(1) Expand the control range: for example, when the control signal of the multi-contact relay reaches a certain value, it can be switched and disconnected at the same time according to the different forms of the contact group. , Connect multiple circuits.
(2) Amplification: For example, sensitive relays, intermediate relays, etc., can control large power circuits with a very small control amount.
(3) Integrated signal: For example, when multiple control signals are input into the multi-winding relay in the prescribed form, the predetermined control effect is achieved after comparison and synthesis.
(4) Automatic, remote control, monitoring: For example, the relay on the automatic device and other electrical appliances can form a program control circuit to realize automatic operation.

7. How to use the relay——

insert image description here
4. Universal 5V blue shell relay

insert image description here

insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/weixin_41659040/article/details/132354843