Atmega328p-pu resets when trying to run solenoid valve

I am trying to make a controller which controls a stepper motor and a operates a solenoid valve. It also has an LCD Screen and a matrix 5x4 keypad.
Everything works fine until i connect the coil of the solenoid valve.
The coil is operated by an onboard relay, which is operated by an s8050 transistor which is operated by pc817 opto coupler which is controlled by atmega328p-pu.
Now when the coil is charged no problem there it works fine the solenoid valve operates but as soon as the power to the coil is cut the atmega328 resets.
Even if the coil is connected to a completely different smps then too this happens. As soon as the power going to the coil is cut arduino resets.
Even if the coil is not at all connected to the controller and i connect-disconnect the coil manually by hand powered by a different smps. If i keep the coil near the controller atmega328 resets.
Can someone please explain the reason why this is happening and what solution should i implement to prevent this from happening.

Please post a schematic. Hand drawn, photographed and posted is fine. Include all pin and terminal numbers/labels, components, their part numbers and/or values and all power supplies. Post technical data for the components including the specs of the power supplies.

It sounds like there is a reverse EMF generated when the coil power is disconnected. How to mitigate that depends on the schematic.

1 Like

You haven't mentioned the "kickback" or "commutating" diode. :roll_eyes:

Using Diodes in circuits with Solenoids - Using Arduino / General Electronics - Arduino Forum


re: pwillard

Whenever I hear a topic along these lines, I always think "Not enough power!"
Check:

  • Is the Atmega328p-pu getting enough power? The power supply for the Atmega may be outputting too little voltage.
  • Is the relay drawing too much current (there is a short circuit or the relay has too little resistance)? If so, get a power supply with higher wattage for the relay.

I will take a SWAG as there is no schematic. Try without a load on the relay contacts, if it resets it is in your circuit probably back EMF from the relay coil. This tends to manifest itself when the coil is turned off but if you have a pulse in the relay coil power it can do it as well.

Atmega328 is powered by 7805 linear voltage regulator and another 7805 powers the lcd. Input of the regulators is a 24v 5A SMPS.
Relay takes about 50mA and whole Circuit takes around 200mA.
And the coil takes around 200mA as well.
The relay has a flyback diode but the coil doesnt.
I tried to run the coil with the same SMPS as well as a saperate SMPS atmega resets in both cases.
If i run the circuit without connecting the coil it runs perfectly fine with no problems.
Even if i remove the wires of the coil from the relay and short them manually without any connection to the controller, powered by a saperate smps if the coil is kept anywhere near the pcb the atmega328 resets which is quite wierd.

I will post the schematics as soon as i reach my workshop as i dont have access to the schematics here at my home.
@anon44338819

These are the Schematics of the circuit.
I am not a pro at this. I am just a beginner trying to understand things so please forgive me if the schematics are not how they should be.


@groundFungus @mrburnette @gilshultz

I hope you are heatsinking the 7505s you have about 3.8 watts of heat to dissipate. Your schematic is a great start. I am having problems following the reset circuit, VCC and Vref. There are a bunch of parts but no connections to power or ground. I would interpret your schematic sourcing them through the processor, which I doubt. Also is this on a PCB or a prototype assembly? If this is on a prototype board consider using twisted pairs in all the relay circuits and see if that helps, You can connect ground at only one end so it will act as a shield.

You are running the 7805s at the high-end of their voltage specification:

IMO, for such an input, a DC-DC is a far better design, more forgiving and far more efficient.

Are the 7805s hot? I know your current requirement is not much, but the regulators have to shunt the voltage drop.

IMO, weird is an understatement. There is a possibility that somewhere a ground is not proper, creating an above-zero potential.

You may wish to try powering the 7805's with a 12 Volt set of batteries and then use a DVM to check every ground connection directly from the battery negative for the negative probe.

Its a PCB and not a prototype assembly. But I have printed the pcb in house using toner transfer method. So can it be an issue? When initially printing the pcb i forgot about the decoupling capacitors for the atmega328. So i soldered two 0.1uF ceramic capacitors on the pcb traces directly.

Yes 7805 are running hot but they do have heatsinks.
I am thinking of redesigning the pcb with some other method of power supply instead of 7805's.

Hi,
Now how about a proper schematic to troubleshoot your project?

Can you draw a schematic that has all the pinouts used joined together, not net numbers.
You schematic is okay for PCB design, but a nightmare for signal tracing and trouble shooting.

Can you please post images of your PCB pattern, so we can see how you have placed your traces and provided suitable noise prevention?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Isolate the circuit with optocoupler it will work fine.

There are switch mode supplies that are the same pin out and near the size as the 7805s.

Op's primary PSU is still too high in Voltage:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.