AVR acts weirdly when a 12 V solenoid valve is connected to it with a relay

Thread Starter

chathurinda

Joined May 28, 2017
2
Hi , I'm doing this soil moisture sensing project with a solenoid valve to automate the watering using an atmega32A microcontroller . I'm using external power pack to give 12 V to the solenoid valve and 5 V regulator to convert the 12 V and give to the microcontroller. I've attached the 12 V solenoid valve with a relay to the microcontroller. and I have added a LCD to display information.I have included 2 interrupts in the code which will display 2 messages in the LCD .

The relay switching and everything works fine with the 12 V supply until I attach the solenoid valve to the other side of the relay. and when the 12 V solenoid valve is connected those interrupt functions starts showing up in the LCD even when I'm not pressing the interrupt switches.and the circuit sometimes gets reset. and sometimes other characters starts showing up on the LCD.

if anyone can help I would be grateful !
 

bertus

Joined Apr 5, 2008
22,270
Hello,

How are the parts connected?
Are you using a backEMF diode on the valve?
Can you post a schematic?

Bertus
 

Picbuster

Joined Dec 2, 2013
1,047
Agree with Bertus however: a bare solenoid is using current and will create spikes positive and negative ones.
Action should betaken to diminish that.
Power supply impedance is also having effect.(if both supply and circuit at full load are identical voltage will drop 50%)
Next: the decoupling of processor(s)
Next: getting all the transients from processors power supply circuit.

But again if you want help post schematic.
Picbuster

Mod edit: language
 
Last edited by a moderator:

JohnInTX

Joined Jun 26, 2012
4,787
In addition to the good advice above, be sure to use separate power lines (power and ground) for the processor/LCD and other ugly stuff. Route each pair back to the source power and decouple there.

Consider that transients can show up on the inputs and that you might need to consider debouncing them.
Junk on the LCD can be from transients on the E line.
 
Top