Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Serial relay problems.

Status
Not open for further replies.

gonadgranny

Member level 4
Joined
Feb 23, 2011
Messages
68
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,930
Hey. I have an arduino microcontroller which is controlling several relays connected to 40W lightbulbs which are powered by the mains 240v power supply.
I can control the bulbs fine when using a pre-programmed sequence stored on the arduino but what I want to do is control them using a program on my computer over the serial and this is where problems occur.

WHen I try to send preprogrammed signals over serial it works fine in flicking the relays when not connected to the mains power supply but when I do something happens which messes up my arduino and leaves it in a kind of frozen state.

This sounds like some sort of EMF problem maybe but it all works fine when the signals are sent from a sequence stored on the arduino which makes me wonder where the difference arises.

Any help would be massively appreciated.
Danny.
 

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,274
Trophy points
1,413
Location
Southwest, USA
Activity points
62,509
Could be. There are also other possible causes including, but not limited to, back EMF from the relay coils and too much current draw when the relays are energized.

Do you have a schematic of your circuit?
 

gonadgranny

Member level 4
Joined
Feb 23, 2011
Messages
68
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,930
WIth regards to back EMF, I'm struggling to understand why this would not be an issue when the lighting sequence is "Self contained" within the board but becomes such when the signal is transferred over serial.
I don't have a schematic unfortunately.I am self taught and have limited knowledge. The circuit is very simple however, just arduino output to transistor to relay coil which is then accompanied by the mains voltage across the appropriate pins.
I put an LED across the two coil pins in order to try and stifle any EMF kickback. I am not sure if it was placed correctly but since doing so there has not been any problems with the circuit other than when using the serial...
Again, thank you for your help and for any more which I may receive.
Danny.
 

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,274
Trophy points
1,413
Location
Southwest, USA
Activity points
62,509
WHen I try to send preprogrammed signals over serial it works fine in flicking the relays when not connected to the mains power supply but when I do something happens which messes up my arduino and leaves it in a kind of frozen state.
EMI emissions are not an uncommon occurance from the opening and closing of higher voltage relay contacts. This could cause interferance on the RS-232 lines, serial transmit and receive errors and depending on how the AVR's serial routines are written, a cessation of all serial communication.

What is driving the relays? Is it the same power supply driving the Arduino?

Also, out of curiosity, why a LED instead of something more approriate like a 1N4001 to drain the back/kickback EMF?
 

gonadgranny

Member level 4
Joined
Feb 23, 2011
Messages
68
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,930
Yes, the relays are powered by the 5v arduino power supply through transistors. I used LED's as I do not have enough diodes in my kit but if using these would solve the problem then I could certainly purchase some...

---------- Post added at 22:34 ---------- Previous post was at 22:29 ----------

p.s. would the led's "leak" voltage if it is too high? Upon observing them I did not see much optical activity as a result of kickback which was surprising...
 

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,274
Trophy points
1,413
Location
Southwest, USA
Activity points
62,509
Here are some design notes for a relay board design, likely similar to your design:

RELAY DRIVING BASICS

8 RELAY BOARD FOR IR/RF INTERFACE

The first PDF has some very good design tips to calculate max current draw, biasing, etc, you may want to double check your design for any possible problems. I would go ahead an replace the LEDs for a handful of 1N4001, you're talking only a couple of dollars worth of parts. Another problem would be exceeding the current rating of the power supply when a number of relays are energized, this could cause a voltage dip interferring with the MCU and RS-232 level translator/converter (MAX232) both of these events could cause the problem you describe.

I hope the info helps you track down the problem.
 

gonadgranny

Member level 4
Joined
Feb 23, 2011
Messages
68
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,930
Thank you very much for the help. I will look into it.
 

andre_teprom

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,200
Helped
1,142
Reputation
2,303
Reaction score
1,119
Trophy points
1,403
Location
Brazil
Activity points
53,587
...the relays are powered by the 5v arduino power supply through transistors...
I suffered with the same problem in past, when supplyed an on-board modem with same 5V bus also used to a relay.
Every time the relay was stopped conduction, modem restarted.

That´s because the relay coil is winded with thousand turns, performing a big inductance element.
The fact is aggravated because instead 12V relay, the 5V one, requires more turns to acchieve the same force ( according Lorentz law ).

+++
 

gonadgranny

Member level 4
Joined
Feb 23, 2011
Messages
68
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,930
interesting. Is there any way to isolate the cable? winding aluminium foil around the wire maybe?
 

andre_teprom

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,200
Helped
1,142
Reputation
2,303
Reaction score
1,119
Trophy points
1,403
Location
Brazil
Activity points
53,587
Try to put series beads.
However, maybe should be more effective protect 5V bus, if not be possible to provide a separated one for those relays.

+++
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
47,964
Helped
14,147
Reputation
28,553
Reaction score
12,833
Trophy points
1,393
Location
Bochum, Germany
Activity points
278,248
Referring to your initial report, it sounds more likely that the problem is caused by contact sparking and related EMI rather than problems at the relay coil side.
WHen I try to send preprogrammed signals over serial it works fine in flicking the relays when not connected to the mains power supply but when I do something happens which messes up my arduino and leaves it in a kind of frozen state.
The serial interface cable apparently acts as a return for the interfering currents.

Also the assumption, that the RS232 receive routine may be messed up may be an explanation, see post #6.

Of course, this assumption doesn't answer the question, how the interferences enter the processor board. It's most likely also related to relay wiring on the low voltage side. But if the assumption is correct, you would mainly try to reduce the contact sparking, e.g by connecting RC snubbers or VDRs accross the contacts. Also series beads at the coil side as suggested by andre can help to reduce the crosstalk from high voltage output to proccesor circuit.
 

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,274
Trophy points
1,413
Location
Southwest, USA
Activity points
62,509
EMI due to contact sparking was my first inclination as well, see post #4.

The EMI causing interference on the RS-232 coupled with the inability of most MCU UARTs to handle repeated malformed frames by default, putting the UART and the Arduino into a seemingly "frozen state," lends credence to contact sparking being the probable cause:

WHen I try to send preprogrammed signals over serial it works fine in flicking the relays when not connected to the mains power supply but when I do something happens which messes up my arduino and leaves it in a kind of frozen state.
 

gonadgranny

Member level 4
Joined
Feb 23, 2011
Messages
68
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,930
I have just had a look at the definition of contact sparking and it mentions how it affects a wide range of radio frequencies. I have been experiencing interference on my speakers too which confirms that this is probably what it is. so....am i correct in thinking that the usb cable is acting as an antenna which is absorbing this troublesome emf pulse? if so could i surround it by other conductive materials which it might be more inclined to choose? is this a common problem? thank you again for all your help. i appreciate it very much.
Danny.
 

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,274
Trophy points
1,413
Location
Southwest, USA
Activity points
62,509

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top