arduino Controlling Circuit Hangs when controlling 230v ac fan using a relay

hi.......
i have made a circuit for controlling home appliances like light fan etc.
when i control lightning load arduino works fine but when control fan or operate fan after two or three time operation it hangs/freeze the arduino.
i m using atmega 328 ic, uln2003, 12v relay for controlling 230v ac load.

I think we need a schematic; real one or photo/scan of handdrawn one. Are you using a relay board? If so, which one?

Code could also be useful (not sure though in this situation if it will help); please use code tags as shown below

type
** **[code]** **

paste your code after that
type
** **[/code]** **
after that

Before copying the code, please auto-format it in the IDE.

hi sir,
here is my schematic

schematic_pdf.pdf (91.3 KB)

jyotinpatel:
when i control lightning

Who are you? Zeus? :open_mouth:

First thing I would do is to add a 100nF capacitor to the power rails, close to the ATmega chip. The large electrolytic capacitor at the output of your voltage regulator has a relatively high (internal) resistance and inductance (compared to smaller ones), plus the distance from the voltage regulator to the chip adds inductance as well (from wires or PCB traces), meaning that very sudden spikes or drops in voltage can occur, caused by electromagnetic interference caused by the fan, for example (or inductive loads in general).

This is a possible solution, but not very likely, I'm afraid.
Next thing to do is checking all the wiring and solder joints, maybe two wires short out the circuit and cause the Arduino to reboot, maybe install a power indicator LED to monitor the supply voltage, or a even a blinking LED to the ATmega. I'm suspecting a hardware related issue here.

But if you are using a large program with arrays, you may run out of memory, or maybe a segmentation fault causes a reboot. This seems even more unlikely, but we can't completely rule it out yet.

I see you're not using opto isolation for your relay circuit. This would have really helped with eliminating any conductive interference on the power rails when the relay contacts are switched.

I'm quite sure that if you install MOVs like these, it would cure or greatly reduce the problem (emissive RF from contact arcing). The MOVs could be installed from the NO to COM contacts. Additional MOV's would be needed from the NO to COM terminals if 230VAC load is switched here.

Also, you may need to increase the distance from the relays and electronics.

Also, a ferrite core on the DC power rails (relay power & GND) would be a great help. Use multiple turns if possible. Others have used a ferrite core in the AC load wire with great results.

You should add a snubber circuit on the AC load, to filter inductive currents.

I've had very similar problems. In my case switching noise from the relay would even disrupt other nearby electronics such as my wireless mouse. It would affect the microcontroller even when I was switching the relay manually.

MOVs are worth a try but if that doesn't work then you might need a snubber across the AC load as suggested. For me a 100R resistor and 100nF capacitor solved the problem permanently. Note that you need to check the power and voltage rating of the resistor and must use a safety-rated capacitor. You may also have to experiment with different values.

If you can stretch to using a solid state relay and it is suitable for your application it may be an easier solution.

1 Like

actually i m controlling ac fan speed using my microcontroller. sometime it runs nice for 1 hour or for a day and sometime it hangs with two or three times operation. by doing some experiment and some trial and error i found the result that it is problem with inductive load and some time when sparking is occur in any manual switch near that device. I want permanent solution for my this problem.

mart256:
You should add a snubber circuit on the AC load, to filter inductive currents.

can u tell me the value of capacitor and resistor for snubber circuit