6

I have faced this problem many times that I connects Relay with pic microcontroller and whenever I put Load on Relay's Contacts PIC16f877a resets. I some time solve this problem by triggering another relay from basic relay attached to PIC. But this is not a solution. Can any one describes Why pic is affected with this relay spark. And what is really happening which causes pic to reset. Following things I have kept in mind while building circuit

  • I have 1K Pullup resistor on pin 1 (Reset pin) of Pic 16f877a
  • Fuses are, Power up timer = enable, Brown out detect = enable, LVP= disable, CP=enable
  • Power supply is filtered, ceramic capacitor of value .1uf connect across both ends of regulator
  • Crystal is 4MHz, and 33pf capacitor across crystal are close to (Circuit works fine, problem of reset occurs only when relay turns on with Load connected)
  • Relay is used of 12v/5amp ratings
  • C945 NPN Transistor is used to drive the relay
  • Reverse biase 1N4148 diode is connected across relay coil to save reverse leakeage

I never faces such problem in Atmel 89c51 microcontroller with same relay interfacing circuit. It is PIC who goes reset every time. But if do not connect any load to relay the circuit works fine. No reset occurs. Can any-one describes what is the issue with PIC?

Here is schematic, Crystal is attached as mentioned above enter image description here

Abdul Rehman
  • 411
  • 1
  • 5
  • 15
  • 3
  • A schematic helps visualize what has been implemented, far better than a series of textual bullet points. 2. Replace the 1n4148 with a Schottky barrier diode like the 1n5819. 3. Try putting a capacitor (try 10 uF) across the diode.
  • – Anindo Ghosh Mar 12 '13 at 11:08
  • 1
    I have had this problem before. It was because of the collapsing on the power supply. Put a 10 uF capacitor on the Vdd power rail, and most probably your problem will be solved. Also, to avoid SR latch-up, as @Kaz noted, Microchip suggest an RCR network. Look for this information in the datasheet of your microcontroller. – abdullah kahraman Mar 12 '13 at 11:23
  • Grounding: does your load's return current share paths with your small signal digital world? – Kaz Mar 12 '13 at 11:50
  • @Kaz... well, Load is 220V, thus definitely separate AC power source is given. Line from Relay and neutral directly to AC inductive load. With 2 Amp current Load. I added diode for reverse leakage prevention. – Abdul Rehman Mar 12 '13 at 11:59
  • @abdullahkahraman...... yes 10uf capacitor reduces the amount of rapid reset. Thanks. Pic reset is very common problem i faced. I really want to know any technical details why it is happening. As if i built same interfacing circuitry with ATmel 89c51 every thing goes fine. I am really surprised why PIC have problem? – Abdul Rehman Mar 12 '13 at 12:06
  • @anindoGosh I am going to try schottky barrier, but some how i did not understand the logic of schottky here? Will you please explain a lit. As schottky is costly comparatively and Later I am want to attach 20 relays. I am sorry if this question looks silly. – Abdul Rehman Mar 12 '13 at 12:09
  • 1
    @AbdulRehman Try increasing the capacitor to 100uF. For the replacement on 1N4148, search for "Flyback diode". About grounding.. Every cable/trace has a resistance, but very small. However, with sufficient current, there can be a voltage drop. This means the ground will be at a higher potential than 0 volts. – abdullah kahraman Mar 12 '13 at 12:41
  • 1
    @AbdulRehman While several excellent inputs have been provided already, hence my prior comment may be irrelevant, my suggestion for a Schottky comes from trying to alleviate flyback pulses from the relay coil at the source. Typical flyback energy can require 1 to several amps of pulse current capability in the diode, 4148 doesn't manage that. Also, the lower the diode voltage, the earlier in the pulse the bypass begins. Finally, between the Schottky and the capacitor, the impulse absorption would be more robust. A flyback diode as others suggested is really what you need there. – Anindo Ghosh Mar 12 '13 at 16:37