11
\$\begingroup\$

I have a microcontroller hooked up to a 5v supply which goes through a voltage regulator stepped down from 12v.

I'm assuming that it's rebooting because it's possible that the voltage drops quickly for a small fraction of time, which is enough to cause the chip to reboot.

Is this assumption correct?

Could adding a capacitor to the circuit solve this issue?

\$\endgroup\$
4
  • \$\begingroup\$ I'm a bit surprised that the vendor's application notes didn't specify a couple of capacitors already... \$\endgroup\$ Jan 2 '15 at 19:49
  • 3
    \$\begingroup\$ Sure, but the capacitance needed for reliable operation under typical load variations is quite a bit short of what is needed to operate through brief supply failures. \$\endgroup\$ Jan 2 '15 at 19:53
  • 2
    \$\begingroup\$ Does the chip work fine on a reliable 5V supply? It could also be the watchdog resetting the chip, are you sure it's correctly setup or disabled? \$\endgroup\$
    – user17592
    Jan 2 '15 at 20:04
  • 4
    \$\begingroup\$ Take an oscilloscope and look at the power supply voltage. Also look at the reset signal. This will give you more insight into your problem. The duration of the brownout (a dip or a downward spike in supply voltage) will help you size the capacitor, or to figure out what's causing the spike in the first place. If you catch the downward spike which causes the μC to reset, don't hesitate to post the screenshot here. \$\endgroup\$ Jan 2 '15 at 22:19
19
\$\begingroup\$

There are possibly two things going on here, short glitches (ns to µs) and much longer supply dropouts (ms to s).

You always need a bypass capacitor accross power and ground of a microcontroller. This keeps the local supply steady despite quite large very short term variations in the current the microcontroller is drawing. These variations are too fast for the power supply to regulate away. Also, the traces back to the supply have enough impedance at the high frequencies of these fast current variations to cause local voltage fluctuations even if the main supply was totally steady.

The other problem of longer term power supply dropouts has to be handled with significant energy storage somewhere. After all, insufficient power is coming in for some period of time, and the local storage has to make up the difference temporarily. The best place to put this is before the regulator. Let's say your regulator requires 2 V headroom. That means it will continue to produce 5 V out as long as its input doesn't drop below 7 V. That's 5 V less than the nominal 12 V in. A large enough cap on the input can hold up the input voltage of the regulator for some time after the 12 V input suddenly goes away. Put a Schottky diode in series with the 12 V input, then the cap afterwards. That prevents the input going low from discharging the cap.

For example, let's say you put a 1 mF cap on the input of the regulator (in addition of course to the small high frequency caps required for basic regulator operation as specified in the datasheet). Since you didn't say what your current is, we'll arbitrarily pick 100 mA in this example. Let's also say the Schottky diode drops 500 mV at full current.

The cap is then charged to 11.5 V during normal operation, and can drop to 7 V before the 5 V supply starts to drop. (4.5 V)(1 mF)/(100 mA) = 45 ms, which is how long the cap can keep things running after the 12 V input suddenly goes away.

\$\endgroup\$
1
  • \$\begingroup\$ If you're using higher supplies to power your MCU, then use a smaller capacitance. It will save resources when fabricated on an IC. Besides, look into the power supply. Modern voltage regulators (like LM723) almost never show this behaviour, and you should investigate your power supply circuit. Another reason for this behaviour is a short circuit somewhere. I cannot stress the importance of eliminating unintended shorts. \$\endgroup\$
    – xyz
    Jan 3 '15 at 13:20
9
\$\begingroup\$

If it's really power supply dropping, you'll do better with a capacitor in front of the voltage regulator (isolated with a diode, if necessary). That will allow the voltage to drop more before falling out of spec for the micro.

For example (picking numbers out of the air) suppose your micro needs 5V, your regulator supplies 4.75V and your micro is guaranteed to work at 4.5V. And further suppose you're feeding the regulator with 9V from a wall wart and the micro and other stuff draw 50mA. And suppose the regulator drops out at 1.5V.

If you put a 1000uF capacitor after the regulator, the time it will hold up the micro is:

t = 1000uF * (4.75V - 4.5V)/50mA = 5ms

If you put it before the regulator, the time it will hold up the micro is:

t = 1000uF * (9V - 6V)/50mA = 60ms (about 12x longer)

I kind of suspect that this may be an EMI issue causing disruption of the micro program unless you have a strong indication that the voltage is actually dropping.

\$\endgroup\$
3
\$\begingroup\$

It is mandatory to have ceramic capacitors close (~1cm) to the MCU supply pins. This is practically true for all integrated circuits.

But if you have doubts why the MCU resets, they usually have registers showing why a reset occured. Some MCUs have a brown-out circuit onboard and the trip point can even be set on some of them.

Which MCU do you use?

\$\endgroup\$
2
\$\begingroup\$

It is good practice to have some capacitance placed CLOSE to the power pins of the microcontroller. Typically a 1uF and a 0.1uF in parallel would do it. This is a general guideline though. It depends on how severe the voltage dip is (how much of a dip and for how long) that will tell you how much bulk capacitance.

In addition, for squelching conducted noise due to ESD, I would add a 470pF cap in parallel with the above.

That said, I would recommend you consult the datasheet for the microcontroller to see if there is a power fail bit that gets set in cases like this to see if it is a power failure at all.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.