Go Down

Topic: Wiring a Opto-Isolated Relay to Arduino (Read 18289 times) previous topic - next topic

MarkT

, leave the jumper in. Having an optoisolatar and the relay seems like overkill to me. Most applications just drive the transistor to drive the relay.
Actually no, its not unknown for mains switching relays to generate enough interference to crash microcontrollers, the opto-isolation can be a real improvement in reliability.
[ I DO NOT respond to personal messages, I WILL delete them unread, use the forum please ]

timmorn

#16
Nov 05, 2018, 08:35 pm Last Edit: Nov 05, 2018, 08:37 pm by timmorn
Oh, to this point: Do you mean relay module VCC or JD-VCC? My plan to set it up like in the schema you postet: VCC gets the Arduino 3.3V, JD-VCC gets the 5V from the buck converter.
Please look at this drawings. It is not clear to me which version I should choose. Or does none of this versions work because of the 3.3V?




Paul__B

Neither is correct.

Please consider carefully and follow my explanation above.

timmorn

#18
Nov 06, 2018, 09:51 am Last Edit: Nov 06, 2018, 09:55 am by timmorn
Neither is correct.

Please consider carefully and follow my explanation above.

Can you help me and tell me what in my drawings is not correct? The only difference I can find is, that you said GND and 5V should run from the buck converter to the relay. But because the same Buch converter Powers the Arduino and the relays, GND is at all interconnected and so it should make no difference in my eyes if GND comes from Arduino or directly from the Buck converter? Is there one more difference?

The second of my drawing is in my eyes the same as the one you shared. Only difference: 3.3V from arduino instead of 5V.

The first one gets 5V to the logical side of the relay. Here I would be afraid that the Arduino gets damaged when logical pins are low and get 5V through it.

Paul__B

The only difference I can find is, that you said GND and 5V should run from the buck converter to the relay.
That is indeed what I said.  Directly from the buck converter to GND and JD-VCC on the relay board.

But because the same buck converter Powers the Arduino and the relays, GND is at all interconnected and so it should make no difference in my eyes if GND comes from Arduino or directly from the Buck converter? Is there one more difference?
Yes.  It is this matter of isolation as MarkT mentions.  Short of providing a separate power supply to the two parts as in the diagram I quoted, you want separate wiring from the one power supply - the buck converter in this case - to each separate part, and as I emphasised, to keep the wiring to each section paired.

This is the real "noob" mistake - presuming that it does not matter how the wires are run as long as they eventually connect one part to another.

Well, we are not dealing with house wiring (and in fact, it matters there too!) here but with electronics and especially electronics that operates at radio frequencies - in fact ten times the frequency of broadcast radio - it matters a lot as wires are now radio antennae to transmit or receive!  :smiley-eek:   If you doubt that, just try holding your radio - on AM or FM - right next to your operating Arduino.

The second of my drawing is in my eyes the same as the one you shared. Only difference: 3.3V from Arduino instead of 5V.
So it is clearly wrong then on both scores.  It shows the relay GND returned to the Arduino instead of the power supply (and it should be run in parallel with the JD-VCC connection), and it shows the relay VCC going to 3.3 V instead of the "Raw" pin.

The first one gets 5V to the logical side of the relay. Here I would be afraid that the Arduino gets damaged when logical pins are low and get 5V through it.
OK, you have it seems, read enough discussions here to be cautious about what voltages you connect to Arduino pins.  That is excellent in itself but you will just have to read the last paragraph of my original explanation a few times in order to understand it.

OK, to help you, here is the circuit of the relay board:  (Actually, let me attach that to my first post for convenience)

You will note the two LEDs in series, which means that until the voltage between VCC and IN reaches 2.6 V or so, no current will flow so it could never pull the Arduino pin higher than 5 - 2.6 or 2.4 V, which is much less than 3.3 V.

Please have another go at getting the diagram right - it will then be useful for others.

timmorn

Wow. Thank you very much for your patience. I think I understand now.

So, I think this is what you explained:



The only thing I am not sure is, that you said "and it shows the relay VCC going to 3.3 V instead of the "Raw" pin" but I think here you talked of the second drawing, because this should really not matter if I connect to Arduino RAW or to Buck converter 5V?

One Last Question for my special project: Is returning GND of relay to the Buck Converter a thing of "this is the really correct way, but should also work if returning to Arduino"? Because in my special setup it is a little tricky to return GND to the Buck Converter, because I already designed and bought a PCB where this Pin is returning to Arduino  :smiley-confuse:

Paul__B

OK, nearly there.

The VCC on the relay board pairs with the "IN" lines which go from the relay board to the Arduino, so it should travel with them and and back to the "Raw" pin on the Arduino or at least alongside the 5 V line from the "Raw" pin back to the buck converter, not with the "JD-VCC" power line.

I am merely explaining the correct approach to design.  Anything may "work" but if not correctly laid out, may not work reliably.  I cannot see what a PCB has to do with it if the design has not been finalised.  :smiley-eek:

timmorn

The VCC on the relay board pairs with the "IN" lines which go from the relay board to the Arduino, so it should travel with them and and back to the "Raw" pin on the Arduino or at least alongside the 5 V line from the "Raw" pin back to the buck converter, not with the "JD-VCC" power line.
I want to try the second way to improve my understanding. Is this the way you want it?



Can you explain to me why this image makes a difference to my last image? Is the matter the length of the cable? Or that the cable really is physically near the other cable? Why? Electromagnetic Interference?

Paul__B

OK, that's good now!

Yes, absolutely!  Electromagnetic Interference.  You have all the wires to one section of the circuit neatly together and somewhat distanced from the other.

The relay wiring is subject to significant current transients or impulses.  Wires carrying this current not kept together form a loop which generates a magnetic field.  Wires which are used as inputs to the Arduino which are not kept together form a loop which can pick up such impulses, so the forward and return wires of any circuit must be kept together.

A lone wire which has voltage transients on it propagates an electrostatic field and this may capacitively couple to another unshielded wire.  Having the corresponding (ground) return adjacent helps to contain this electrical field and reduce transfer from one circuit to another.  Look up the theory of a "transmission line".

(But you see, the line from VCC back to the 5 V terminal would be shorter if it simply dropped off at the "RAW" terminal as it is right next to - as it should be - the other wire back to 5 V - which is part of the same circuit.  :smiley-lol: )

outsider

#24
Nov 07, 2018, 08:40 pm Last Edit: Nov 07, 2018, 08:59 pm by outsider
When the Arduino outputs are HIGH there is 3.3V on them but you are putting 5V on one of them and causing reverse current to flow through that pin's protection diode to GND, I think Vcc pin on relay module should connect to Vcc (3.3V) pin on Arduino.
Quote
You will note the two LEDs in series, which means that until the voltage between VCC and IN reaches 2.6 V or so, no current will flow so it could never pull the Arduino pin higher than 5 - 2.6 or 2.4 V, which is much less than 3.3 V.
So just leave the JD-VCC jumper on and eliminate a wire.

Paul__B

So just leave the JD-VCC jumper on and eliminate a wire.
So you do not understand the concepts of "isolation" and "decoupling"?

polymorph

Davidking8811 please don't hijack someone else's thread.
Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8
Multitasking: forum.arduino.cc/index.php?topic=223286.0
gammon.com.au/blink - gammon.com.au/serial - gammon.com.au/interrupts

Paul__B

Davidking8811 please don't hijack someone else's thread.
You sure about that?  :smiley-roll:

polymorph

Well, the post is gone now. So... I look like a crazy person.
Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8
Multitasking: forum.arduino.cc/index.php?topic=223286.0
gammon.com.au/blink - gammon.com.au/serial - gammon.com.au/interrupts

Paul__B


Go Up