how to efficiently control relays using EQSP32 industrial esp32 plc.

How to efficiently control relays

Relays are incredibly useful and are utilized in nearly every automation system due to their ability to control a high-power circuit with a low-power signal. However, the traditional approach to relay operation is relatively energy-intensive, potentially generating excess heat and requiring a sizeable power supply to operate. This raises the question: might there be a better way; an approach to efficiently control relays?

Turns out, there is. Let’s dive deeper into the world of relays to uncover the smart and efficient way to control them.

For our tests we are going to use top-brand three-phase relay, with a 24-volt, AC or DC coil rating.

As we apply 24 volts the relay activates, as expected, but it’s drawing 170 milliamps. That might not seem significant, but it equates to over four watts of power. In an enclosed space, that heat adds up, risking not just the relay but the entire system. Imagine scaling that up to ten relays. We’re suddenly looking at 40 watts of heat generation.

Efficiently control relays. Continuously applying 24V on the relay is not an efficient way of controlling it.

Experimenting with relay’s holding power

When experimenting with lowering the voltage, it reveals that the relay remains operational way below the 24V activation voltage. Consuming progressively less power, it disengages at around 7.5 volts.

To efficiently control relays we need to define their deactivation voltage and throttle the applied voltage above that point.
Relay disengages at around 7.5V

Interestingly, reactivation requires a surge to just over 14 volts.

Relay re-engages at around 14V

There we have it: activating a relay demands more power than maintaining it.

By applying just 8 volts—about 30% of its rated voltage—post-activation, the relay operates on a mere 360 milliwatts. That’s less than one tenth the power at nominal voltage, dramatically reducing heat, allowing more relays to function concurrently, while using a smaller power supply.

Efficiently control relays using Pulse Width Modulation (PWM)

We can throttle the relay’s voltage through Pulse Width Modulation (PWM), a technique where we modulate the voltage by adjusting the on and off time of repeating pulses.

pwm control using eqsp32
Equivalent to 50% of 24V = 12V

For our demonstration, we’ll be using the EQSP32 wireless controller, connecting the relay to one of its 16 IO lines—each capable of PWM.

EQSP32 - Industrial IoT ESP32 PLC wired on three phase delay

EQ-AI for code generation

We’ll ask EQ-AI, our tailored GPT model for the EQSP32 – Industrial ESP32 PLC, to turn on the relay and dial the power down to 35% after 100 milliseconds. To stay on for five seconds, then off for two, in a repeating cycle

Using the following prompt,

EQ-AI prompt used for our example:

“I have a relay at pin 9 with holding power 35% and derate time 100 ms. I want it to be energized for 5 seconds and then turn off for 2.”

EQ-AI, with its detailed understanding of the EQSP32’s capabilities, swiftly provides the optimal code.

#include "EQSP32.h"

EQSP32 eqsp32;

void setup() {
// Initialize eqsp32 module

// Configure pin 9 as RELAY with specific holding power and derate time
eqsp32.pinMode(9, RELAY); // Note: Make sure to define RELAY as per your setup
eqsp32.configRELAY(9, 350, 100); // Set holding power to 35% and derate time to 100ms

void loop() {
// Turn relay on
eqsp32.pinValue(9, 1000); // Start at 100% power
delay(5000); // Keep on for 5 seconds

// Turn relay off
eqsp32.pinValue(9, 0); // Turn off relay
delay(2000); // Off for 2 seconds

We simply transfer this into the Arduino IDE, compile, and run. As expected, the relay commences its on-off cycling.

Note that pin 9 was configured by EQ-AI as “RELAY” mode. EQSP32’s innovative “RELAY” mode automatically derates the relay power to the user defined holding power value, after the user defined derate delay has been applied. Thus, the only thing we need to take care in the code is the On/Off durations.

EQSP32 - Industrial IoT ESP32 PLC. RELAY mode algorithm demonstration for automatic power derating. Energy efficient, smart way to drive relays.

We simply transfer this into the Arduino IDE, compile, and run. As expected, the relay commences its on-off cycling.

Efficiently control relays using EQSP32 innovative “RELAY” mode

Through an oscilloscope, we see the relay’s initial burst of energy at 24 volts for 100 milliseconds, before transitioning to PWM at 35%, stabilizing the voltage at 8.5 volts as can be seen on the voltmeter.

Monitoring the power supply reveals that, with the relay off, the EQSP32 alone draws about 30mA. Engaging the relay spikes the current to over 140mA momentarily, then levels out at around 50mA.

With PWM on, the relay’s additional draw is a mere 20mA, approximately half a watt, demonstrating the contrast in power required to activate versus maintain.

This principle of tiered power application is essential to efficiently control relays and other coil-activated devices, like water or pneumatic valves, and solenoids, ensuring both energy conservation and operational integrity.

Two more details: Flyback diodes and relay sequencing

When applying PWM to a coil, a flyback diode is an important component to maintain proper current flow and avoid voltage spikes.

Current flow when coil is energized
Current flow when coil is disconnected – Current flowing through the flyback diode

Also, when activating multiple relays simultaneously, a huge amount of power would be demanded. To solve this, a slight delay should be applied between each activation to prevent a cumulative power surge. EQSP32 includes flyback diodes on each output and handles this sequencing automatically.

EQSP32 - Industrial ESP32 PLC relay sequencer signals

Add a Comment

Your email address will not be published. Required fields are marked *