i can't undestand what happen

hello friend i had a problem on my project i make a pcb that alow to atmega 328 control 2 relays for specific time and after the atmega should operate the Buzzer for 3 time for 1000ms to make me pay attention that the operation is finish (I'm certain of my code because i execute it on arduino and evry thing is ok no blocking no delaying ) now the problem is when i put a 220 v as consumerand i start the program , after finishing the relays controle Sometime the program blocking and buzzer didn't operate

note that i use opptocoupler PC817 and transistor 2N2222A to controle the 5v Relays and same transistor to controle the Buzzer and OPPO F5 charger to supply the arduino it output is 5V 2A

this is the schematic of project if anybody wonna see it https://drive.google.com/open?id=1htvZ-BLh-i18QXs-eOM-VUkmELerKVAc Any help will have a big impact :) :) am so sorry for this poor anglish :) am ready to give evry information that usefull for fix that problem

You need a 0.1uF capacitor from reset to ground. This is so the reset is released after the processor is powered up.

thanks you mike for your reply i have put 0.1uf between the + and ground of atmega 328 and the problem did not rebuke again i wonna now that if that is enough or i should put a 0.1uF capacitor between Reset and Gnd as you said Mike !!!!

10k for the optocoupler is very high value. Also there should probably be a base resistor on the relay transistors to limit the current, perhaps 220 ohms or so.

With 10k resistors your opto coupler output current will be small, and not well defined (variation between devices), and not turning the transistors on fully.

10k is just default value of resistace am sorry for that

i use 550 ohms for all

i wonna now that if that is enough or i should put a 0.1uF capacitor between Reset and Gnd as you said Mik

Yes that is why I said it.

Hi All, Please note: on the attached schematic, Q1 & Q2 are shown as 2N3906, PNP. This is wrong! They should be NPN transistors. (2N3904 is good) OP is using 2N2222 and that is good. Herb

As already mentioned, your design has some serious omissions and errors. To summarize:

You have no supply bypass capacitors for the processor. This will lead to eratic behavior at best and a non-responsive board in the worst case.

The lack of base resistors on Q1, 2 and 3 can kill the processor.

Optocouplers that share input to output side grounds do not provide isolation and serve no purpose. Eliminating the PC817’s and selecting proper switching transistors for the relay control will result in a better design using less board space at a lower cost.

actualy i use 2N2222A for all semiconductor on mu project but in the schematique is defferent because there is no 3d design for 2N2222 on protues version the i use that is why i use defferent type of transistor just in the schematic no in the reality

i wonna no your opinnion about the proper switching transistors type that i should use

You are also removing any benefit of opto isolation by having a common ground on both sides of the opto, so you might as well get rid of all that and just use a single mosfet to switch the relays

TMISAII: i wonna no your opinnion about the proper switching transistors type that i should use

We would need to know the relay coil specs and operating voltage.

WattsThat: We would need to know the relay coil specs and operating voltage.

sangle SRD-05VDC-SL-C

Looks like needs about 80ma and the 2N2222 will handle that fine with a 470 ohm base resistor. Your original 550 ohm resistor is okay as well, not as much margin but I seriously doubt it will matter.

Hi,

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .

OPs diagram.

You should be able to EXPORT your diagram as jpg and attach it to your post.

Tom… :slight_smile:

Hi, Can you post a picture of your project so we can see your wiring and component layout.

Keep ALL 220Vac wiring away from any low voltage wiring to minimise AC interference.

Tom.. :)

Note you are using a 2N3906 to drive those two relays, these are PNP transistors and you have wired them up as if they were NPN transistors. So either wire them correctly or use NPN transistors.