Electronic – arduino – microcontroller resetting and hanging problem

arduinoatmegaavr

I am controlling a 16×2 LCD and a high electrical device using ATmega8l microcontroller but if there appears a spark in AC power line due to high electrical device then my microcontroller goes to reset or unreadable character on LCD or controller goes to hang and I have to reset.

please help me what should i do ?

Best Answer

It is possible that the power supply for your ATmega is unable to supply enough power during those sparkling times when you turn your AC load on. If the power to the processor drops to below a certain voltage, it will reset. You want to add a big electrolytic capacitor between the Vcc and Gnd pins: you probably have two Vcc and two Gnd pins; add a capacitor for both.

I don't know how you are controlling your AC device: is it possible that some of the line voltage is reaching your ATmega? That would be bad.

Also as Rick_2047 notes, make sure you are not pulling more than 40mA from each one of your ATmega pins, and even 40mA is a bit much. If you need to drive loads more than 20mA consider using transistors or FETs. If you are using a relay to switch your AC load it likely needs a decent amount of power, so use a transistor.

Finally, if you are using a relay, you need to snub the transient voltages generated when you turn it off. There needs to be a diode in parallel with the relay contacts to safely handle the transient voltages.