Relay Module - ECE-180D-WS-2023/Knowledge-Base-Wiki GitHub Wiki

Arduino - Relay

Nazanin Zam

Updated by Austin Liu

Relay modules are essential components in control and automation systems that have the ability to switch on and off larger loads. In most laboratories, relays are used to control pumps and other timed equipment. Additionally, they are widely used in fields such as industrial control systems, home automation (lights, fans), automotive electronics (ignition, fuel pumps), and telecommunications.

Relay modules have many advantages over traditional switches, such as the ability to isolate electrical components. This is useful for applications where circuits are connected to multiple paths. Relays can also handle high voltage and high current loads, making them ideal for use in power control applications. This tutorial will explore the different types of relays, their functionalities, and how to implement one on an Arduino microcontroller.

How the relay works

The basic structure of a relay module is comprised of an electromagnet, a spring-loaded armature (coil), and a set of normally open (NO) and normally closed (NC) contacts. The two inputs are low trigger and high trigger while the outputs are the open and closed contacts.

Detailed look into a relay. Note the coil and the armature used to energize and de-energize.

A relay determines how to switch on/off based on specific contacts being energized. For example, when there is no voltage applied across the coil, the switch is open and the device is inactive. Once a sufficient voltage is applied across the coil, the switch closes and the device turns on. This is the case for a high level trigger that is normally open. The opposite is true for high level trigger in a normally closed case.

Essentially, when the electromagnet is energized, the coil is attracted towards the electromagnet, causing the normally open (NO) contacts to close and the normally closed (NC) contacts to open. This can be seen in the image above. When the coil is energized, it moves the armature and makes contact with the moveable contact. The contact connects the load to the power source, thus switching the high voltage or high current circuit. When the electromagnet is de-energized, the spring-loaded coil returns to its original position, disconnecting the load from the power source.

How to set up with an Arduino

What is required to set up a flashing LED using a 1 channel relay module.

  1. An Arduino Uno
  2. 1 Channel relay module
  3. 1 LED
  4. A 5v External DC power supply
  5. Jumper wires

A one channel relay. There are only one NC, CC, and NO ports.

Wiring

Take three jumper wires and connect Vcc, ground, and input ports to a breadboard. Using additional jumper wires follow the connections below.

Relay → Arduino

Ground → Gnd

Vcc → 5 v

Input → any number 2-13. In this case 10 was used.

Now take your LED. This can be inserted into the breadboard or connected using jumper wires. The shorter end of the LED needs to be grounded (black wire on LED) and the longer side (red wire on LED) has to be connected to the normally closed (NC) port on the relay.

Using an external power supply, connect the negative side to ground on the breadboard and positive to common contact (COM). Both the led and power supply ground can be connected to the same row used by the relay on the breadboard. As described above, we can determine the functionality of the relay by setting either NC or normally open (NO) to be the high level trigger. In this case we will be using NC.

Some Code

#define relayPin 10 // can define your own pin used 

void setup() {
  pinMode(relayPin, OUTPUT);

}

void loop() {
    digitalWrite(relayPin, LOW); 
    delay(10000); // how long you want it to stay in that position 1000=1 second
    digitalWrite(relayPin, HIGH);
    delay(10000);
}

When setting the relayPin to low, there is 0V being sent to the relay keeping the light off. After 10 seconds, the arduino programs the pin to high (5v) making the LED turn on for 10 seconds. This will keep repeating until the user disconnects.

This code can be expanded upon as relays come with multiple channels and can be used to control many devices at once. There are also many different types of relays. In this example an electromechanical relay was used. Other types include Solid-State, reed, and hybrids of electromagnets and semiconductor materials.

All of the relay types mentioned have fast switching speeds and low power consumption, making them suitable for general use. However, solid-state relays have limited voltage and current ratings making them not suitable for high inrush current. Reed relays, on the other hand, are ideal for their small size and high reliability, but may suffer from contact bounce (unintended toggling between open and closed). Ultimately, if cost is not a concern, hybrids are usually the best option due to their high switching frequency, reliability, and high voltage and current ratings.

Types of Relays

Reed Relays

Reed relays consist of two magnetic contact plates that close together to form a path for current to flow. These relays are used in a variety of applications, from communications and instrumentation to medical equipment and aerospace systems.

The key feature of reed relays is that they do not require an armature to close the contact plates together. Instead, the contact plates themselves move when an external magnetic field is applied. This makes them different from traditional relays, which use an armature to physically move the contacts together.

The contact plates in a reed relay are typically made of a thin, flexible metal such as nickel-iron or tungsten. These materials are chosen for their magnetic properties and their ability to withstand repeated opening and closing of the contacts. The contact plates are mounted inside a glass envelope or tube, which provides protection from the environment and helps to maintain their position and alignment.

To operate a reed relay, an external magnetic field is applied to the contacts, causing them to move together and close the circuit. The strength of the magnetic field required to close the contacts depends on a number of factors, including the size and shape of the contacts, the distance between them, and the strength of the magnetic field being applied.

Diagram of a Reed Relay

Since the moving parts are very small and light compared to the armature-based mechanism in traditional relays, reed relays are able to switch much faster than traditional relays. Their relatively simply operating mechanism also allows them to be reliable over long periods of time.

However, due to their small components, reed relays have limited current-handling capabilities.

Solid-State Relays

A solid state relay (SSR) uses an actuator that responds to an input voltage signal to control the flow of current through the device. The actuator is typically made up of a semiconductor device such as a thyristor or a triac. When an input voltage is applied to the actuator, it triggers a small current flow that allows the output circuit to be energized.

The output side of an SSR is typically equipped with a sensor that can detect when the actuator has been triggered. Once the sensor detects this signal, it allows the load to be turned on. The load can be any electrical device or component that needs to be switched on or off, such as a motor, a light, or a heater.

A simple example consists of an LED as the actuator and a photodiode as the output sensor:

Example Diagram of Solid State Relay Internals

When the input voltage turns on, the LED will begin to shine. Once the voltage reaches a predetermined value, the LED illuminates brightly enough to turn on the photodiode, switching on the load.

One of the main advantages of SSRs over traditional electromechanical relays is that they are more reliable and longer-lasting. Because they don't have any moving parts, there's less wear and tear on the device over time, and there's less chance of the relay failing due to mechanical failure.

In addition, SSRs can be more versatile in their applications than traditional relays. They can handle a wider range of loads, including AC and DC currents, and they can switch on and off more quickly and precisely. They are also generally smaller and more compact than traditional relays, making them a good choice for applications where space is at a premium.

Mercury Relays

As the name suggests, mercury relays are a type of electrical switch that use liquid mercury as the switching element. When in the on state, the relay contains enough mercury to touch the contacts of the relay. In this state, an iron slug is used to displace the mercury, allowing it to come into contact with the relay's contacts. When the relay is turned off, a magnetic field is created in the coil of the relay. This magnetic field attracts the iron slug out of the mercury, breaking the contact between the terminals of the relay and the mercury. This allows the mercury to return to its original position, separated from the contacts.

Diagram of a Mercury Relay

The use of mercury as a switching element offers several advantages over other types of relays. For example, mercury relays can switch on and off much more quickly than armature-based relays. This is because the liquid mercury can quickly flow to make or break a contact, whereas an armature has to physically move to make or break a contact. Additionally, mercury relays have a longer service life than armature-based relays because there are no moving parts to wear out and the contacts are not subject to mechanical fatigue. They are also more reliable as they are less prone to contact bounce or chattering, which can cause electrical noise or arcing.

Despite these advantages, mercury relays have some drawbacks. They are not environmentally friendly due to the toxicity of mercury, and they are not suitable for use in some applications, such as those involving high-vibration environments or those that require hermetic sealing. Nonetheless, mercury relays remain a useful and reliable option for many applications that require fast, reliable switching.

Closing Remarks

Relay modules are a simple and cost-effective solution that offer several advantages. They can be easily controlled with just a voltage, eliminating the need for complicated circuits involving mosfets and gate drivers as switches. This makes them ideal for high-quality industrial applications. However, relays have slower switching speeds compared to mosfet-based approaches, which restricts their use for applications like BLDC motor drivers that require high switching speeds to drive the motor. Another downside is that relays tend to be excessively sized.

Relays are the ideal choice for applications that prioritize simplicity and cost-effectiveness in non-fast switching scenarios. In control and automation systems, relay modules are vital components that offer reliability, durability, and versatility. They also provide a safe and controlled method to switch high voltage or high-power circuits while maintaining electrical isolation. With the advancements in technology and the growing demand for automation and control systems, relay modules are likely to play an even more important role in the future.

Sources

Word count: 968

⚠️ **GitHub.com Fallback** ⚠️