Hi,
I'm trying to switch a mains current (240V AC) with a relay connecting via a transistor to my PIC (a 16f876a). The PIC is powered from a battery supply - 4 rechargeable AA NIMH cells providing 5V. That's powering the PIC directly - there's no regulator (I presumed there's no need for one).
At the moment the mains supply is hooked up to a light. Everything usually works fine when switching the relay ON, but when the relay switches OFF the PIC resets almost every time.
If I disconnect the mains supply the PIC can turn the relay on and off without any resets.
The schematic is attached. The relays sit on a separate PCB immediately adjacent to the board with the PIC, and the two are connected with 2 inch wires. The wires with the mains current travel close by the PIC board - this isn't really avoidable. The relays are switching the Live wire of the mains supply.
In addition to what you can see on the schematic I've added a 0.1uF cap between MCLR and ground. (Something I saw suggested somewhere.)
I've read a lot about decoupling capacitors, zero crossing, ground planes, and so on! But I don't know where to start, short of randomly trying everything. It would be great to be able to systematically diagnose what's creating the problem, but I don't know how to go about doing this.
Any suggestions are gratefully received.
Thanks,
Luke
Bookmarks