I am just adding one more thing on top of what Richard Recommended isolate your pic output pins with opto couplers And you never see that problem again. Andre Abelian -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU] On Behalf Of llile@SALTONUSA.COM Sent: Monday, February 24, 2003 3:25 PM To: PICLIST@MITVMA.MIT.EDU Subject: Re: Fw: [PIC] Help in PIC interference problems? >I have a design which uses a PIC16F877 to switch on/off some relays controlling pneumatic valves(230VAC) and contactors(230VAC). There is also a Hitachi 44780 based LCD to display some values. The problems arise when I tried to switch on/off the pneumatic valves and contactors, the PIC seems to have the following problems quite often (30%): >It seems that these problems happens especially when switching high inductance load such as solenoid of 12VDC, 24VDC and 230VAC through the relays. >Currently for the above design I am using ULN2803A to sink 12VDC relays. Both the relays and PIC used the same 12VDC supply except the PIC through another 5V (7805)regulator. The DC voltage seems to be quite acceptable durring the switching but I am unable to study further as I don't have a storage scope. >Any experiences or ideas on how to solve these interference problems? Richard, you have a nasty problem. You may spend weeks beating your head against the wall solving it. There are a number of things you can do, and there is no telling which one (or three!) will be the solution. Don't get any haircuts in the next few days, you'll need all the hair you can grow because you are going to pull a lot out. You should start by throwing out your PCB board design, and then it gets worse from there: 1. Don't paste capacitors all over your circuit just yet. This is a band-aid which won't help you if you have more basic problems. 2. Make sure you have a ground plane under your PIC, and also between your PIC and any relays. A relay coil magnetic field collapsing will induce currents in the PIC's die, making it go insane. A nice, low impedance grounded foil path under the PIC will help a lot. Ground plane needs to go under your LCD driver too. If your relays are stacked on top of the PIC that is extra bad, if they are all on the same PCB but widely separated that is better. 3. Physically separate your relay board from your control board. Consider putting your control board inside a can. 4. Physically separate your grounds for your digital circuits and your power circuits. Tie them together at one point, right at the power supply transformer. Use a ground plane for both sections. 5. Add a MOV (A.K.A. TVSS) to the mains input. 6. Make sure you have a catch diode in parallel with each DC relay coil. Make the foil path very short between the coil and the catch diode, and use a fast diode, not a 1N4001. You may also experiment with using no catch diode and using a parallel resistor for this. 7. Make sure your relay contacts have a snubber network across them. This will be a small resistor (10 ohms or so) in series with a small capacitor (0.1 uF or so). 8. You may have to experiment with syncrhonous switching, firing your relays at particular moments in the AC sine wave. This is tricky using relays, as they are slow. 9. You may have to switch with Triacs instead of relays, and use zero crossing switching to reduce noise. 10. You may need a better 5V regulator that can handle fast transients. regular 7805's are pretty bad at catching fast transients. Even better yet, tap separate power supplies for the relays vs. the PIC from the power transformer or AC source. Leave the relay power unregulated. 11. Consider higher voltage relays, 24V or even 48V. These make less of a power supply spike when they kick off, because they consume less current. Your problem may be mains spikes due to mains contact switching, in which case this trick is irrelevant. 12. Use a lot of sanity checks in your code. Test key registers and variables, if they have changed since you wrote them, your PIC is insane and should be sentenced to die of a watchdog timeout. Check sanity on startup by writing numbers to a list if registers, then checking to see if the numbers are still there. If not, then die-you-dog until the PIC is proved sane. 13. NOW, paste capacitors all over your circuit. Load a handlful of 0.1 UF capacitors into a blunderbuss and fire them at the schematic. You need one 0.1 uF at the very terminals of the PIC, one at the very terminals of the LCD controller, one in parallel with every electrolytic filter cap, one on each side of your 5V regulator, and some others just for fun. Good luck. -- Lawrence Lile Senior Project Engineer Toastmaster, Inc. Division of Salton, Inc. 573-446-5661 voice 573-446-5676 fax Richard Sent by: pic microcontroller discussion list 02/21/2003 11:13 PM Please respond to pic microcontroller discussion list To: PICLIST@MITVMA.MIT.EDU cc: Subject: Fw: [PIC] Help in PIC interference problems? I have a design which uses a PIC16F877 to switch on/off some relays controlling pneumatic valves(230VAC) and contactors(230VAC). There is also a Hitachi 44780 based LCD to display some values. The problems arise when I tried to switch on/off the pneumatic valves and contactors, the PIC seems to have the following problems quite often (30%): 1)LCD display clear off and could not response to further control by the PIC unless the reset.(seems that the LCD requires to be initialize again) 2)LCD starts displaying at the wrong position (Code has been skipping) 3)PIC set a certain output pin turns on when it is not required.(Code has been skipping) It seems that these problems happens especially when switching high inductance load such as solenoid of 12VDC, 24VDC and 230VAC through the relays. Currently for the above design I am using ULN2803A to sink 12VDC relays. Both the relays and PIC used the same 12VDC supply except the PIC through another 5V (7805)regulator. The DC voltage seems to be quite acceptable durring the switching but I am unable to study further as I don't have a storage scope. Any experiences or ideas on how to solve these interference problems? All suggestion and comments regarding these problems is appreciated Thanks! Have a nice weekend. Regards, Richard -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body