Arduino freezes due to 12 V on relay?

I use an Arduino Mega combined with a RLY08 relay from robot electronics to control a dosing pump for my aquarium.

The relay board is controlled via i2c. I can control 8 different relays in this way and without adding the dosing pump, it works…

However, at the moment I add the dosing pump (12V, 150 mA) and the power supply, after about 5 times switching the pump on and off, the Arduino freezes and so does the relay. I have to reset the Arduino to get it working again.

Without putting the power adapter into the outlet, it does not freeze and the relay is functioning as it should do.

I think there is a kind of shock or leaking current to the arduino. I also made a ‘counter’ that counts the amount of seconds the pump is turned on. If the adapter is plugged in, sometimes the value goes from 3 seconds to a strange value like 3200300. This does not occur if the adapter is not connected. Therefore, it’s not a software bug.

I have tried 1K, 1K8 and 10K pull up resistors, but all without succes. I also tried another adapter, same result.

I hope somebody can help me, I’m so frustrated! It took me a lot of time trying to find the cause.

Thanks in advance! :slight_smile:

Scheme:

[Click for large picture]

I think you need some supply decoupling around the motors:- http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

What is that thing in series with the wall wart supply? It looks like it might be a motor, if so it is a rather unconventional way of wiring it up. The other wires are not labeled where do they go?

Thanks for the tip about de-coupling. But is the Relay module not supposed to take care of this? It should keep the circuits separated.

It's a dosing pump. Indeed, it contains a kind of motor. It's just a second circuit connected to one relay. Maybe its my drawing but I think it's the only way to wire it up??

OK if the problem only happens when that motor is switched on then the problem is the motor.

It is generating interference that is screwing up the rest of the circuit. Decoupling is one way of reducing the interference on the circuit being interfered with. This is not something that would be taken care of by the relay board, or if it is it is not effective enough.

You can do things to reduce the interference the motor generates, like put a reverse diode across the coil (I am assuming it is a DC motor) You can also add small capacitors across the motor and an inductor in line with the power supply. Then you can add a ferrite to the motor wiring, like those bulges you see in computer leads sometimes.

Many thanks for the advice

http://www.robot-electronics.co.uk/htm/rly08tech.htm

It's a ready-to-use relay board. I think I cannot easily add a reverse diode without modding the board? I added a 1 uF capacitor and this seems to be an improvement, however i'm still testing....

update: The problem is still there, but the situation has improved, less crashes.

Should I add more / less 1uF capacitors? In parallel I suppose?

I think I cannot easily add a reverse diode without modding the board?

Yes you can you can wire it directly off the motor.

What sort of capacitor are you using? The best for this sort of work is a ceramic one. These have lower inductance and so should clobber higher frequencies better. Also consider a series inductor or choke as well as the capacitor.

I added a 1 uF capacitor

is this on the motor or on the power feed to the relay board? You could do with both.

So in reversed order and parallel to the the pump?

The capacitor is a Electrolytic Capacitor 1uF 50V 105° E5R Radial, so probably the cheapest available?

So in reversed order and parallel to the the pump?

Yes.

Electrolytic Capacitor

I would change that. These are very inductive and while better than nothing can let stuff through. I would be inclined to keep it and add a 100nF ceramic in parallel with it.

At the moment I have two of these electrolytic capacitors of 1 uF and this gives the best result until now, I’ve had no crashes anymore while I have turned the relay on and off for hundreds of times.

How can this be explained compared to the situation with only 1 capacitor? Is it the capacity that is doubled?

So you are proposing to add a 0.1 uF ceramic capacitor in parallel to the 1 uF electrolytic capacitor? And this in combination with the reversed diode over the pump.

By combining the two types capacitors, don’t you still suffer from the disadvantages of the electrolytic capacitor?

Thanks for your time. I really appreciate your help and I like to learn about this.

Is it the capacity that is doubled?

Yes capacitors in parallel add up so you have got the equivalent of a 2uF capacitor

By combining the two types capacitors, don't you still suffer from the disadvantages of the electrolytic capacitor?

No because the lower value capacitor shorts out the larger one.

Sorry for the thread jump, but I have a question about decoupling cap you mention above. So If I had a 12VDC motor and I want to add a decoupling cap two I would putt the Cap across the positive and negative leads to the motor? Rough sketch attached below.

Yes that's right. Use a 0.1uF ceramic along with something like a 4u7 electrolytic.

Thanks Grumpy_Mike, to verify it is a 4u7 (4.7uF) electrolytic cap? Polarized or non-polarized?

Yes 4.7uF but it is written as 4u7

Polarized or non-polarized?

Electrolytic capacitors are always polarised but an unpolarised one would work just as well. However if you are switching the direction of the motor by reversing the voltage then you must either use an unpolarised capacitor or put the capacitor before the change over circuitry so that it always sees the same potential across it.

Thanks Grumpy_Mike