User avatar
Wizards Hat
Posts: 13
Joined: Tue Jan 01, 2019 9:58 am
Location: Manchester, UK

Relay Line out voltage causing voltage on line in

Tue Jan 01, 2019 1:35 pm

I think I have a problem with voltage noise passing between supposedly isolated parts of a relay & don't know how to get rid of it.

I have recently bought a standard 5V relay module board (8-channel)* and can control it without issue using an mcp23017 connected to the pi (3).
However, when I connect the output of the relay to a mains connected appliance (light bulb for example) the relay no longer works.

I have determined that whenever the mains AC line is connected to the output, there is approximately 2V across the GND-In(any) of the relay inputs - this is present even if there are no other connections to the relay board.
Therefore the voltage signal coming from the controller can never drop the signal to 0V and the relay doesn't fire.

I also have a variable power supply up to 15V & that also causes noise on the input but only up to about 100mV & the relay will still energise.

Can anyone suggest a solution to this?
I want to be able to power several mains operated components (a smoke machine, fan & lights) for my current project.

TIA,
Dan.


*Image

pcmanbob
Posts: 6619
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Relay Line out voltage causing voltage on line in

Tue Jan 01, 2019 3:19 pm

Hi.

If connecting AC mains to the relay output terminals causes 2 volts to appear on the ground of the 5v circuit, it suggests the is some thing wrong with either,

how you have the mains connected to the board,

there is a fault on the board which is shorting the relay contacts to the 5v circuit,

or possibly you have the relay board on a conductive surface which is causing a short.

Working with these relay boards and mains is not some thing I would recommend unless you have training and qualifications to work on mains electricity as the mains voltage is present on the back side of the pcb.

Mains AC voltages can and will kill your or burn down your house given the chance.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
Wizards Hat
Posts: 13
Joined: Tue Jan 01, 2019 9:58 am
Location: Manchester, UK

Re: Relay Line out voltage causing voltage on line in

Tue Jan 01, 2019 3:59 pm

Appreciate the response Bob...

....I do realise the danger involved even though I have no "official" training on electrical wiring...but I am a very experienced physics teacher (& therefore a degree in physics too) & very much understand what not to do.

I have been trying to research this problem for 2 days & I am 100% confident I have it wired correctly - I must assume from what you say that I have a short on the board...irritating.

Regards,
Dan.

pcmanbob
Posts: 6619
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Relay Line out voltage causing voltage on line in

Tue Jan 01, 2019 4:32 pm

You could always post a pictures of how you have it all wired, fresh pairs of eyes might help.

Have you got the relay board standing on an insulated surface ? as I said all voltages are present on back side of pcb were ever there is a copper track or solder point.

Does the problem occur across all relays or just one ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

klricks
Posts: 6535
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Relay Line out voltage causing voltage on line in

Tue Jan 01, 2019 4:33 pm

Wizards Hat wrote:
Tue Jan 01, 2019 3:59 pm
Appreciate the response Bob...

....I do realise the danger involved even though I have no "official" training on electrical wiring...but I am a very experienced physics teacher (& therefore a degree in physics too) & very much understand what not to do.

I have been trying to research this problem for 2 days & I am 100% confident I have it wired correctly - I must assume from what you say that I have a short on the board...irritating.

Regards,
Dan.
What country are you in? (You can add location to your profile)
Is there a common ground connection between RPi and relay board and all DC power supplies?

I am not sure the following will help but somethings to check:

Are all DC power supplies connected with 3 prong grounded plugs?
Are all the load devices and RPi power supplies on the same AC circuit?
Are you sure you are switching the line and not the neutral? To be sure you would need to test the AC outlet to be sure it's wired correctly.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

Brandon92
Posts: 773
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: Relay Line out voltage causing voltage on line in

Tue Jan 01, 2019 5:10 pm

Also, how did you connect the mcp23017 and the relay board to each other. And how did you configure the relay board.
Because, the Rpi is operates at 3.3V and your relay board is 5v. What could mean that your are not able to enable the relay.

And did you measure the voltage between the gnd - inx when the power supply for the relay was still present? If this is the case, depending on the jumper selection. You could simply measure the vcc minus the forward voltage of the led plus the forward voltage of the led inside the optocoupler. And this is nothing to worry about.

User avatar
Wizards Hat
Posts: 13
Joined: Tue Jan 01, 2019 9:58 am
Location: Manchester, UK

Re: Relay Line out voltage causing voltage on line in

Tue Jan 01, 2019 5:19 pm

Hopefully you can see the attached picture - when there is NOTHING else connected to the relay other than the 240V line out (UK mains)..on ANY of the channels, there is a voltage between GND-In(all) of line in ...when taking this picture it was 1.25V.

Image

Can't seem to find any obvious short between the 2 sides.

Regards,
Dan.

Brandon92
Posts: 773
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: Relay Line out voltage causing voltage on line in

Tue Jan 01, 2019 5:38 pm

Maybe a very stupid question, but are the battery in your multimeter not empty. Because this could result in very strange measurement.

And what is the voltage across DS7. Because when you measure that voltage where you measure it right know. There should also be a voltage across that led (series).

And is there something on the bottom of that pcb, what there should not be?

edit:
Are you measuring the same when you disconnect the mains voltage? And make it a difference when you place your multimeter further from that pcb?

User avatar
Burngate
Posts: 5967
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Relay Line out voltage causing voltage on line in

Tue Jan 01, 2019 6:13 pm

My first reaction would be to sling that board in the bin, as far away from mains as possible!

But ... can you measure any resistance between any of the output connections and any of the inputs?
There should be infinite resistance. Anything less is a fault.

User avatar
Wizards Hat
Posts: 13
Joined: Tue Jan 01, 2019 9:58 am
Location: Manchester, UK

Re: Relay Line out voltage causing voltage on line in

Tue Jan 01, 2019 6:42 pm

Thanks for the suggestions...
Brandon92 wrote:
Tue Jan 01, 2019 5:38 pm
Maybe a very stupid question, but are the battery in your multimeter not empty. Because this could result in very strange measurement.
Erm...ok...not thought of that, but just changed it & get the same readings.
Brandon92 wrote:
Tue Jan 01, 2019 5:38 pm
And what is the voltage across DS7. Because when you measure that voltage where you measure it right know. There should also be a voltage across that led (series).
There appears to be about 0.12V across all of the LEDs (DS1 to DS8)
Brandon92 wrote:
Tue Jan 01, 2019 5:38 pm
And is there something on the bottom of that pcb, what there should not be?

edit:
Are you measuring the same when you disconnect the mains voltage? And make it a difference when you place your multimeter further from that pcb?
Nothing on the bottom of it.
When I unplug the mains, the readings drop to 0V.

Regards,
Dan.

User avatar
Wizards Hat
Posts: 13
Joined: Tue Jan 01, 2019 9:58 am
Location: Manchester, UK

Re: Relay Line out voltage causing voltage on line in

Tue Jan 01, 2019 6:45 pm

Burngate wrote:
Tue Jan 01, 2019 6:13 pm
My first reaction would be to sling that board in the bin, as far away from mains as possible!
Fair enough about binning the board - what would you suggest in its place? For my project I need to be able to turn on/off mains operated smoke machine, fan & lights.
Burngate wrote:
Tue Jan 01, 2019 6:13 pm
But ... can you measure any resistance between any of the output connections and any of the inputs?
There should be infinite resistance. Anything less is a fault.
Tried to find a short this way, not found anything that links the 2 sides.

Regards,
Dan.

pcmanbob
Posts: 6619
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Relay Line out voltage causing voltage on line in

Tue Jan 01, 2019 8:00 pm

If you really need to switch mains voltages then I suggest you look at octal relays, they mount on individual bases with screw terminals.

I would look to use ones with 12v DC coils, then use a separate 12v PSU to power them and a uln2803A to interface the pi gpio to the 12v switching the ground side of the coil.
The uln2803A has built-in back emf diodes to protect the electronics from the back emf generated by the relay coil.

The uln2803A is also designed to be driven directly by the 3.3v of the pi gpio.

If you need a diagram for connecting up I can draw one up for you.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

pcmanbob
Posts: 6619
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Relay Line out voltage causing voltage on line in

Tue Jan 01, 2019 8:04 pm

Wizards Hat wrote:
Tue Jan 01, 2019 6:45 pm
Burngate wrote:
Tue Jan 01, 2019 6:13 pm
My first reaction would be to sling that board in the bin, as far away from mains as possible!
Fair enough about binning the board - what would you suggest in its place? For my project I need to be able to turn on/off mains operated smoke machine, fan & lights.
Burngate wrote:
Tue Jan 01, 2019 6:13 pm
But ... can you measure any resistance between any of the output connections and any of the inputs?
There should be infinite resistance. Anything less is a fault.
Tried to find a short this way, not found anything that links the 2 sides.

Regards,
Dan.
To do insulation testing you really need a proper insulation tester that generates mains voltages but a very very low current, and ordenary digital meter will only be using low voltage < 12v DC so won't cause any bad insulation to break down.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
Wizards Hat
Posts: 13
Joined: Tue Jan 01, 2019 9:58 am
Location: Manchester, UK

Re: Relay Line out voltage causing voltage on line in

Tue Jan 01, 2019 8:20 pm

pcmanbob wrote:
Tue Jan 01, 2019 8:00 pm
If you really need to switch mains voltages then I suggest you look at octal relays, they mount on individual bases with screw terminals.

I would look to use ones with 12v DC coils, then use a separate 12v PSU to power them and a uln2803A to interface the pi gpio to the 12v switching the ground side of the coil.
The uln2803A has built-in back emf diodes to protect the electronics from the back emf generated by the relay coil.

The uln2803A is also designed to be driven directly by the 3.3v of the pi gpio.

If you need a diagram for connecting up I can draw one up for you.
I actually want to drive the relays for these from i2c using MCP23017 (nearly all the GPIO will be tied up already), but I assume the rest of what you describe will be the same.

I would really appreciate a diagram for this - although my training is in physics, I've never been taught any electronics & I've always gone along the lines of ...well this works so far, so that's the route I'll follow ...so if someone who knows what they're talking about suggests a better route, I'll gladly follow :D

Regards,
Dan.

Brandon92
Posts: 773
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: Relay Line out voltage causing voltage on line in

Tue Jan 01, 2019 8:32 pm

Wizards Hat wrote:
Tue Jan 01, 2019 6:45 pm
Fair enough about binning the board - what would you suggest in its place? For my project I need to be able to turn on/off mains operated smoke machine, fan & lights.
I also won't use that kind of relay board to switch the mains on and off. Because, the layout ect will probebly not be 100% ok and the relay are also questionable. And depending on what you need to switch, the relay his contact need to be suitable for that. So, not all relay can switch the same. Some are special design to switch motors and others are designed to switch lights.

As a example, this kind of relay are more suitable and saver to switch the lights: finder 22-21-9-012-4000 and the datasheet.

And like others say, you can drive then direcly by a transistor (or a uln2803A). But if it is easyer for you, you also can use the relay board that you have to switch a proper relay (like the finder).

stevend
Posts: 211
Joined: Fri Oct 11, 2013 12:28 pm

Re: Relay Line out voltage causing voltage on line in

Tue Jan 01, 2019 8:46 pm

Wizards Hat wrote:
Tue Jan 01, 2019 1:35 pm
I think I have a problem with voltage noise passing between supposedly isolated parts of a relay & don't know how to get rid of it.

I have recently bought a standard 5V relay module board (8-channel)* and can control it without issue using an mcp23017 connected to the pi (3).
However, when I connect the output of the relay to a mains connected appliance (light bulb for example) the relay no longer works.

I have determined that whenever the mains AC line is connected to the output, there is approximately 2V across the GND-In(any) of the relay inputs - this is present even if there are no other connections to the relay board.
Therefore the voltage signal coming from the controller can never drop the signal to 0V and the relay doesn't fire.

I also have a variable power supply up to 15V & that also causes noise on the input but only up to about 100mV & the relay will still energise.

Can anyone suggest a solution to this?
I want to be able to power several mains operated components (a smoke machine, fan & lights) for my current project.
Were the input points where you're measuring the voltage high impedance? If so, it takes very little coupling to get some sort of reading. Try measuring the voltage with a resistor connected first to VCC, then to GND. Value will depend on the exact drive circuit.
Any idea what the circuit driving the relays is? Those 4-pin ICs are often optocouplers, and I have had odd readings across them in some situations.
As far as driving your bits and pieces from those relays is concerned, if they are reasonably low current the actual relay contacts should do. However you've also got the very important issue of maintaining high voltage isolation between mains and low voltage sides; this is firstly down to the spec on the relays themselves, then to how the PCB is laid out, and how you mount it in an enclosure. The spec on the relay itself looks reasonable.

Brandon92
Posts: 773
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: Relay Line out voltage causing voltage on line in

Tue Jan 01, 2019 9:14 pm

stevend wrote:
Tue Jan 01, 2019 8:46 pm
The spec on the relay itself looks reasonable.
Well, it depents on how you look at it. If you use a resistive load it can switch 10A @240VAC. However, the load that the op want to switch are not resistive load. And if you take a look how much the can switch a inductive load at 230VAC. Well, that is not specified! And the maximum power that they can switch is only 240-300W (depending on the type) and that is only 1A. And not the 10A that is written on the relay itself.
srd-05vdc-slc.PNG
srd-05vdc-slc.PNG (159.93 KiB) Viewed 1264 times
.
As a comparison the relay that I wrote earlier about. Depanding on what type of lamp your are using, you can connect a higher power or less power to the relay itself. So the relay is rated at "20A" but it can only switch 200W LED. Thats why it is very imported to chose the right relay for the task you want!:
22.21.9.012.4000.PNG
22.21.9.012.4000.PNG (97.67 KiB) Viewed 1264 times

JohnsUPS
Posts: 110
Joined: Fri Jul 06, 2018 2:13 am
Location: USA

Re: Relay Line out voltage causing voltage on line in

Tue Jan 01, 2019 11:27 pm

What is happening is that you are getting coupling from the mains back to the input from within the relay, and this is largely the result of the high voltage AC connection. Bear in mind that the input impedance on your multimeter is very high, and that any coupling will show up because there is no loading on the pin. Some of this coupling may also be due to the board layout. You probably wouldn't have this problem if you were switching a lower voltage AC line or DC.

The addition of minor loading on the pin you're measuring should knock the 1.25v down considerably. Experiment with a resistor (say >4.7k or so) between the relay board input signal pin and ground while you have your multimeter connected and see what happens. Connect the resistor as close to the board input pins as you can.

Also consider buffering the MCP23017 output pins with a transistor follower (such as an NPN 2N2222 or 2N3904), and have the transistor do the switching rather than the chip. This is what I would do. The logic will probably have to be inverted if this is done. The transistor will probably switch the inputs harder than the IC will, and will also give you flexibility to tweak the circuit that drives the input to the board to give you reliable operation.

The MCP23017 data sheet indicates that the current sink/sourcing capability of the output pins is pretty good (25ma), and is more than adequate to drive the LED within the optocoupler and activate the relay. This output also appears strong enough to still drive the opto adequately with a resistor across the input at the board, so long as that resistance value isn't too small.

Another option, although it may seem redundant, would be to have the relays on the board do the switching for another bank of much heavier relays that actually do the mains switching/heavy lifting. Doing so would protect your relay board at the least, and provide a much more difficult path for inductive coupling to take place. If the magic smoke escapes for some reason, you probably will only have to replace a 'secondary' relay rather than the whole 8 channel board.

jerryk
Posts: 30
Joined: Wed Nov 02, 2016 3:26 pm

Re: Relay Line out voltage causing voltage on line in

Wed Jan 02, 2019 12:57 am

I used the same relay board in an alarm system interface. I'm switching 12v and lower circuits but as far as driving all 8 of the relays directly from the pi goes I opted to use a separate power supply and 2n3904's to activate the relay coils.

Although I used the primary pins on the pi to drive the transistors I could just as well used the mcp23017 pins to drive the transistors. Regardless of how you set things up, I think having a separate power supply drive the board is essential due to the current draw of the Songle Relays. I did not consider this board mains worthy from things I read about it on the eev blog forum.

Any sort of mains application for me will be as described in the post above where I will use a mains rated relay driven by the songle relays on the sainsmart board which appears to be the same as yours.

Here is how I wired things to the relay board. It runs cool even with all 8 relays on full time.

https://drive.google.com/open?id=19SVl5 ... DjDgwfbbtK

Jerry

pcmanbob
Posts: 6619
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Relay Line out voltage causing voltage on line in

Wed Jan 02, 2019 8:06 pm

Diagram showing how to connect ULN2803A to gpio and relays be it octal or anther type of relay with a 12v DC coil.

Image

Only shown 3 relays but you can drive 8 from the chip ,integral clamp diodes for switching inductive loads, so no need for them to be added externally, ULN2803A can be driven from 3.3v of pi gpio or up to voltage on common pin so driving it from your mcp23017 should be fine.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
Wizards Hat
Posts: 13
Joined: Tue Jan 01, 2019 9:58 am
Location: Manchester, UK

Re: Relay Line out voltage causing voltage on line in

Sun Jan 06, 2019 3:54 pm

That's brilliant - thanks Bob.

I've bought some ULN2803A chips - just need to decide on what relays to get now.

Why do you suggest the "octal" ones?...seems like a much reduced/limited choice

...would appreciate suggestions from anyone as to what specific relays to actually use - there seems to be a huge choice & I'm not sure why to choose one over another.
=> want to be able to control a 400W smoke machine (so assume ~2A), light bulb & extractor fan (~20W)...all on separate switches.

Regards,
Dan.

Brandon92
Posts: 773
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: Relay Line out voltage causing voltage on line in

Sun Jan 06, 2019 4:09 pm

Wizards Hat wrote:
Sun Jan 06, 2019 3:54 pm
Why do you suggest the "octal" ones?...seems like a much reduced/limited choice
He used one of the relay of his drawing package as a example.
Wizards Hat wrote: ...would appreciate suggestions from anyone as to what specific relays to actually use - there seems to be a huge choice & I'm not sure why to choose one over another.
=> want to be able to control a 400W smoke machine (so assume ~2A), light bulb & extractor fan (~20W)...all on separate switches.
Did you read my posts about the relay. I suggested one for the light bulb in a previous post :) And why it is important to choose the right one.

User avatar
Wizards Hat
Posts: 13
Joined: Tue Jan 01, 2019 9:58 am
Location: Manchester, UK

Re: Relay Line out voltage causing voltage on line in

Sun Jan 06, 2019 4:58 pm

Brandon92 wrote:
Sun Jan 06, 2019 4:09 pm
Wizards Hat wrote: ...would appreciate suggestions from anyone as to what specific relays to actually use - there seems to be a huge choice & I'm not sure why to choose one over another.
=> want to be able to control a 400W smoke machine (so assume ~2A), light bulb & extractor fan (~20W)...all on separate switches.
Did you read my posts about the relay. I suggested one for the light bulb in a previous post :) And why it is important to choose the right one.
Yeah, I read your post & that's why I need more help/suggestions
- if the one you suggested is ok for a light bulb, but not ok for a 400W smoke machine & I look on the Farnell website you linked to & go up one level & filter to 12Vdc coil, there are nearly 1000 relays listed but no filter for power, only filters for current.

How do I find what I need without having to read 1000 datasheets (even then, I'm not sure what I'm trying to find in them...it's unlikely to list "smoke machine" in there :D )

Regards,
Dan.

pcmanbob
Posts: 6619
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Relay Line out voltage causing voltage on line in

Sun Jan 06, 2019 7:16 pm

This relay will switch 7A of resistive load at 240V AC which is about 1600W and seeing as it has 4 contacts you could common them together to switch even more.

https://uk.farnell.com/finder/55-34-9-0 ... stViewed_1
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Brandon92
Posts: 773
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: Relay Line out voltage causing voltage on line in

Sun Jan 06, 2019 7:55 pm

pcmanbob wrote:
Sun Jan 06, 2019 7:16 pm
This relay will switch 7A of resistive load at 240V AC which is about 1600W and seeing as it has 4 contacts you could common them together to switch even more.

https://uk.farnell.com/finder/55-34-9-0 ... stViewed_1
Personally, I would not add the relay contacts parallel to each other. Because there is always one contact that make contact first before the other ones. This means that the unlucky contact will carry all the current first. Before sharing it with the others. Then you can better use the version with less contacts: https://uk.farnell.com/finder/55-32-9-0 ... dp/2787151

And here you kind find other families of that relay type and others.
Also a interesting to know: https://en.wikipedia.org/wiki/Utilization_categories

But also remember that the fuse in front of your relay is smaller than the maximum allowed current of the relay.

Return to “Automation, sensing and robotics”