Problem with Arduino + Solenoid

Hi everybody,

I have a circuit with an Arduino Uno and an 12v water valve (solenoid). I’ve connected the solenoid to the same power source of Arduino (12v 5a and tried an 12v 1a also), when I connect the solenoid (or 12v water valve) works and Arduino works fine too, but when I disconnect the solenoid the Arduino resets.

I’ve tried connecting through a relay, directly on the power source,… but every time I get the same result: when I disconnect (turn off) the solenoid the Arduino resets…

The circuit schematic before the adjustments:

After the adjustments:

What could be happening?

Thanks!!

Have you got a flyback diode? I don’t know the symptoms of not having one, but I wonder if the reverse spike could cause a reset? (Assuming you know for a fact it is resetting.)

Unfortunately I'm sure about the resetting... I've already tried to use a diode (1n4007) but the problem still the same. Here a video with the problem occurring: https://youtu.be/Yi_y5MG4KNw P.S.: in this video I'm using a circuit with an standalone ATMEGA 328, but testing with Arduino Uno the problem is the same.

Curious....

When I look at the video, the LCD is displaying some text. However when the system is "reset" by removal of the solenoid, the text comes back immediately. Would think if the µP was reset it would have to rewrite the text.

Could it be the light in the LCD being effected somehow?

Does the text actually disappear of just the backlight?

JohnRob

Put a serial print in setup() and look for it in the monitor to check it's resetting.

Hi, Can you post a drawing how you drive the relay with the Arduino?

The video doesn't show flyback diodes across the relay coils. That will kill the relay drive transistors.

The solenoid also must have a flyback diode across. Spikes will reset or kill the MCU.

I don't see any decoupling on the 5volt regulator or on the MCU.

You need to fix all those things to make your circuit stable. Upload a diagram if you want proper help. Leo..

JohnRob: Curious....

When I look at the video, the LCD is displaying some text. However when the system is "reset" by removal of the solenoid, the text comes back immediately. Would think if the µP was reset it would have to rewrite the text.

Could it be the light in the LCD being effected somehow?

Does the text actually disappear of just the backlight?

JohnRob

In fact the whole "system" is rebooting, not just the LCD backlight. The texts come back to the same because the program was in the beginning on the moment of error. If the program is on a different stage, the text on the display will change to the initial message of the program. What is happing is like I unplug the Arduino or ATMega from the power supply and plug again.

nyphot: Put a serial print in setup() and look for it in the monitor to check it's resetting.

As I said to JohnRob, unfortunately I'm sure it's reseting... But I believe it's an electrical problem not the program it self, if I don't connect the solenoid everything goes fine.

tauro0221: Hi, Can you post a drawing how you drive the relay with the Arduino?

Hey, I've updated the original post and added the schematic. But the problem is not in relay... Without connecting the solenoid, the circuit works fine. The problem occurs even if I connect the solenoid directly on the 12v power source (with the circuit connected to the same power source and with or without using the relays).

Wawa: The video doesn't show flyback diodes across the relay coils. That will kill the relay drive transistors.

The solenoid also must have a flyback diode across. Spikes will reset or kill the MCU.

I don't see any decoupling on the 5volt regulator or on the MCU.

You need to fix all those things to make your circuit stable. Upload a diagram if you want proper help. Leo..

Hi, thanks for the tips, I've just updated the original post with the circuit schematic. About de diodes I've already adjusted that, but the problem stills... And theres decouplers before all the relays.

I though that maybe could be a good ideia adding some capacitors on the circuit... What do you think?

I'm quite newbie and learning now, so sorry for the beginner mistakes :|

Capacitors are what is used for decoupling. It helps clean up the power supply to the ic.

What you say are decouplers are actually optoisolators. They are used to physically seperate 2 circuits for a few different reasons, png the logic circuits from transients is one, but you seemed to negated them by connecting the power supply and ground to both circuits.

As for the before/after diagrams…point out the changes. It’s like a game of “where’s Waldo”.

You also don’t show the solenoid hookups either. They require a diode across them, just like the relay coils and motors, which are all bad about putting voltage spikes on the power supply, and you have all of them hooked to yours along with the uC without decoupling capacitors.

Hi,

[u]Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?[/u]

ALL your GND tracks are TOO narrow.

ALL your POWER tracks are TOO narrow.

Where are the suppression capacitors that are supposed to be mounted CLOSE to the regulator, look at the data sheet for the regulator and the suggested circuit.

Where are the bypass caps for the controller IC?

Leave as much copper on the PCB as possible, you are paying for the PCB not how much copper you use.

Did you breadboard this project before going to PCB?

Please a [u]circuit diagram[/u], it is confusing to see 2x rele1 and 2x rele2 and 2x rele3, how many relays do you have?

You can drive the BC548 from the 328 directly.

Do you have a DMM?

Thanks.. Tom.. :) PS, Do not update your original post. Place any changes in a new post.

Hi, You are missing an electrolytic capacitor after the LM7805 and also I will add a .1uf capacitor in parallel with it. I will use a 470uf 16 volts. Also your ground path it is too thin. Any try to add the capacitor after the regulator.

Hi, Also, I will add another electrolytic cap 470uf 16V to pin 7.

Ceramic decoupling caps are needed. Electrolytic buffer caps are also needed, depending on the supply used.

Why the opto couplers. They have no function on a single supply. Remove them, and connect a 1k resistor (assuming relays are 12volt) directly from Arduino pin to relay transistor base.

The diagram does not show diodes across the relay coils. The motors also need diodes across. Leo..

Hi, Sorry too many advised but also you should add another 470uf 25 volt cap at +12 volt connector. You may need a larger one to allow the load from the solenoid and the relays when they are enable/disable. It looked to me your problem it it the sagging of the voltages.

TomGeorge: Hi,

[u]Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?[/u]

ALL your GND tracks are TOO narrow.

ALL your POWER tracks are TOO narrow.

Where are the suppression capacitors that are supposed to be mounted CLOSE to the regulator, look at the data sheet for the regulator and the suggested circuit.

Where are the bypass caps for the controller IC?

Leave as much copper on the PCB as possible, you are paying for the PCB not how much copper you use.

Did you breadboard this project before going to PCB?

Please a [u]circuit diagram[/u], it is confusing to see 2x rele1 and 2x rele2 and 2x rele3, how many relays do you have?

You can drive the BC548 from the 328 directly.

Do you have a DMM?

Thanks.. Tom.. :) PS, Do not update your original post. Place any changes in a new post.

Hi, sorry for the mess and thanks for answering. Is it better now?

|500x207

http://i.imgur.com/plqe4GC.png

ALL your GND tracks are TOO narrow.

ALL your POWER tracks are TOO narrow.

[u]Thanks for the tips, I'm gonna change the circuit to adjust it...[/u]

Where are the suppression capacitors that are supposed to be mounted CLOSE to the regulator, look at the data sheet for the regulator and the suggested circuit.

Where are the bypass caps for the controller IC?

[u]I'm gonna put some, until yesterday I didn't know what was a suppression and bypass capacitor... :( I'm already searching more information about it.[/u]

Leave as much copper on the PCB as possible, you are paying for the PCB not how much copper you use.

[u]Until I'm learning, these PCBs are homemade. I'll try doing it, can I just ask why? I want to understand the reasons to repeat on another projects...[/u]

Did you breadboard this project before going to PCB?

[u]The most of it, yes... I just didn't know this little issue with the solenoid. I was reading and where there is a coil, there is problem... And I didn't know it is so problematic.[/u]

Please a [u]circuit diagram[/u], it is confusing to see 2x rele1 and 2x rele2 and 2x rele3, how many relays do you have?

[u]I have 3 relays, some other components as resistors I called relays too to make it easier to mount the PCB schematic.[/u]

You can drive the BC548 from the 328 directly.

[u]Just the decoupling diode should be enough? The optoisolators is too much?[/u]

Do you have a DMM?

[u]DMM is a Digital Multimeter? If yes, I do.[/u]

Thanks for all the tips!!!!!!!!!

tinman13kup: Capacitors are what is used for decoupling. It helps clean up the power supply to the ic.

What you say are decouplers are actually optoisolators. They are used to physically seperate 2 circuits for a few different reasons, png the logic circuits from transients is one, but you seemed to negated them by connecting the power supply and ground to both circuits.

As for the before/after diagrams......point out the changes. It's like a game of "where's Waldo".

You also don't show the solenoid hookups either. They require a diode across them, just like the relay coils and motors, which are all bad about putting voltage spikes on the power supply, and you have all of them hooked to yours along with the uC without decoupling capacitors.

Hi, thanks for answering, here is the circuit schematic: http://i.imgur.com/plqe4GC.png

I use fritizing to draw my circuits, if you want I can send the original file too...

About the changes between the two circuits, I added some diodes to the relays.

The solenoid is connected to a screw terminal on relay 1.

I need to learn more about capacitors and diodes... I'm gonna try to study more about it.

As I'm new on "this world" my circuits (and schematics) are confusing and childlike sometimes... There is just on month that I'm "playing" with electronic. Before I was just programing the Arduino with modules... Now I'm trying to evolve.

tauro0221:
Hi,
You are missing an electrolytic capacitor after the LM7805 and also I will add a .1uf capacitor in parallel with it. I will use a 470uf 16 volts. Also your ground path it is too thin. Any try to add the capacitor after the regulator.

I’ll do it… Sorry for asking, I want to learn and understand more about capacitors, why these capacitors? What I mean is, how do I measure it?