Go Down

Topic: Relay module is active low...how to reverse that (Read 19509 times) previous topic - next topic

arusr

Hello,

EDIT:  this is the relay module I have:
http://www.amazon.com/SainSmart-4-CH-4-Channel-Relay-Module/dp/B0057OC5O8

This seems to be a common problem, and newbies like me are surprised when it happens.  But what's a good way around this?  When the Arduino reboots, it sets off the relay, which turns on the output (a remote control power switch).  That's not the behavior I want.  I've tried setting the output to HIGH right away during setup, but there's still a long delay before the relay is de-energized.
What's a good way to make the relay modules active high?  I have an NPN transistor that I can use to flip it, but the example I find use a ULN2803, and I don't know how to take that schematic and apply it to a single NPN transistor.
For reference:
http://electronics.stackexchange.com/questions/39920/turn-on-a-relay-when-the-output-is-high

Thanks!

JoeN

You have linked to another discussion which contains a broken link to the product you say you have.  Sort of unhelpful.

If the relay module you are using, which you could have provided a link for, has a normally closed relay on it, and it's hard to tell with the extreme lack of specificity here, you are screwed.  When it is off, the relay is closed, end of story.  Get a different module.

I hope that is not the case.  It sounds like when there is no input to the relay module the input is floating and somehow floats to a signal level where the relay module closes the relay without there being any signal.  If this is the case, the normal solution is a pull up or pull down resistor, whichever causes the module to leave the relay open.  Approximately any higher value resistor will do, probably try a 4.7K or 10K one and if for some reason that isn't strong enough, use a 1K.
I will never ask you to do anything that I wouldn't do myself.

fungus

You use a thing called a "pull up resistor" (or pull down) to keep the voltage on the line stable during boot.

Alternatively: Use relays with optoisolators (which you should really be doing anyway).
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Paul__B

Since the Arduino boots with all outputs open circuit, you need to find what is pulling your relay board input low on reboot and fix that.  Of course, it would make it obvious to us what the problem is if you actually revealed what the relay module is, and how you have it all connected (and I mean as always, all of the connections).

Pull-ups are clearly not going to help.  I strongly suspect that that you actually mean, is that the relay board is actuated when you turn off the Arduino but leave the relay board powered, since with the power off, the protective diodes will pull the outputs down to whatever the Vcc line is, which is zero if there is no power in the Arduino board.

if your relay board includes an opto-isolator - as I presume it does since almost all of those which take active-low inputs do, then you need to separate the link connecting "Vcc" to "JD-VCC" and power the Vcc from your Arduino whilst you continue to power JD-VCC from the relay supply.


arusr

#4
Oct 23, 2014, 06:32 pm Last Edit: Oct 23, 2014, 06:37 pm by arusr Reason: added explaination.
Quite right, I should've included the relay module:

http://www.amazon.com/SainSmart-4-CH-4-Channel-Relay-Module/dp/B0057OC5O8


The relay board has an optocoupler I believe.  When the Arduino digital output is LOW, the relay is energized.  When the Arduino output is HIGH, the relay coil is de-energized.  I am jumpering the JD-VCC to VCC. and powering the relay board's VCC from the Arduino's 5V supply.  I'm only using one of the relays, so I have a digital output from Arduino to relay 4.

Grumpy_Mike

That is rather a poor design, yes you will get that problem.

One way to correct this is to use a transistor to switch the Vcc line to the relay board and control that transistor from an arduino output. This will give you a sort of output enable output.

arusr

you need to separate the link connecting "Vcc" to "JD-VCC" and power the Vcc from your Arduino whilst you continue to power JD-VCC from the relay supply.

I had the jumper on the Vcc and JD-Vcc.  I can take the jumper off and power the Vcc from Arduino and JD-Vcc from another voltage source...but does that solve the problem?  The Arduino's output will still go low when it reboots, and the relay board would still be active LOW, would it not?  So when the Arduino reboots (1-0-1 transistion), the relay would still pull in until the microcontroller runs the program again.

The relay is de-energized 99.9% of the time (Arduino output is 1 99.9% of the time).  I only energize the relay coil for 1 second to mimic the pushing of a button.


dlloyd

#7
Oct 23, 2014, 10:39 pm Last Edit: Oct 23, 2014, 10:43 pm by dlloyd

Active High Logic Connection:

Arduino output HIGH = Relay coil energized.
Arduino output LOW = Relay coil not energized.

This should work providing the power link is
removed and you only drive one relay.
Leave IN1, IN2 and IN3 disconnected.

UNTESTED
 



Paul__B

#8
Oct 23, 2014, 10:50 pm Last Edit: Oct 23, 2014, 10:53 pm by Paul__B
The Arduino's output will still go low when it reboots, and the relay board would still be active LOW, would it not?  So when the Arduino reboots (1-0-1 transition), the relay would still pull in until the microcontroller runs the program again.
Someone correct me if I am wrong here, but the Arduino output does not go low when it reboots, it is open circuit and will not actuate the opto-coupler.

What does sound of interest now, is that you are powering the relay board from the Arduino Vcc.  I am betting that is the problem and that if you provide a more appropriate power source for the relay board (JD-Vcc), the problem will go away.

Oh, and if the relay power supply is only used for the relay board, do not deliberately connect its ground to the Arduino ground.

Universal problem reported here but the Arduino Vcc should never be used for powering motors, relays, or other than a couple of LEDs drawing 10 mA or so.

This should work providing the power link is removed and you only drive one relay.
So what happens if he wants to use the other relays, eh?  ;D

My advice - find the actual problem and fix that.

Byork

The Arduino's output will still go low when it reboots, and the relay board would still be active LOW, would it not?  So when the Arduino reboots (1-0-1 transition), the relay would still pull in until the microcontroller runs the program again.
Someone correct me if I am wrong here, but the Arduino output does not go low when it reboots, it is open circuit and will not actuate the opto-coupler.

What does sound of interest now, is that you are powering the relay board from the Arduino Vcc.  I am betting that is the problem and that if you provide a more appropriate power source for the relay board (JD-Vcc), the problem will go away.

Oh, and if the relay power supply is only used for the relay board, do not deliberately connect its ground to the Arduino ground.

Universal problem reported here but the Arduino Vcc should never be used for powering motors, relays, or other than a couple of LEDs drawing 10 mA or so.

This should work providing the power link is removed and you only drive one relay.
So what happens if he wants to use the other relays, eh?  ;D

My advice - find the actual problem and fix that.

I second this, it does not go low on reset. I have this relay board in 4/8/16 channels, and I have reset/uploaded sketches countless times with the relay hooked up to my arduino, it never goes low.  Try using external power for the board, if that still doesn't work, you will probably need to tell us more about your setup.

Grumpy_Mike

Quote
Someone correct me if I am wrong here, but the Arduino output does not go low when it reboots, it is open circuit and will not actuate the opto-coupler.
No correction required here. Pins default to inputs and so can and will float so there is no current path and the relay will not turn on.


Quote
Oh, and if the relay power supply is only used for the relay board, do not deliberately connect its ground to the Arduino ground.
I would disagree with that. You need to sing the current to activate the opto to activate the relay so you do need the arduino ground connecting to the relay board ground if it has a separate supply.


Quote
Arduino Vcc should never be used for powering motors, relays, or other than a couple of LEDs drawing 10 mA or so.
I would disagree with that as well, providing you apply sufficient decoupling you can run everything off one supply. If you don't decouple then the simple way round is to use a separate supply.

Paul__B

Quote
Oh, and if the relay power supply is only used for the relay board, do not deliberately connect its ground to the Arduino ground.
I would disagree with that. You need to sing the current to activate the opto to activate the relay so you do need the Arduino ground connecting to the relay board ground if it has a separate supply.
You haven't been following the theme here.  Read it again and recant!

Quote
Arduino Vcc should never be used for powering motors, relays, or other than a couple of LEDs drawing 10 mA or so.
I would disagree with that as well, providing you apply sufficient decoupling you can run everything off one supply. If you don't decouple then the simple way round is to use a separate supply.
I said - the Arduino Vcc.  The one derived from the on-board regulator (or the USB which will admittedly provide a little more power).  It will not provide power or motors and the like.  You are thinking of running the Arduino Vcc from a serious power supply, which is a totally different matter.


dlloyd


Q
So what happens if he wants to use the other relays, eh?  ;D
A
...I'm only using one of the relays, so I have a digital output from Arduino to relay 4.
Q
My advice - find the actual problem and fix that.
A
problem:  Re: Relay module is active low...how to reverse that

Q
eh?  ;D
A
Who talks like that??? (I'm from Canada) ;D

KenTF

You do realize that the relay switch has TWO positions.  Instead of using the Normally Open position, you could use the normally closed instead.  Then just change your program logic accordingly.

Paul__B

I'm only using one of the relays, so I have a digital output from Arduino to relay 4.
Makes you wonder - why would you get a four relay module and only use one relay?

Q
My advice - find the actual problem and fix that.
A
problem:  Re: Relay module is active low...how to reverse that

And - as so often turns out to be the case in these discussions, that is absolutely not the problem once you get down to it!

Who talks like that??? (I'm from Canada) ;D
You would perhaps prefer "Oi!"?

You do realize that the relay switch has TWO positions.  Instead of using the Normally Open position, you could use the normally closed instead.  Then just change your program logic accordingly.
Again, you need to read the thread and understand what the actual problem is.  If you do, you realise that is not a solution at all!

Actually, I am getting to quite like the new forum system in many ways (but not all).  I have it set to display 25 topics per index page, and 25 messages per thread.  And I have - largely accidentally - got rid of the botched "WYSIWYG" reply window function.

Go Up