Relay board: from Active LOW to Active HIGH

Hello (again) :slight_smile:

So I finally connected my 16 channels relay board to 2 of those 74HC595 shift registers! It's cool and all!

But I have an little problem, the board is Active LOW and I want it Active HIGH. So I've read about using NPN transistor arrays such as the ULN2803. Guess what? There are 2 of those on the relay board! And even better, they are mounted on sockets.

So I'm wondering... If I remove those chips and replace them with wires, like that:

Would that work? Is it as simple as that? Please tell me if my schema is correct, or else, what do I need to do :slight_smile: (I don't want to try and fry the board!)


Also another little problem with this board:

On the main connector (where are all the input pins) there are two GND pins (and two 5V pins).

The board only works correctly when I connect one of those GND pin to the Arduino GND. But then, when I power the board while the Arduino ISN'T powered, then the Arduino receive some current from the board because the "on" LED of the Arduino is lighted but not fully (and the program don't run).

What can be the problem and how do I solve it? Do I need to connect this GND pin somewhere else, such as on the GND of the 12V power supply of the board (where is connected the GND of the 230V main current)?

Thanks in avance!

Would that work? Is it as simple as that?

Yes but you would not get the same current drive capability no be able to drive loads from a voltage higher than 5V.
Your terms active high and low are miss-used, the term reefers to inputs not outputs. Do you mean current source / current sink perhaps?

No no I mean, when an output of the shift registers is LOW, then the relay is ON, and when the output is HIGH then the relay if OFF.

I want the other way and don't want to change the code because I have something else (LEDs) connected to the shift register's outputs as well, so I want LED ON when relay is ON too :slight_smile:

Then no that would not work because you will not be able to drive the relay direct from the output of the shift register.

But why on earth does this matter what level turns it on? You control it with software so it makes no odds at all.

Ok I now understand the ULN2803 isn't just an array of NOT gates...

Is there a similar device (same pins and size) that do what the ULN2803 do except inverting? (So I could replace the chips easily)

If not, what is the best choice:

  • Another pair of ULN2803...

  • A pair of 74HC540 with their OE inputs not wired so they are LOW (?) (see Truth table in the datasheet)...

  • Three 74HC14...

... right before the board's inputs?

Any other solutions?

Grumpy_Mike:
But why on earth does this matter what level turns it on? You control it with software so it makes no odds at all.

In my previous post I explained why

And, if you could try to answer the other question at the end of first post :slight_smile:

But then, when I power the board while the Arduino ISN'T powered,

Never ever do that. Is is very bad to have anything on the inputs of an unpowered chip.

Is there a similar device (same pins and size) that do what the ULN2803 do except inverting? (So I could replace the chips easily)

No.

I want the other way and don't want to change the code because I have something else (LEDs) connected to the shift register's outputs as well, so I want LED ON when relay is ON too

If you connect the LEDs and resistors across the relay coil they will come on with the relay.

Grumpy_Mike:
Never ever do that. Is is very bad to have anything on the inputs of an unpowered chip.

I don't understand why the Arduino, and also the 16 LEDs that I placed between the shift registers outputs and the relay inputs, were powered. Do I need to add diodes to block current flowing from the relay board inputs to the shift registers outputs?

Or, how to make sure the Arduino is powered before the relay board is powered? Another Arduino-powered relay, that turns ON the power supply of the relay board? Seems like Rube Goldberg electronics :smiley:

Grumpy_Mike:
If you connect the LEDs and resistors across the relay coil they will come on with the relay.

That require soldering on the relay board, which I prefer to avoid. I think I will forget about those LEDs and just show the states of relays on the TouchScreen.

Thanks for your answers, Grumpy Mike :slight_smile:

Seems like Rube Goldberg electronics

No it is how all electronics works.
It is called parasitic back powering. It is caused by the ESD protection diodes on the input chips being forward biased and leaking current into the power rails. When a device like a display has multiple power rails there is often a set up sequence that the device has to follow otherwise you get latch up. Which basically means the circuit will not function until the power is removed.

This is the sort of problem faced by designers working with stand by modes in equipment. Especially with EU regulation pushing the stand by power requirements down even further. I just bought an electric cooker last month and that had to comply with new ridiculously small stand by current so that the time can't be shown when the cooker is not on. Is it any wonder that the EU is very unpopular in the UK with many people.

Do I need to add diodes to block current flowing from the relay board inputs to the shift registers outputs

No diodes would not work because they would prevent a logic zero from being sent and that would lead to the inputs floating.

Well you can plug them in in the correct order but the best way is to drive the arduino from the same power supply as the relay board. That means you can power the arduino through the 5V pin or the Vin pin depending on the voltage you have. Then you need to ensure that the system is powered up before plugging the arduino into your computer.

Grumpy_Mike wrote: "But why on earth does this matter what level turns it on? You control it with software so it makes no odds at all."

If Grumpy_Mike sees this post, I have a question. Here's where I think it matters whether your relay is Active LOW vs. Active HIGH. (But if I have this wrong, would love to know...).

Let's say you connect a relay to Digital Pin 2 on an Arduino which will be used to send the signal to activate the relay. Consider three states: a) Arduino OFF, b) Arduino ON DP2 LOW, c) Arduino ON DP2 HIGH. With an Active LOW relay, the relay is active at B, and not active at A & C. Let's say "ACTIVE" means turning a light on (ie light is wired to NO, so when active the NO closes, circuit completes, light goes on). So the light will be OFF when the Arduino is OFF and OFF when Arduino is ON and DP2 is HIGH, but the light will be ON when Arduino is on and DP2 is LOW.

Here's the problem -- this means that when the Arduino is on, it needs to send a constant HIGH signal on DP2 to keep the light off. But if the Arduino resets or is interrupted in some way, you may get to a state where you will have the Arduino on and DP2 LOW and the light will go on, even though you don't want it too. May not be a big deal for a light to go on briefly while an Arduino resets, but it could be a big deal, depending on the use case.

So it strikes me that you may want to have a relay in which Arduino being powered off, and the digital signal being LOW, result in the SAME relay state -- and so only if the Arduino output is HIGH will the switch activate -- then you need an Active HIGH relay.

Put another way, if you have a power interruption to your Arduino (say you accidentally unplug it briefly), then your light will turn on during that process. But to ensure that a light NEVER turns on unless/until you send a HIGH signal, you need an Active HIGH.

I think this is correct, but welcome corrections. I actually bought a bunch of Active LOW relays and need to replace them with Active HIGHs because of this issue -- so if I'm wrong, I would be saved that cost! (And as far as I have seen, Active HIGH relays are more expensive...)

FYI the reason is: instead of light bulbs, some of my relays will control magnetic locks -- so an Arduino reset would unlock a door (which wouldn't re-lock, even if the power was out for only a second) which would be a problem.

calden, I think you should read about pull-up and pull-down resistors

Still here after two years eh?

Well of course, the correct answer was to wire the LEDs so that they were going to the 5V line so that both the LEDs and the relays were "active low", and I do hope that you figured that on balance, it was not a good idea to connect your system ground to the mains ground unless there was a very good reason for doing so.

And the answer to the problem about whether the relay power supply was switched on without the Arduino supply has been dealt with innumerable times here. The relay board has two "VCC" terminals which must not be linked. The one that powers the relays must logically be connected to the relay power supply, whilst the one that connects to the opto-couplers must be connected to the Arduino power supply. This means that the opto-couplers can only ever be actuated when the Arduino supply is on, and the fact that the inputs will be effectively pulled to ground when the Arduino supply is not powered, does not matter.

A ULN2803 is merely an array of transistors and "kickback" diodes (strictly, Darlington transistors but that does not matter) so this diagram is closely representative of the relay board you illustrated.

But if the Arduino resets or is interrupted in some way, you may get to a state where you will have the Arduino on and DP2 LOW

No you will not get to that state at all.
A reset turns all the pins into inputs. Then you have to use a pull up / down resistor resistor to get the line into the correct default state.

However, you should never have the power to these relays on before the arduino, that is just rank bad design.