Method of driving electromagnetic relay with single chip microcomputer

Publisher:RadiantDuskLatest update time:2016-03-18 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
In various automatic control equipment, there is a problem of interconnection between low-voltage automatic control circuits and high-voltage electrical circuits. On the one hand, the control signal of the low-voltage electronic circuit must be able to control the actuators of the high-voltage electrical circuit, such as motors, electromagnets, and electric lights; on the other hand, good electrical isolation must be provided for the electrical circuit of the electronic circuit to protect the safety of the electronic circuit and personnel. Electromagnetic relays can complete this bridge role.

An electromagnetic relay is a relay that generates a predetermined response by the relative movement of mechanical parts under the action of the current in the input circuit.
It includes DC electromagnetic relays, AC electromagnetic relays, magnetic latching relays, polarized relays, reed relays, and energy-saving power relays.
(1) DC electromagnetic relay: an electromagnetic relay whose control current in the input circuit is DC.
(2) AC electromagnetic relay: an electromagnetic relay whose control current in the input circuit is AC.
(3) Magnetic latching relay: a magnet is introduced into the magnetic circuit. After the relay coil is powered off, the relay armature can still maintain the state when the coil is powered on, and has two stable states.
(4) Polarized relay: a DC relay whose state change depends on the polarity of the input excitation.
(5) Reed relay: a relay that uses the action of a reed sealed in a tube and has the dual functions of a contact reed and an armature magnetic circuit to open, close or switch the circuit.
(6) Energy-saving power relay: an electromagnetic relay whose control current in the input circuit is AC, but it has a large current (generally 30-100A), a small size, and a power-saving function.

   Electromagnetic relays are generally composed of a control coil, an iron core, an armature, a contact spring, etc. The control coil and the contact group are insulated from each other, so they can provide good electrical isolation for the control circuit. When we add the rated voltage of the coil to both ends of the relay coil, a certain current will flow through the coil, thereby generating an electromagnetic effect. The armature will overcome the pulling force of the return spring under the action of electromagnetic attraction and be attracted to the iron core, thereby driving the moving contact of the armature to close with the static contact (normally open contact). When the coil is powered off, the electromagnetic attraction disappears, and the armature returns to its original position under the reaction force of the spring, causing the moving contact to close with the original static contact (normally closed contact). In this way, the attraction and release achieve the purpose of switching on and off in the circuit.

Below is a photo and main technical parameters of a small signal relay HK4100F-DC5V-SH. . .

             figure 1

 Main technical parameters of HK4100F electromagnetic relay  :

Brand: HUI KE
Model: HK4100F-DC5V-SH
Dimensions (mm): 10.5*15.5*11.8mm (W*L*H)
Weight: 3.5g
Origin: Ningbo, China   
Contact parameters:
Contact form: 1C (SPDT)
Contact load: 3A 220V AC/30V DC
Impedance: ≤100mΩ
Rated current: 3A
Electrical life: ≥100,000 times
Mechanical life: ≥10 million times

Coil parameters:
Resistance (±10%): 120Ω
Coil power consumption: 0.2W
Rated voltage: DC 5V
Pull-in voltage: DC 3.75V
Release voltage: DC 0.5V
Operating temperature: -25℃~+70℃
Insulation resistance: ≥100MΩ
Withstand voltage between coil and contact: 4000VAC/1 minute
Withstand voltage between contacts: 750VAC/1 minute

1. Relay drive principle

   Figure 2 below is the schematic diagram of the HK4100F relay drive circuit on the S51 enhanced single-chip microcomputer experimental board. The base B of transistor T5 is connected to P3.6 of the single-chip microcomputer, the emitter E of the transistor is connected to one end of the relay coil, and the other end of the coil is connected to the +5V power supply VCC; a diode IN4148 is connected in parallel at both ends of the relay coil to absorb and release the reverse electromotive force generated when the relay coil is powered off, to prevent the reverse electromotive force from breaking through transistor T5 and interfering with other circuits; R3 and light-emitting diode LED9 form a relay status indication circuit. When the relay is energized, LED9 lights up, so that the relay status can be intuitively seen.
HK4100F electromagnetic relay drive schematic diagram 


                        figure  2

Note: As shown in the figure above, 1, 2, and 3 of CN2 are relay output terminals, where 1 is connected to the normally open contact of the relay, 2 is connected to the moving contact of the relay, and 3 is connected to the normally closed contact of the relay. When the relay is energized, 1-2 will be connected, which is equivalent to a closed switch. Therefore, we can connect wires on terminals 1-2 to control other circuits.   
 Driving principle:

   1. When the P3.6 pin of the AT89S51 microcontroller outputs a low level, the transistor T5 is saturated and turned on, and the +5V power supply is added to both ends of the relay coil. The relay is energized, and the status indicator LED is also lit. The normally open contacts of the relay are closed, which is equivalent to the switch being closed.

   2. When the P3.6 pin of the AT89S51 microcontroller outputs a high level, the transistor T5 is turned off, there is no potential difference between the two ends of the relay coil, the relay armature is released, and the state indicator LED is also extinguished, and the normally open contact of the relay is released, which is equivalent to the switch being disconnected. Note: At the moment when the transistor is turned off, since the current in the coil cannot suddenly change to zero, a higher voltage induced electromotive force will be generated at both ends of the relay coil. The induced electromotive force generated by the coil can be released through the diode IN4148, thereby protecting the transistor from breakdown and eliminating the interference of the induced electromotive force on other circuits. This is the protection function of the diode D1.


   2. Relay Driver

   A simple relay control experiment source program is given below, which controls the relay to continuously close and release. The program is very simple.

Program flow chart   Relay control ASM source program:    
       ORG    0000H
       AJMP   START         ; Jump to initialization program

       ORG    0033H
START:  MOV    SP,#50H        ;SP initialization
       MOV    P3,#0FFH       ;Port initialization

MAIN:   CLR    P3.6           ; P3.6 outputs low level, relay energizes
       ACALL  DELAY          ; delays for a while
       SETB   P3.6           ; P3.6 outputs high level, relay releases
       ACALL  DELAY          ; delays for a while
       AJMP   MAIN           ; returns to repeat cycle

DELAY:  MOV    R1,#20         ; Delay subroutine
Y1:     MOV    R2,#100
Y2:     MOV    R3,#228
       DJNZ   R3,$
       DJNZ   R2,Y2
       DJNZ   R1,Y1
       RET                   ; Delay subroutine return

       END

       Figure 3       
   Create a new project jdq in Keil C51, input the source program above, and compile to get the HEX format burning target file jdq.hex. Use the ISP programmer to burn the file to the AT89S51 chip, and then we can see that the relay on the microcontroller driving the experimental board is pulled in and released after a delay of 1S. The "tick-tick" sound keeps ringing, and the general indicator light of the relay is also flashing, and the relay output contact also switches on and off repeatedly with the action of the relay.


   The following program drives the relay using the CPL bit inversion instruction, and the program's running results are exactly the same:

       ORG    0000H
       AJMP   START         ; Jump to initialization program

       ORG    0033H
START:  MOV    SP,#50H        ;SP initialization
       MOV    P3,#0FFH       ;Port initialization

MAIN:   CPL    P3.6           ; P3.6 output level flips, relay status changes
       ACALL  DELAY          ; delay for a while
       AJMP   MAIN           ; return to repeat cycle


DELAY:  MOV    R1,#20         ; Delay subroutine
Y1:     MOV    R2,#100
Y2:     MOV    R3,#228
       DJNZ   R3,$
       DJNZ   R2,Y2
       DJNZ   R1,Y1
       RET                   ; Delay subroutine return

       END

Reference address:Method of driving electromagnetic relay with single chip microcomputer

Previous article:Precautions for welding of MCU learning board
Next article:Operation of 16-bit INT data in 8-bit microcontroller

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号