NPEDUCATIONS, Electronic circuits development, electronics tutorials, microcontroller tutorials and projects, advanced microcontroller (ARM) based tutorials and projects, Embedded c development, Embedded c for ARM cortex M, Intel IoT based projects, IoT projects, CC3200 launch pad projects, MSP430 Launchpad tutorials and projects, Tiva C launch pad tutorials and projects, 8051 tutorials and projects, sensor interfacing with microcontroller tutorials, data communications and networking tutorials, peripheral interfacing with microcontroller, led message scrolling display, arduino based tutorials and projects, intel galileo based tutorials and project, ADC interfacing tutorials, LED Blinking, LCD interfacing, Embedded System tutorials and projects, projects, projects, online Embedded C training

What is a Relay? How to interface relay with 8051 microcontroller using ULN2003/ULN2803? What is use of Fly wheel diode?

What is a Relay?

A relay is an electromechanical switch, which perform ON and OFF operations without any human interaction. General representation of double contact relay is shown in fig 1.1

Generally, the relay consists a inductor coil, a spring (not shown in the figure), Swing terminal, and two high power contacts named as normally closed (NC) and normally opened (NO). Relay uses an Electromagnet to move swing terminal between two contacts (NO and NC). When there is no power applied to the inductor coil (Relay is OFF), the spring holds the swing terminal is attached to NC contact.
Figure 1.1 Representation of Relay

Whenever required power is applied to the inductor coil, the current flowing through the coil generates a magnetic field which is helpful to move the swing terminal and attached it to the normally open (NO) contact. Again when power is OFF, the spring restores the swing terminal position to NC.

Advantage of relay:

A relay takes small power to turn ON, but it can control high power devices to switch ON and OFF. Consider an example; a relay is used t control the ceiling FAN at our home. The ceiling FAN may runs at 230V AC and draws a current maximum of 4A. Therefore the power required is 4X230 = 920 watts. Off course we can control AC, lights, etc., depend up on the relay ratings. Relays can be used to control DC motors in ROBOTICs.

Best article submission sites

Types of Relays:

a.       SPST (Single Pole Single Throw)

b.       SPDT (Single Pole Double Throw)

c.       DPST (Double Pole Single Throw)

d.       DPDT (Double Pole Double Throw)

Interfacing relay to 8051 microcontroller

There are many ways to interface a relay to 8051 microcontroller. But simple and easy way for beginners is by using ULN2003/ULN2803. In this tutorial, a 5volts operated relay is taken for the demonstration. But the circuits shown can be useful to 12Volts operated relays also.

What happens when a relay is directly interfaced to 8051 micro controller?

Generally, a relay takes 70mA (some relays may works with 50mA) current to excite the inductor coil. But the current sinking capability (IoL) of each port pin of 89S52/89C52/89C51 has 20mA. So whenever 70mA current flow into the port pin may cause damage to that particular port pin. So to avoid this problem we need a large current sinker.

What is the need of ULN2803/ULN2003?

As we discuss above we need a large current sinker circuit between the relay and 8051 microcontroller. A transistor which has current sinking capability greater that 70mA is enough to act as a relay driver between the microcontrollers and relay. But the biasing circuit required for the transistor is a bit clumsy. In some cases like robotic car, the number of relays required will increase. Therefore the number of transistors and its biasing components will increase, PCB size increases, debugging is a bit headache.

Figure 1.2 interfacing Relay with 8051 microcontroller using ULN2003

So the simple way to drive the relay with 8051 microcontroller is by using ULN2003/ULN2803. A ULN driver has 500mA current sinking capability for each output pin. When input pin of ULN driver is at logic high then the corresponding output pin is connected to ground via 500mA fuse. Internally each fuse is designed by using Darlington transistor pair. So interfacing the 8051 microcontroller to relay via ULN driver will not damage the microcontroller port pin. The interfacing circuit is shown in figure1.2.

What is the need of fly wheel diode?

When power is applied to the relay inductor coil the current flowing through it causes magnetic field energy stored in it. This magnetic field is stored through the center of the coil and also outside of the coil.
                                                            B = LI2/2.
When the current flowing through inductor is off (i.e, the current changes from max to zero) causes changes in the stored magnetic field which in turn produce electric field that opposes the change in the current.
                                                            V = Ldi/dt.
If the current change is fast, the derivative value will be very high. The voltage produced due to the electric field across the coil to opposite to the actual current direction (i.e., negative potential) and may reach hundreds of volts if the change in current is very fast. This large voltage may damage the electronic parts.

                              Figure 1.3 Inductor coil connected across the collector terminal

As shown in figure 1.3 the inductor coil is connected at the collector terminal of the transistor. When logic high is applied, the transistor is in ON state, so the current flows along the inductor and transistor. When a logic LOW is applied, the transistor enters into OFF state (OPEN circuit), which in turn stop the current flow. Inductor doesn’t allow sudden changes in the current therefore large negative voltage is produce across inductor coil and causes electrons to cross the air gap as shown in figure. Therefore an electric spark/arc is produced across the open terminals of the transistor and it may damage the transistor as shown in figure 1.4

                  Figure 1.4 Spark Generated when inductor coil current is suddenly off

To avoid such problem, place a diode across the inductor coil as shown in below figure. When a power of the coil is OFF, the electric field (produced from the stored magnetic field) finds a path to flow electrons. Therefore the stored energy dissipates in the diode. When the relay coil power is ON, then the diode is not in conducting state. Whenever the power is OFF, the voltage appears across coil forward bias the diode and the current find a path to flow as shown in figure 1.5.

                  Figure 1.5 Flywheel diode across the inductor coil protects the transistor

Where do we see the electric spark in daily life?

You can see the electric spark by triggering the gas lighter or rubbing the positive terminal of the battery with its negative terminal by using a wire.
You can see big electric arc in movie theaters at film projector room.
You can see when a fan/light switch is on/off.


Thanks for visiting NPEDUCATIONS. We will contact you soon



great article and very well explained


Thank You Malik!

Post a Comment

Thanks for visiting NPEDUCATIONS. We will contact you soon

If you really like this tutorial, Don't forget to give the comment or please subscribe to the RSS feed by submitting your E-mail or like our Facebook page.
Related Posts Plugin for WordPress, Blogger...

Powered by Blogger