User avatar
Imperf3kt
Posts: 2775
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Brief voltage drop on UPS like system. would a capacitor fix it?

Tue May 29, 2018 1:46 am

This is somewhat related to several posts I've made recently, but doesn't particularly belong to any, so I've made what is hopefully the last thread I need about this subject.


I have my Raspberry Pi3B running from a Lithium Polymer battery which is regulated to 5.25v with an MP2636 Boost / charge module.
After a lot of fiddling and testing, I've managed to get this system stable all the way to ~75% CPU usage with no throttling no matter if I power via the battery or the vin which is fed from an official Raspberry Pi power supply.

Where I do have issues, is when plugging in an external power source to charge the battery, at the same time as using the Pi (or disconnecting it)
For a moment, the undervoltage indicator pops up then very shortly after, disappears.

To fix this, I've considered adding a capacitor that could pick up the slack in the split second it takes the boost circuit on the MP2636 to kick in / switch back to passthrough.

Would this help at all? And if so, would I put it in series with the 5v out from the MP2636, or bridge it across the 5v out and 0v?
I don't really understand capacitors well enough to work this out on my own.

Schematics for reference:
Image
55:55:44:44:4C
52:4C:52:42:41

MarkDH102
Posts: 346
Joined: Fri Feb 13, 2015 3:18 pm

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Tue May 29, 2018 6:16 am

I have a Pi0W that is powered from a mains adapter.
It has a speakerPHAT attached and also a relay card to switch 5V from the Pi to power on/off a WiiFit board.
I found that switching the relay to power the WiiFit caused a dip in the 5V that was sometimes large enough to cause the Pi to reboot.
I now have a 1000uF 16V strapped across the 5V and 0V pins of the Pi and have been running for a few months with no problems.

User avatar
Imperf3kt
Posts: 2775
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Tue May 29, 2018 7:52 am

Thanks!
So just to be sure, something like this:
Image

I'll see how it goes and maybe put a couple in parallel if its not enough.
55:55:44:44:4C
52:4C:52:42:41

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Tue May 29, 2018 8:39 am

Yes.

Your problem may be that the instantaneous current requirements of the processor under peak load is exceeding the ability of the regulator to react. Adding a smoothing capacitor to the supply lines provides localised energy storage that can supply brief periods of peak demand while the regulator catches up. The RPi already has localised energy storage (supply rail capacitors), but not much (because of the physical size of high-value capacitors).

However, your problem may be worse than this. If you are actually nearing the overall limit of the regulator, it may not be able to top up the capacitor before that supply of peak demand also runs out. Just throwing bigger and bigger capacitors at it isn't necessarily the answer, and having huge smoothing capacitors creates its own problem when starting up ("inrush current").

Try 1000uF, but if that doesn't fix it you need to look more closely at the specifications for the regulator, and also whether the connecting wires are thick enough and short enough. Put the capacitor as close to the RPi as you can make it, with as short a connection to the RPi as possible.

---

As a general comment: when I started getting interested in electronics, there were about a dozen different monthly magazines for the electronics hobbyist and/or professional. Now there is one. It seems to me people are being encouraged into electronics via coding (which is a good thing), but there is very little education going on except trial and error, and the blind leading the blind.

It is fundamental to successful electronics that you pay attention to specifications and understand how to apply them. "Suck it and see" may work, but (1) if it doesn't you've wasted money (and time) buying the wrong thing, (2) it may not be reliable, and (3) if you (or somebody else) tries to replicate the circuit, it may not work at all due to the component tolerances adding up the wrong way. This is contrary to coding, where all you waste is time and if it works at all it will work every time, anywhere.
Military and Automotive Electronics Design Engineer (retired)

For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!

User avatar
Imperf3kt
Posts: 2775
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Tue May 29, 2018 9:07 am

Yes don't worry. The regulator module is rated for 2.5A and the regulator chip itself is rated to 3A.

I am using very short 13AWG copper wires (<10cm) to connect everything, so I am absolutely sure the wiring is up to the task.

There is a switch in the circuit, but it is also high quality rated for more than 10Amps. Through all this, I see 5.23v at the GPIO.


I thank you for your input, it is the same conclusion I came to but was not sure how to wire it in.


The next task is working out how to monitor the battery voltage and shut down the Pi cleanly at ~2.9v but that is another topic.
55:55:44:44:4C
52:4C:52:42:41

User avatar
Imperf3kt
Posts: 2775
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Wed May 30, 2018 9:29 am

I soldered a 10v 1000uf electrolytic capacitor as depicted in the diagram and it made my situation worse.

I have a 5" screen attached and it flashes on and off. The Pi doesn't even attempt to boot.

I removed the capacitor and everything seems normal again. Did I use the wrong type of capacitor, or is it simply not 'filling up' enough?
55:55:44:44:4C
52:4C:52:42:41

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Wed May 30, 2018 9:40 am

This is the inrush current I was talking about. It overloads your regulator which then shuts down. The easiest option is to try a smaller capacitor.

You may have to accept that your chosen regulator is not up to the mark.
Military and Automotive Electronics Design Engineer (retired)

For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!

IanS
Posts: 234
Joined: Wed Jun 20, 2012 2:51 pm
Location: Southampton, England

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Wed May 30, 2018 9:53 am

Also check you have the capacitor the correct way around. Some capacitor types are polarised, some are not. Electrolytics, which are the only type you will get with this kind of size (i.e. 10uF or higher) at a sensible price, are polarised.

User avatar
Imperf3kt
Posts: 2775
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Wed May 30, 2018 10:13 am

Yeah, I have it correctly polarised.

I have a lot of 16v 470uf caps laying around, I'll try one of them tomorrow.


As to accepting the regulator is not up to the task, I know its on the limit, but so far this is the only regulator I have found that even comes close to properly powering the Pi. I can run some pretty intensive tasks and really load up the 5v rail without voltage drops, its just when I switch between charging and draining the battery.

If it doesn't work, I can just charge the battery with the unit off.
Thanks for your help so far!
55:55:44:44:4C
52:4C:52:42:41

Idahowalker
Posts: 445
Joined: Wed Jan 03, 2018 5:43 pm

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Wed May 30, 2018 12:47 pm

Also, consider the location of the capacitors connection to a supply voltage. If, when you apply the charge voltage the cap in on the non-voltage side of the switch, when the switch is thrown, the first thing to happen will be that the cap will charge and that will appear as a high current low voltage o/p from the cap. Such could be why things got worse with the addition of the cap.

Image
Without knowing why you are deleting my postings, I will not know how...

User avatar
Imperf3kt
Posts: 2775
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Wed May 30, 2018 2:17 pm

Yeah, I considered that, but if I put it on the other side of the switch, won't it allow leakage and help drain the battery faster than it already does (the regulator is permanently running the boost converter)
55:55:44:44:4C
52:4C:52:42:41

User avatar
Burngate
Posts: 6007
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Wed May 30, 2018 6:28 pm

How about putting a resistor in parallel with a schottky diode, in series with the capacitor?

On power-up, the cap charges through the resistor (the diode is reverse-biased) so does so slowly.

When power disappears momentarily, the cap supplies current through the diode.
screen,b60.png
screen,b60.png (16.38 KiB) Viewed 2658 times

MarkTF
Posts: 300
Joined: Tue Mar 03, 2015 4:59 pm

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Wed May 30, 2018 6:46 pm

Imperf3kt wrote:
Wed May 30, 2018 2:17 pm
Yeah, I considered that, but if I put it on the other side of the switch, won't it allow leakage and help drain the battery faster than it already does (the regulator is permanently running the boost converter)
Electrolytic capacitors do have some leakage current, but it typically is on the order of microAmperes. This should be insignificant relative to the RPi current draw unless the system sits for very long periods (weeks?) with the RPi powered off and with the charger inactive.

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Wed May 30, 2018 8:56 pm

Burngate wrote:
Wed May 30, 2018 6:28 pm
How about putting a resistor in parallel with a schottky diode, in series with the capacitor?

On power-up, the cap charges through the resistor (the diode is reverse-biased) so does so slowly.

When power disappears momentarily, the cap supplies current through the diode.
screen,b60.png
Professionally, I've never seen anything like that. I would call it clutching at straws.
Military and Automotive Electronics Design Engineer (retired)

For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!

User avatar
Imperf3kt
Posts: 2775
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Wed May 30, 2018 9:48 pm

For reference, here's a photo I took the other day (before I added the cap)
It might make it easier to envisage what I am doing / have done. Maybe someone can spot a potential issue.

Note that this is supposed to be temporary. Once it works as desired, I'll be transferring it to a much more compact PCB

Image
Sorry about the brightness, it was taken underneath a 2000lm light.

Some explanation
The blue wires are connected to the vcc and GND on the underside of the USB socket because I found the USB socket was limiting current (definitely not not the cable I was using)

The wires connecting the battery to the regulator are 18AWG

The switch, I pulled off a USB hub. The markings (which, admittedly, are for AC) specify it has a maximum rating of 3A@250v or 6A@125v
55:55:44:44:4C
52:4C:52:42:41

User avatar
Burngate
Posts: 6007
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Thu May 31, 2018 11:11 am

Z80 Refugee wrote:
Wed May 30, 2018 8:56 pm
Burngate wrote:
Wed May 30, 2018 6:28 pm
...
Professionally, I've never seen anything like that. I would call it clutching at straws.
In what way is it that?
You said:
Z80 Refugee wrote:
Wed May 30, 2018 9:40 am
This is the inrush current I was talking about. It overloads your regulator which then shuts down. The easiest option is to try a smaller capacitor.

You may have to accept that your chosen regulator is not up to the mark.
So the problem is that the charging current into a larger cap is greater than what the regulator can provide, but a smaller cap cannot provide the charge for the brief time that the regulator is off-line.

The voltage/current versus time isn't symmetrical - the cap doesn't need to charge quickly, but it does need to discharge quickly.
So control the charge time with a resistor, and allow the discharge to bypass that with a diode.

With 5.25v available from the regulator, and a minimum of 4.75v to avoid the lightning bolt, no more than 0.5v can be dropped across the diode -hence a schottky rather than a bog-standard one.
Imperf3kt wrote:
Wed May 30, 2018 9:48 pm
The switch, I pulled off a USB hub. The markings (which, admittedly, are for AC) specify it has a maximum rating of 3A@250v or 6A@125v
Unfortunately, a switch that's perfectly happy to switch 3A at 250v AC may not be good enough for 5v DC.

They're rated for AC because they only have to survive arcing over a hundred ms or so - try switching off DC with an inductive load!

But also, if the contacts have, say, 0.5Ω resistance, there'll be only a volt or so drop across it - nothing worth mentioning, at 230v.
At 5v, though, that's a considerable amount.

Still it'll probably be ok, until age and atmospheric polution oxidise the contact surfaces. And I don't know of a better switch!

User avatar
Imperf3kt
Posts: 2775
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Thu May 31, 2018 2:14 pm

Yeah, I understand AC ratings are different to DC (which is why I mentioned that bit of trivia), but I assumed it was alright as I had salvaged it from a 2A, 5v device. A few electronics resellers stock the same switches and list them as fine for DC use. Some local auto electrical superchains also stock switches rated the same for use in 12/24v DC systems. I know its guesswork, but I'm pretty confident the switch is adequate.

Across the entire wiring setup, I am seeing a 0.02v voltage drop (5.25v at the MP2636, 5.23v at the Pi) so there doesn't seem to be any worries there.

It turns out that I don't have any 470uf caps around... I did find some 100uf caps though, is this maybe getting too low?
I've never used diodes before (they're obviously polarised, I assume?) but I have a bunch of old electronics with many diodes I could salvage instead of buying new ones, at least, until I test if the setup functions as desired.


I really appreciate all the responses here, they help a lot.
55:55:44:44:4C
52:4C:52:42:41

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Thu May 31, 2018 3:00 pm

Burngate wrote:
Thu May 31, 2018 11:11 am
In what way is it that?
If you are aware of that circuit configuration actually being used in practice to combat supply voltage drops due to instantaneous demand, please refer me to an example. The circuit is suitable for maintaining a supply rail (at reduced voltage) temporarily to, for example, allow time for a controlled shut down, but the downstream electronics would have to be designed to accept the lower voltage. Also, a diode with decent current handling ability would take a significant time to switch from being reverse-biased to forward-biased.
Military and Automotive Electronics Design Engineer (retired)

For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Thu May 31, 2018 3:01 pm

Imperf3kt wrote:
Thu May 31, 2018 2:14 pm
I did find some 100uf caps though, is this maybe getting too low?
Try it and see - you never know. You could always fit several.
Military and Automotive Electronics Design Engineer (retired)

For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!

User avatar
Burngate
Posts: 6007
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Thu May 31, 2018 5:44 pm

So "professional" means "it's done in stuff you can buy", so if nobody's doing it, it must be "clutching at straws" -it must be dodgy, somehow.

Maybe you're right - maybe no "professional" - i.e. someone who gets paid, not necessarily someone who's good at his job - has used it in a commercial bit of kit.
Probably because they were able to improve what's feeding it so it wasn't necessary.
Here, we can't do that - we're stuck with the feed we're given, and this circuit does exactly what's required. "clutching at straws" is perjorative, to say the least.

Nobody had used a battery to back up an internal combustion engine, until somebody tried it, and now everybody's doing it (I exaggerate, but still ...)
Except for Tessla, who've ditched the engine.

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Fri Jun 01, 2018 9:37 am

I assume you mean your circuit has been shown to work in practice then. If so, I take it back. Some 'scope plots demonstrating its performance would be nice...
Military and Automotive Electronics Design Engineer (retired)

For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!

User avatar
Burngate
Posts: 6007
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Fri Jun 01, 2018 6:12 pm

You mean ... pratting around with odd components until it works is better than a bit of theory?

I don't think you mean that, at all.
You more-or-less describe yourself as professional, though what in area I don't know.
The answers you've given to other posts lead me to think you know what you're talking about.

So what have you against this?
What don't you like?
Do you think it won't work?

"Clutching at straws" is what a drowning man is reputed to do when there's nothing else around to grab hold of, not in the belief that it might save his life, but because he thinks anything is better than nothing - any deal is better than no deal.
But in fact drowning people don't do that - however many straws are in the water with them, they wave their arms around and scream their heads off.

So you accused me of grabbing at anything that shows a glimmer of hope, rather than working things out logically.
But I've explained the reasoning behind it and why it will work - not how it might work if I pray to the right gods, but how it will work.

I'm not going to persue this any more, because we're straying off topic.
Add me to your list of foes if you like.
Just stop traducing me.

User avatar
Imperf3kt
Posts: 2775
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Sat Jun 02, 2018 7:52 am

I know its only banter, but I consider you guys' discussion on this matter, as somewhat educational.
If the moderators are okay with it, I don't mind if you continue discussing the reasons for and against such a circuit design.

I would stress lets keep it civil though.
55:55:44:44:4C
52:4C:52:42:41

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Sat Jun 02, 2018 8:31 am

Yes, I'm a retired electronics design engineer with military, automotive, and high-reliability systems experience.

I stand to be corrected, but my vote is that the cap-res-diode circuit won't work. Even with a Schottky diode, the forward voltage will be about 0.3V (or more, unless the current is very low), and it will take time to turn on (even if it is faster than a normal diode). What does this mean?

OK, suppose the RPi is being operated at the extreme of 5.25V (which is not a good idea, the specification is 5.1V). The cap is charged to virtually 5.25V through the res. A sudden peak in current demand from the RPi causes the supply voltage to dip. It would have to dip to at least 4.95V before the cap could contribute any meaningful current, and if the rate of change was reasonably fast it would dynamically dip below that. Operating the RPi within spec at 5.1V reduces the best case to 4.8V.

I have a lab power supply and a 'scope, but I'm not in a position to prove it one way or the other because I can't easily set up a test circuit to match the OP's situation (brown-outs because of current limiting from the supply circuit, and intermittent supply start-up if significant capacitance is added). The easiest way to resolve this is for the OP to try it and see.

No, even if it works on the bench this would not come up to scratch in the professional environment. The design file needs to justify every aspect of the design before it is released for production. "Think this may work" or "happens to work when tested on the bench" doesn't cut the mustard. "Meets every aspect of the required performance parameters according to analysis of the published and guaranteed specifications of the components", or at the very minimum "works with a demonstrated safety margin when tested over the full range of environmental parameters, with multiple independent builds", is the required standard for design sign-off. Running the RPi at more than 5.1V alone would be sufficient to reject the design.

PS: If a unit fails to perform when delivered to the customer, the design engineer in in the frame. If it is then shown that the failure is due to some disregard of specifications - there will be consequences. Sometimes the published specifications are incorrect, or a batch of components does not meet its specifications, in which case the buck does not stop with the engineer.
Military and Automotive Electronics Design Engineer (retired)

For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!

User avatar
davidcoton
Posts: 4143
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: Brief voltage drop on UPS like system. would a capacitor fix it?

Sat Jun 02, 2018 10:17 am

Z80 Refugee wrote:
Sat Jun 02, 2018 8:31 am
I stand to be corrected, but my vote is that the cap-res-diode circuit won't work. Even with a Schottky diode, the forward voltage will be about 0.3V (or more, unless the current is very low), and it will take time to turn on (even if it is faster than a normal diode). What does this mean?

OK, suppose the RPi is being operated at the extreme of 5.25V (which is not a good idea, the specification is 5.1V). The cap is charged to virtually 5.25V through the res. A sudden peak in current demand from the RPi causes the supply voltage to dip. It would have to dip to at least 4.95V before the cap could contribute any meaningful current, and if the rate of change was reasonably fast it would dynamically dip below that. Operating the RPi within spec at 5.1V reduces the best case to 4.8V.
The specification for the Pi's supply voltage is (unless something changed) the same as the USB voltage spec -- 5V +/- 0.25V. That's at the Pi -- the voltage at the PSU may be higher as long as the voltage at the Pi doesn't rise too much off load. So a 0V3 drop across a diode is easily tolerable with the right supply. But the issue here is to find a simple one-off solution to a deficiency in the existing supply. The "professional" solution is to change or modify the supply -- but that is out of scope here. (NB 5V1 is the nominal output of the official supply.)

Note also that the low voltage threshold is nominally 4V65 (IIRC), so even with a 5V0 supply the circuit is not hopeless. If the supply voltage starts below that, issues may still arise. In this case a "perfect diode" as used in the 3B (not 3B+) protection circuit may be the solution, at the cost of higher component count and circuit complexity.

The circuit @Burngate gave has a good chance of solving the OP's particular problem, though it is not a cure-all for weak PSUs.
Signature retired

Return to “Advanced users”