Relay Board

Hi,

I am finally getting around to revisiting my train signal project. I currently have a pretty basic code that seems to do what I want, my next problem is now the relay board.

Ok, the relay board I have is Low for on so that when there is no power/ signal the relay is off, makes sense to me. After a bit of searching this is probably done with a pull up resistor on the actual relay module.

Ideally I need the relays to remain off anytime the program is not asking them to be on as they points motors will burn out if constantly left on.

When the arduino is initially turned on all is fine I.e. The relays are all off until a button is pressed as it sends all the pins high as it is programmed to.

When the relay board is just powered up (nothing connected to the input pins) the relay is off, the pins are high due to the pull up resistor, all is good.

But if the arduino is connected to the relay board but the arduino is powered off the pins are sent low and the relays are turned on. As soon as I also power up the arduino they are sent high as programmed.

Is this normal? It there a way I can resolve this problem

Thanks

Maybe, put a diode between the relay board and the Arduino control pin.

aarg:
Maybe, put a diode between the relay board and the Arduino control pin.

Assume the OP is refering to the common relay board with opto inputs.

Can you please explain how an extra diode would reverse the logic / problem ?

ricky101: Assume the OP is refering to the common relay board with opto inputs.

Can you please explain how an extra diode would reverse the logic / problem ?

It sounds like the protection diodes on the Arduino I/O pins are conducting current when it is turned off. As I reconsider this, I guess it wouldn't help to use diodes. Sorry. An open collector transistor buffer/inverter would, because it would need current from an active voltage source (i.e. +5V) to turn on.

Really, the relay board should have that kind of logic to prevent this problem.

OP did not post a link to the relay board used. So any advise given could be wrong. Leo..

Yes, please post a schematic.

aarg:
It sounds like the protection diodes on the Arduino I/O pins are conducting current when it is turned off. As I reconsider this, I guess it wouldn’t help to use diodes. Sorry. An open collector transistor buffer/inverter would, because it would need current from an active voltage source (i.e. +5V) to turn on.

Really, the relay board should have that kind of logic to prevent this problem.

Thanks, fair enough, would have been nice if it was that simple !

Give the OP is using a relay board with opto inputs, then the only solution to this regular problem seems to be to use a chip like the ULN2803A between the arduino and relay board to invert the signal again, or to hack the relay board so your conection from the Arduino goes directly to the 510 ohm base resistor to the transistor, so bypassing the opto /inversion.

If this is the circuit (but I see that we are jumping the gun here), you could also hack the input circuit by grounding what is now the input, and connecting the 1k resistor to the input instead of VCC. Then the LED indicator would still work, and you would still have opto-isolation.

If I were designing such a board, this would definitely be a jumper selectable option.

Or use a relay board like mine, shift data into a TPIC6C595 and it sinks relay coil current.
I use SPI.transfer to shift data in, here’s a video clip of 3 of them daisy chained together controlling 120V LED strings (Christmas lights).

IMG_3176.JPG
IMG_3175.JPG

I don't expect to sell any, as pictured and buying material in 25-lots, it costs $34.25 as a kit with SMD only parts installed and user to add all the thru hole parts.

Sure is nice to only need 3 IO pins to control a lot of relays - I've tested with 3 boards, 24 relays, with SPI.transfer at 4 MHz loading in the data.

prs999: Ok, the relay board I have is Low for on so that when there is no power/ signal the relay is off, makes sense to me.

After a bit of searching this is probably done with a pull up resistor on the actual relay module.

1) True if you're talking about the common 1/2/4/8 relay boards (not the 16).

2) Not with a pullup resistor. The opto coupler LED on the board is connected between +5volt and "relay in" Opto LED current flows from Arduino's 5volt line, through the opto LED, back to the Arduino pin (sinking).

prs999: Ideally I need the relays to remain off anytime the program is not asking them to be on as they points motors will burn out if constantly left on.

When the arduino is initially turned on all is fine I.e. The relays are all off until a button is pressed as it sends all the pins high as it is programmed to.

When the relay board is just powered up (nothing connected to the input pins) the relay is off, the pins are high due to the pull up resistor, all is good.

Ok if you take care what you put in void setup. Again, no pullup.

prs999: But if the arduino is connected to the relay board but the arduino is powered off the pins are sent low and the relays are turned on. As soon as I also power up the arduino they are sent high as programmed.

Is this normal? It there a way I can resolve this problem

1) If you have connected the board as intended, the relay pin is low when the Arduino is off, but so is the 5volt supply for the opto LEDs. So the relays should be off when the Arduino is off.

2) Connect the board as intended.

Arduino 5volt to relay 5volt. Arduino pins to the relay ins. [u]NO[/u] ground between Arduino and relay board. [u]NO[/u] ground between Arduino and relay board. [u]NO[/u] ground between Arduino and relay board. JD-VCC jumper removed. Dedicated supply for the relay coils connected to JD-VCC (coil power) and ground. Leo..

Yes, it appears you have a relay module with opto-isolation because the control is active-low. However, you don't have it configured to use this isolation, otherwise it is impossible for this problem to happen due to the relay connections alone.

To configure for full isolation, remove the jumper and use a separate DC supply and make sure there is absolutely no ground wire from the relay board to the Arduino. Problem solved.

|450x194

EDIT: Wow - Wawa! Your post came just before I submitted this (you've got my vote, +1) :)

+1 An image can replace a thousand words. Leo..

Hi All

Thank you for all of your replys.

Firtsly apologies it has been a long day at work!

You were all correct in your assumptions about the relay board I am using it is the opto islolator type as Ricky101 outlined in his diagram

Wawa and dlloyd have solved the problem. I basically had 1 power supply feeding both the arduino and the relay coils (although the modules were optoisolated I decided, maybe incorrectly that I didn't really need this function) therefore the Grounds were the same. I have now powered the arduino off of the usb and left the psu just doing the coils and voila all is as expected as per dlloyd's diagram

Thanks again everyone for all of your help

Of course, the VCC on both sides of the opto is (or should be) different. I missed that obvious fact. It makes perfect sense now.