Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

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.
 

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?
 

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.
 

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?
 

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...
 

Here are some design notes for a relay board design, likely similar to your design:



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.
 
Thank you very much for the help. I will look into it.
 

...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 ).

+++
 

interesting. Is there any way to isolate the cable? winding aluminium foil around the wire maybe?
 

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.

+++
 

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.
 

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.
 

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.
 

As FvM suggested, the application of a RC Snubber or VDR is the most prescribed method to absorb contact spark EMI.

Here are a few links discussing these solutions:

PIC 16F54 Controller hangs while triggering a relay



Relay Contact Life

Replacing the tradtional relays with solid state relay is another possible solution.

Hope the info helps solve your problem.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top