Connect with us

Load on Power Relay Causing Microcontroller Reset

Discussion in 'Microcontrollers, Programming and IoT' started by sbrown, May 24, 2015.

Scroll to continue with content
  1. sbrown


    May 24, 2015
    I've created a circuit where a GPIO output of a microcontroller (PIC12F683) is used to turn on/off a darlington transistor (ULN2803A) which in turn turns on/off a power relay. I do not want to use two separate power supplies and the voltage requirements are the same so power to ICs and load is coming from the same source.

    When I have a load connected to the power relay (a Raspberry PI and powered USB hub), the microcontroller seems to be immediately resetting when the relay is turned on. My theory is that the initial power draw from the Raspberry PI and powered USB hub causes a temporary voltage drop and a reset of the microcontroller.

    The microcontroller only resets when I have a load attached to the relay. Switching on the relay without a load attached works fine.

    I'm using a 5V power supply rated for 5 amps. I think 5 amps should be plenty for normal running conditions, but maybe the initial power draw of the relay, Raspberry Pi, and USB hub is too much.

    Without adding a separate power source for the Raspberry Pi and USB hub, I'm thinking I might be able to add a capacity to eliminate the voltage drop to the ICs. I'm not sure if this would work though, where to put the capacitor, or what size capacitor to use. If I add a capacitor, I'm also wondering if I should add a diode to prevent the capacitor from being drained by power draw from the relay, Raspberry Pi and USB hub.

    Here's a picture of my circuit diagram:

    Any ideas or suggestions would be appreciated. Thanks!
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    Nov 17, 2011
    Welcome to electronicspoint.
    Obviously the current surge from turning on the load drops the voltage to the point of reset of the PIC.
    The best method would use separate 5V regulators for the PIC and the load, which could easily be achieved by using e.g. 7805 regulator ICs and a power supply at approx.8V.
    If you can't do this (or do not want to), you can buffer the 5V with am electrolytic capacitor to lessen the voltage drop. A rule of thumb is 1000µF per 1A of current.
    It is also good practice to decouple each and every IC with a local 10nF capacitor directly (or as near as possible) to the IC's pins - I dont see these in your schematic.
    Also tap the 5V that are switched by the relay as near a spossible to the power source (top left corner of your schematic) and not somewhere out of the middle of your circuit. That way the surge current will not take a path through your circuit, but come directly from the power source.
    Note that every length of wire has some resistance and inductance which will drop a voltage when current flows. Minimizing these voltage drops and their effect on the rest of the circuit should remedy your problems.

    If all fails and you still do not want to use separate voltage regulators, the second best solution involves two diodes with anode to the power supply and cathodes separately to PIc and relay contact. YOu will have to raise the voltage of the power supply from 5V to ~5.6V to get 5V to the loads (to compensate the voltage drop across the diodes). In this case, place the electrolytic capacitor on the cathode side of the diode to the IC. The surge current into the load will then affect the voltage to the PIC in a much smaller fashion.
  3. sbrown


    May 24, 2015
    Hi Harald,

    Thank you for the advice! I had a 100µF capacitor laying around so connected it between VDD of the PIC and ground and it works! It may not be the best solution but it was the easy option without making major changes to the circuit which I've already built.

    I don't have much experience and am not familiar with how to use a voltage regulator, but now that you've suggested it this is something I will look into.

    I do not have decoupling caps on the ICs. I'd not heard of this until I started researching my problem online today. In the future, this is something that I will incorporate into my designs.
  4. Colin Mitchell

    Colin Mitchell

    Aug 31, 2014
    Just add 100R to the PIC chip. It does not need 5v.
  5. Gryd3


    Jun 25, 2014
    Good to hear you are making progress.
    Voltage regulators are quite easy to use. To start, try looking in to the LM780X series of regulator.
    They have 3 pins. Input, Ground, Output. So you simply put a higher voltage in, and it will provide a stable voltage out. (These are 'linear' devices though, so they are not the most efficient, but they are incredibly simple. They will heat up with larger loads. When you understand a little of that, look into 'switch-mode' regulators.)
  6. BobK


    Jan 5, 2010
    The decoupling caps are essential on PICs. I am surprised you could even program them without one. You a 100nF as close as possible to each pair of Vss Vdd pins.

Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day