# Enhancing Energy Efficiency Using PWM Drive for DC Relays

We can save energy using a Pulse Width Modulation (PWM) drive for DC control relays and contactors. The energy consumed by the relay may be easily cut in half with this simple technique. This article provides a brief introduction to relays and then shows how the PWM drive signal may be implemented using a microcontroller such as the Arduino Nano Every as shown in Figure 1.

Figure 1: Picture of the Arduino Nano Every microcontroller, MOSFET drivers, and relays with the Digilent Analog Discovery in the background.

## Review of relay theory

Recall that a relay is an electromechanical device. It features a large electromagnet that produces a magnetic field to move the armature which in turn, moves the individual contacts. This coil of wire is an inductor with all the associated properties, including inductive kick when de-energized. It is also governed by the RL time constant where:

\tau = \dfrac{L}{R}

This time constant is a fundamental relay property and is central to our energy saving PWM technique. We must understand the time constant as it determines the waveform necessary to first activate and then hold the armature in position.

Before we continue, it may be useful to review these articles describing the nature of the magnetic field in a relay and the relationship between the time constant and relay on time.

## Review of relay specifications

The typical relay datasheet contains a wealth of information that is useful for our PWM technique. For this example we will focus on the CIT Relay & Switch J104D2C12VDC.20S as shown in Figure 1. The relevant static specifications are:

• 12 VDC coil, 200 mW, and 720 \Omega
• 9.00 VDC pick-up voltage (75% rated voltage)
• 1.2 VDC release voltage (10% of rated voltage)
• “The use of any coil voltage less than the rated coil voltage may compromise the operation of the relay.”

Unfortunately, the dynamic contact closure speed is not specified in the datasheet. However, this is easily determined empirically as shown in Figure 2. In this example, we are viewing the microcontroller command signal (orange) and the associated relay driver current (blue) as developed across a small shunt resistor. Observe that the current reaches steady state (full on) at approximately 8 ms. The dip in current at 5.5 ms is associated with the armature movement and the associated change in magnetic properties caused by a reduction in the air gap. Please see the previously mentioned article on the magnetic field behavior in relays.

Tech Tip: The distinction between the terms static and dynamic is critical to applying the PWM technique to the relay. Static describes things that are stationary while dynamic describes things in motion. For example, the static 12 VDC coil specification along with power, current, and coils resistance are easily calculated using the fundamental Ohm’s Law techniques learned in your circuit theory class. The dynamic relationships such as the change in initial current requires additional attention. As shown in Figure 2 we see that current is dynamic (always changing) except for the brief time between 8 and 10 ms. The relay mechanical close time is also considered part of this dynamic relationship. Here close time is dominated by the LR time constant.

## Significance of relay pick up and release voltage specifications

From the datasheet specification we observe two very different voltage for the initial pick-up voltage and the release voltage. This should not be surprising when we consider the air gap in the relay magnetic structure. Initially, the air gap for an unenergized relay is large. It takes significant magnetic field strength (higher current) to pull against the armature spring. However, once the armature is in the closed position, the air gap is reduced to almost nothing. It takes less magnetic field strength to hold the armature in this position.

This reduction in holding power is key to the relay PWM technique.

Figure 2: Digilent Analog Discovery waveform of the microcontroller’s PWM signal (orange) and the relay driver current (blue: divide by 10). Note the 10 ms turn on time followed by the PWM signal.

Tech Tip: Close inspection of Figure 2 shows that we are not measure the relay current directly. Instead, we are measuring the current supplied to the relay and its flyback diode. From circuit theory, we know that an inductor’s current does not change instantaneously. Instead, we are dealing with an integration of current over time just like a capacitor integrates voltage over time. The actual relay current would fill the gaps with a downward sloping (discharging) current between the PWM charging cycles.

## Description of the two-step process for PWM relay drive

The PWM based energy saving technique is a two-step process. The method is directly related to the difference between the pick-0up and release specifications of the relay. Steps:

• Pick-up: The first step is to activate the relay using the rated voltage. With full power, the relay will quickly close as shown in the first 6 ms of Figure 2. Once the current has reached steady state, we can shift to the next step. In figure 2 this steady state current is approximately 16 mA calculated as 12 VDC / 720 \Omega

• Hold: In this phase we PWM the relay. As shown in Figure 2 the PWM duty cycle is 50%. As explained in the last Tech Tip, we note that this is not a direct reading of the relay current. Instead, Figure 2 shown the current fed to the relay from the power supply. Consequently, we can see that the supply current is significantly reduced from the steady state. I leave it to you to determine the true RMS current supplied by this pulsed signal.

## Benefits and problems associated with the PWM technique

The primary benefit of the PWM technique is reduced energy consumption. In this example, we see that the 50% duty cycle has significantly reduced the energy burned in the coil by reducing the current. With additional experiments we may be able to reduce the duty cycle for even greater energy savings.

This reduced energy consumption does have a few downsides:

• Compromised relay operation: Careful analysis of the datasheet shows includes a “release voltage” not a minimum hold voltage. They are not the same thing. While we may reduce the duty cycle there may come a point where the relay does not hold closed. This is especially true in environments subject to vibration.

• ElectroMagnetic Interference (EMI): Electrical interference takes two forms:

• Local Interference: The PWM signal can blead into the signal being switched. For example, a PWM coil drive with high order harmonics can cause interference to small analog signals.

• Radiated Interference: The PWM drive signal and harmonics may radiate from the PCB causing interference to nearby devices.

Tech Tip: We can reduce the relay closing time by modifying the time constant. Recall that \tau = L/R. We can’t change the inductance, but we can increase R which will reduce the relay close time. The previously mentioned relay close time article introduces this as a L/2R or L/4R where the number indicates the multiplier for the resistance. Here a 4x increase in resistance will reduce the inductance-caused close time by a 4x factor. The downside is the necessity of a 4x increase in voltage.

## Arduino microcontroller code implementation of the relay PWM drive signal

The Arduino code for the PWM relay control is shown below. This control the two relays as shown in Figure 1 with an on or off action occurring once ever 500 ms. The code is relatively simple. It starts with digitalWrite( ) for 10 ms followed by an analogWrite( ) for the remainder of the time the relay is activated. The 10 ms time allows the relay current to fully close and reach steady state current. The PWM is then activated to maintain the relay in the closed position.

#define RELAY_1_PIN 3
#define RELAY_2_PIN 5

void setup() {
pinMode(RELAY_1_PIN, OUTPUT);
pinMode(RELAY_2_PIN, OUTPUT);
}

void loop() {
digitalWrite(RELAY_1_PIN, HIGH);
delay(10);
analogWrite(RELAY_1_PIN, 128);
delay(450);
digitalWrite(RELAY_2_PIN, HIGH);
delay(10);
analogWrite(RELAY_2_PIN, 128);
delay(450);

digitalWrite(RELAY_1_PIN, LOW);
delay(500);
digitalWrite(RELAY_2_PIN, LOW);
delay(500);
}


## Conclusion

The two-step relay drive technique is easy to implement with just a few lines of microcontroller code. It likely operates on hardware you already have in place to drive the relay. I encourage you to give the technique a try. Also, I challenge you to answer the questions and critical thinking questions at the end of this note.

Best wishes,

APDahlen

Aaron Dahlen, LCDR USCG (Ret.), serves as an application engineer at DigiKey. He has a unique electronics and automation foundation built over a 27-year military career as a technician and engineer which was further enhanced by 12 years of teaching (interwoven). With an MSEE degree from Minnesota State University, Mankato, Dahlen has taught in an ABET-accredited EE program, served as the program coordinator for an EET program, and taught component-level repair to military electronics technicians. Dahlen has returned to his Northern Minnesota home and thoroughly enjoys researching and writing articles such as this.

## Questions

1. Describe the two stages required for the PWM technique.

2. What would happen if the activation time, as shown in Figure 2, were reduced from 10 to 3 ms?

3. What is meant by “compromised relay operation” if the duty cycle is reduced below a certain threshold?

4. What is a relay flyback diode? Why is it necessary in this application?

5. Figure 2 presents the current as seen by the MOSFET driver. Switch the current as seen by the relay coil.

6. What determines the lower limit of the PWM duty cycle?

7. How is the air gap associated with a relay’s pick-up and hold voltages? For full credit describe the relationship using common permanent magnets.

8. Sketch the schematic of a L/4R circuit for a relay of your choice. Be sure to include the various resistances and operating voltages.

9. Calculate the power loss for the circuit you constructed for the previous question.

10. Describe the terms static and dynamic as they relate to a relay.

## Critical thinking questions

Locate the datasheet for a relay and then identify each specification as static or dynamic.

1. What cause the dip in the Figure 2 current waveform? How could you prove your assumption using a piece of folded paper?

2. What is meant by “blocking code”? How could non-blocking code be used to improve the code presented in this article?

3. A TVS diode may be used to increase the speed at which a relay turns off. Could we use a TVS diode in this application?

4. What precautions can be taken to minimize EMI associated with the PWM signal?

5. Figure 2 shown the current from the perspective of the power supply. Calculate the delivered RMS current for the PWM signal and then calculate the energy saving over a two-decade product lifetime. Assume the relay is active for 25 % of the time.