Categories: Firmware Guide-8051

Relay Interfacing with 8051

Relay is one of the most interesting and important components. Relays are switches that open and close circuits when actuated when an electrical signal. Because relays are the link between the low power digital electronics and high power devices. It allows digital circuits and digital microcontrollers to high power devices on and off. Simply, it is used to on/off power circuits using microcontrollers. Relays operate with AC or DC at common voltages like 12V, 24V, 48V, 120V and 230V. Relays can control currents ranging from 2A – 30A. When the switch is closed, the circuit is closed – or on. When the switch is opened, the circuit is open – or off. When a switch can be actuated with an electrical signal, the device is then typically referred to as a relay. The actuation of the relay will change the state of the contacts from open to closed or vice verses, depending on the contact configuration. We will look into the details of relay working, types and relay Interfacing with 8051 in this article.

 

Uses of Relays

The major use of relay started during the invention of telephones. Relay act as an important role in switching calls in a telephone exchange. They were used to switch the signal coming from one source to another destination. After the invention of computers, they were also used to perform Boolean and other logical operations. Relays are also used in our day to day devices like Refrigerators, Washing Machines, Heaters, and Air Conditioning.

Relays are mainly used for two basic operations. One is a low voltage application and the other is high voltage. For low voltage applications, more preference will be given to reduce the noise of the whole circuit. For high voltage applications, they are mainly designed to reduce a phenomenon called arcing.

Working of Relays

A simple electromagnetic relay consists of a coil of wire wrapped around a soft iron core, an iron yoke which provides a low reluctance path for magnetic flux, a movable iron armature, and one or more sets of contacts. The armature is hinged to the yoke and mechanically linked to one or more sets of moving contacts. It is held in place by a spring so that when the relay is de-energized there is an air gap in the magnetic circuit. In this condition, one of the two sets of contacts in the relay pictured is closed, and the other set is open. Other relays may have more or fewer sets of contacts depending on their function.

When an electric current is passed through the coil it generates a magnetic field that activates the armature, and the consequent movement of the movable contact either makes or breaks a connection with a fixed contact. If the set of contact was closed when the relay was de-energized, then the movement opens and breaks the connection, and vice versa if the contact were open. When the current to the coil is switched off, the armature is returned by a force, approximately half as strong as the magnetic force, to its relaxed position. Usually, this force is provided by a spring, but gravity is also used as commonly in industrial motor starters.

When the coil is energized with direct current, a diode is often placed across the coil to dissipate the energy from the collapsing magnetic field at deactivation, which would otherwise generate a voltage spike dangerous to semiconductor circuit components.

An electromechanical relay consists of three terminals namely common (COM), normally closed (NC) and normally opened (NO) contacts. These can either get opened or closed when the relay is in operation.

When the relay is not energized then the Normally Closed(NC) and Common will be connected. If it is energized (it means the current is passed), Normally Open(NO) and Common will be connected.

Single Pole Single Throw(SPST): The SPST is the simplest configuration that has only two configurations. It has a total of four terminals. Out of these two terminals can be connected or disconnected. The other two terminals are needed for the coil to be connected.

Single Pole Double Throw(SPDT): It has three contacts. SPDT relay has a total of five terminals. Out of these two are the coil terminals. A common terminal is also included which connects to either of two others.

Double Pole Single Throw(DPST): The DPST relay has a total of six terminals. These terminals are further divided into two pairs. Thus they can act as two SPST’s which are actuated by a single coil. Out of the six terminals, two of them are coil terminals.

Double Pole Double Throw(DPDT): The DPDT relay is the biggest of all. It has mainly eight relay terminals. Out of these two rows are designed to change over terminals. They are designed to act as two SPDT relays which are actuated by a single coil.

Types of Relay

1. Electromagnetic Relays

  • Electromagnetic switches operated by a magnetic coil.
  • Operate with AC or DC.
  • Used as a wide range of switch configuration.

2.Induction Type Relays

  • Used as protective relays in AC systems.
  • Mostly used as directional relays in power-system protection and high-speed switching applications.

3.Solid State Relays

  • Used solid-state components to perform the switching operation.
  • Consist of an input circuit, a control circuit and an input circuit.
  • They do not have any moving objects in their design they are known for their high reliability.

4.Hybrid Relay

  • Relays are composed of electromagnetic relays and electronic components.
  • The input part contains the electronic circuitry and the output part include electromagnetic relay.
  • The hybrid relay uses both Solid State Relay and EiectroMechanical Relay to overcome their disadvantages.

5.Thermal Relay

  • These relays are based on the effects of heat.
  • Used in electric motor protection.
  • Consist of bimetallic elements like temperature sensors as well as control elements.

6.Reed Relay

  • Small, compact, Fast operating switch design with one contact.
  • To protect them from atmospheric protection they are safely kept inside a vacuum or inert gas.
  • Sealed in a glass envelope, which makes the contact unaffected by contaminants, fumes or humidity, allows reliable switching
  • Capable of switching industrial components such as solenoids, contactors and starter motors. They are famous for their switching speed.

7.Polarized and Non-Polarized Relay

Polarized Relay

  • The polarized relay uses a permanent magnet with an electromagnet.
  • The permanent magnet provides a fixed position for the armature. The electromagnetic coil changes the position of the armature about a fixed pivot.
  • The armature position depends on the polarity of the control input.

Non-Polarized Relay

  • The non-polarized relay does not use permanent magnets & their coil can be energized in both ways without affecting its operation.
  • Some relay having back EMF diodes does have polarity since the diode will bypass the coil if the connection is reversed.

Firmware Example – Relay Interfacing with 8051

Here we have to write the firmware for interfacing relay with 8051. Relay is connected to PORT 3 and change the relay position to ON and OFF condition.

Now, reg51.h is the header file used in the Embedded C coding of the micro-controller based on 8051 architecture.

#include<reg51.h>        //header file

The sbit type defines a bit within a special function register (SFR). Here, we have to initialize the port. The relay_pin indicates the name of the SFR bit. Port 3 is the base address and ‘0’ indicates the bit position to access.

sbit relay_pin = P3^0;    //port declaration

The delay function that should give the delay in a millisecond. This function is used to provide a delay while the relay works.

void Delay(int k)
{
  int j;
  int i;
  for(i=0;i<k;i++)
  {
    for(j=0;j<100;j++);
  }
}

Initially, the relay is in ON condition and provide a 1-sec delay. After that, the relay is OFF and again provide a 1-sec delay. Repeat this block of code, until a condition is met.

while(1)               //infinite loop
{
    relay_pin = 0;     //Relay ON
    Delay(1000);       //1 sec delay
    relay_pin = 1;     //Relay OFF
    Delay(1000);       //1 sec delay
 }

Circuit Diagram for Interfacing  relay with 8051

Here we are using transistor which is wired as a switch for Interfacing relay with 8051. This transistor which drives the relay. The transistor will be in OFF state when the pin P3.0 is in the LOW state. When 1 is written to P3.0 current will flow to the base of the transistor and the relay energizes.


[fusion_global id=”18383″]

Application of Relay

  • The major application of Relay is used for isolating a low voltage circuit from the high voltage circuit.
  • Microprocessors use relays to control a heavy electrical load.
  • Electromagnetic relays are employed for the protection of various ac and dc equipment.
  • They are used for controlling multiple circuits.
  • Used as auxiliary relays in the contact systems of protective relay schemes.
  • They are also used as automatic change over.
Share