2
\$\begingroup\$

I'm trying to create a power source switch using a relay. This's supposedly will be used for my Raspberry Pi. So what I want to do here is :

  • Create a backup power source with battery that will replace the main power if it's failed/off
  • Add a capacitor to holds charge, so when the relay is switching, the power will not completely cut off

Here's my schematic:

my schematic

I already tried to create this, but the problem is when the main power is cut off, the output still drops and then backs up to 5V. So I've assumed the capacitor is not doing its job.

But strangely, if I cut both of the power, the output still shows 5V (and slowly going down), so this means the capacitor actually holds a charge, right? Then why when the relay switching, the power still temporary went down? Do I did this incorrectly?

\$\endgroup\$
5
  • \$\begingroup\$ test it with a manual switch ... the voltage drop may be related to the relay coil \$\endgroup\$
    – jsotola
    Jun 3 '20 at 3:36
  • \$\begingroup\$ Datasheet for the relay? Wonder what is the coil release voltage. Also if the RPi is drawing around 2000-2500mA as many configurations do, do the relay contacts switch fast enough before the capacitor voltage drops too far? \$\endgroup\$
    – MarkU
    Jun 3 '20 at 3:36
  • \$\begingroup\$ @jsotola sadly, it's still the same behaviour even with manual switch. \$\endgroup\$
    – Kamp
    Jun 3 '20 at 4:15
  • \$\begingroup\$ @MarkU the only datasheet I've found about the relay is the coil using 5V, max DC 30V 10A. I'm using RPi 2B which is low power, and only use it for kind of a media server. If i'm not mistaken, the last time I checked, it only consumed about ~1000mA (I'm using SSD instead of HDD). \$\endgroup\$
    – Kamp
    Jun 3 '20 at 4:15
  • \$\begingroup\$ Solved this by adding a low voltage drop diode to the relay "output". I forgot the relay can be powered the capacitor instead. Thanks to everyone for the input. \$\endgroup\$
    – Kamp
    Jun 3 '20 at 6:19
1
\$\begingroup\$

The cause of the problem could be the relay's switching characteristics.

The 'pull-in' voltage of a relay would be closer to its nominal voltage whereas its 'drop-out' voltage would be much lower.

After occurrence of a power failure, the relay's 'drop-out' characteristic would ensure that it stays on in spite of the decaying power supply voltage.

Hence the capacitor would also get discharged before switch-over to the battery could occur.

Here's an alternative scheme using a Schottky diode for switching.

enter image description here

The PSU would predominate, with it's voltage set marginally higher. In any case the probability of the PSU voltage exceeding that of the battery is quite high.

With availability of Schottky diodes having a forward voltage as low as 150mV, voltage drop during backup should not be an issue.

\$\endgroup\$
7
  • \$\begingroup\$ Do you mean that the capacitor actually trying to power up the relay when the main power is off? It kinda makes sense now. It there a way to make sure the capacitor only go to the output part, instead of go "backward"? A diode maybe? \$\endgroup\$
    – Kamp
    Jun 3 '20 at 4:40
  • \$\begingroup\$ Yes, Kamp. Instead of using a diode to prevent that, a better alternative would be to use the diode itself to do the switching instead of the relay. \$\endgroup\$
    – vu2nan
    Jun 3 '20 at 5:03
  • \$\begingroup\$ That setup is good, but not actually what I'm looking for, as it activated the battery along with the main power. But I definitely gonna need that Schottky diode. \$\endgroup\$
    – Kamp
    Jun 3 '20 at 6:12
  • \$\begingroup\$ Hi Kamp, With the PSU voltage being marginally higher, the diode would be reverse biased and would not allow battery current unless the PSU is switched off. \$\endgroup\$
    – vu2nan
    Jun 3 '20 at 6:26
  • \$\begingroup\$ I see. I'll try this one too. Thank you. \$\endgroup\$
    – Kamp
    Jun 3 '20 at 6:53
1
\$\begingroup\$

There are standard chips to do what you want, they're called ideal diodes: https://www.analog.com/en/products/ltc4413.html#product-overview

I suspect that one of these is way cheaper than that relay by itself.

enter image description here

As to why the relay doesn't work, it's simply too slow. At 2A, that capacitor should drop almost a volt per millisecond (I = C dv/dt). Most relays won't make contact before 10mS so you've got quite a bit of time where the relay has disengaged from one power source but hasn't engaged the other yet.

You might find something called a "make-before-break" relay that can mitigate this, but you will short the two power systems together briefly with one of those.

\$\endgroup\$
1
  • \$\begingroup\$ Sadly this is not sold in my place, at least not on online shop in my country. I'll keep this on a memo, if I somehow found this. \$\endgroup\$
    – Kamp
    Jun 3 '20 at 6:12
0
\$\begingroup\$

What voltage is your battery actually (when disconnected)? Or what chemistry & configuration of cells. A battery will not be 5.0V all the time. The voltage will vary by state of charge. Does your diagram represent "battery" as a combination of battery and 5V regulator?

If the battery is not actually 5.0V (for example, 4.8V), it will be an additional load on the capacitor at first. The capacitor charges the battery slightly, until the voltages equalize. Then the capacitor voltage should stay at the battery voltage ongoing, which would decrease slowly as the battery discharges. In this case the capacitor voltage would not reach 5.0V as it can only get as high as the battery voltage.

This setup is not so great because the capacitor will wear out faster with repeated inrush/outrush current way above spec. Capacitor current on switchover is limited only by power supply current capacity, battery internal resistance, copper trace resistance, etc. Try adding a small-value power resistor (say 0.1 ohm) between the relay and capacitor, to limit inrush current to the capacitor. You can monitor current through the resistor by the voltage across it (on oscilloscope). Should tell you something about how current is flowing in the circuit as the relay switches.

\$\endgroup\$
2
  • \$\begingroup\$ The battery is actually a power bank, it's always around 5V to 5.1V. But I've already tried using a charger instead for testing. So I guessed, the reason the power went down for a moment when the power switched, is because the capacitor trying to charge the battery instead of powering the output? Is there a way to prevent the capacitor doing this? \$\endgroup\$
    – Kamp
    Jun 3 '20 at 4:24
  • \$\begingroup\$ If the 'battery' is a power bank, between the actual battery (cells) and 5.0V output there will be a DC-DC voltage regulator and probably protection circuitry to prevent current flowing backwards into the voltage regulator. Some power banks have separate input to recharge the battery 'from' USB (port 1) and output to supply 5V 'to' USB (port 2). If there is only one USB port on the power bank, permitting charge and discharge on the same port, there would need to be circuitry inside to determine and switch which direction current should flow. \$\endgroup\$
    – Matt B.
    Jun 10 '20 at 19:29

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.