Li-Ion charger for supercaps?

Discussion in 'Electronics & Electrics' started by Thalyn, Oct 6, 2019.

  1. Thalyn

    Thalyn Member

    Joined:
    Jun 2, 2005
    Messages:
    440
    I've been recently trying to set up something of a "last gasp" UPS for a Raspberry Pi to shut it down when I turn off my 3D Printer (thus killing the RPi's power as well). It doesn't need to last very long - maybe 30 seconds with minimal (500ma or less) load - which lead me to look into supercapacitors. Problem is, I'm having trouble figuring out the best way to rig them up. I've found ICs (like the LTC3226) which would suit the purpose exactly but they're fine-pitch surface mount chips, which is beyond my ability and facilities to use, and no-one seems to make a pre-built module using them.

    However, I have found that a pre-built HAT for an RPi exists for this exact purpose that uses a Li-Ion battery instead. And you can buy them without the battery. I'd use it with the battery but that seems superfluous, given it'll discharge itself mostly through the idle current of an "off" RPi, wasting power and needlessly wearing the battery. But if I were to put a pair of supercaps in place of the Li-Ion battery instead...?

    I know from things I've heard in the past that Li-Ion batteries are charged differently to NiCad or NiMH. I don't know if this difference would impact the ability of such a charger to work with supercaps instead. And if I search for it, all I'm finding are people asking if they can charge batteries from (super)capacitors - not exactly helpful.

    My alternative theory (at present) is to use a 5v boost converter from the caps, with either a mosfet to limit the charging current and stop them trying to charge themselves, or a transistor and set of resistors to achieve the same result (and hoping the voltage loss isn't a problem). The "kill" switch would be provided from an optocouple hooked to the 5v input line before any of the RPi's regulation circuitry.
     
  2. aXis

    aXis Member

    Joined:
    Jun 27, 2001
    Messages:
    5,330
    Location:
    Kalgoorlie, WA
    The easiest option for charging them is a small constant current/constant voltage DC-DC converter. You can get one that handles an amp or two few a few dollars on ebay. The (step-down) DC converter can be supplied from 5V and then charge a bank of parallel supercaps to 2.5V, limited to say 100mA to 1A charge rate. That might take a few minutes, but it doesn't really matter.

    On power-down, you'd then have a separate step-up converter supplying 5V from the supercaps You'll have to get a step-up converter that can handle low input voltages though, because the supercap voltage will fall exponentially, compared to a lithium being pretty flat. if you cant find a suitable step-up converter then possibly use a series bank bank of capacitors to get higher voltages, will likely need a combination step up/down converter for supplying the RPi as the voltages will swing from above 5V to below 5V.
     
  3. _zak

    _zak Member

    Joined:
    Oct 12, 2009
    Messages:
    350
    This is the issue I've always run into when looking to use supercaps - most readily available 5 V boost regulators drop out at around 1.8 V input, meaning that a lot of your supercap's charge won't be able to be used. Those that do go down lower than 1.8 V often have a limited ability to supply current below that value (this review indicates that a cheap step-up '0.9-5 V to 5 V' regulator could only supply 10 mA with a 1 V input).

    Having said that, if you use the suggestion from aXis above for charging, you could combine Adafruit's PowerBoost 1000 Basic with this 55 F supercap from Jaycar. Using this calculator indicates that you'd get about 75 seconds of runtime before the regulator drops out at 1.8 V input.
     
    Last edited: Oct 7, 2019
  4. aXis

    aXis Member

    Joined:
    Jun 27, 2001
    Messages:
    5,330
    Location:
    Kalgoorlie, WA
    Seems more likely that you'd need several supercaps in series. Charge them from 5V with a step-up CC/CV converter, and then power the RPi using a step up/down converter. Using three in series you could get down to 1V across each capacitor and still have reasonable input for the step up/down converter.

    Edit 1 - having trouble finding examples for step up/down (buck/boost) converters that go down to 3V. Most stop at 5V.

    Edit 2 - Here, but might want to check the chip used actually meets those specs.
     
    Last edited: Oct 7, 2019
  5. OP
    OP
    Thalyn

    Thalyn Member

    Joined:
    Jun 2, 2005
    Messages:
    440
    So, if I'm getting this correct... filling in a few blanks, the Li-Ion module idea won't work - not so much because it won't charge the caps (or risk damaging them, etc), but because it will cut out far too early based on the voltage expectations of a Li-Ion cell during discharge. So whether they're fully charged or not is basically irrelevant.

    Instead, it sounds like I'm better off sticking with the idea of running a boost converter off the caps. However, it might be worth looking into running 3 caps in series, instead of 2 in order to keep the input voltage high enough for the boost converter to actually work. This may or may not be further augmented by charging the caps in parallel, which would likely be better for their long-term stability anyway, before draining them in serial for higher voltage; though this seems to be a subject of some debate more on whether it's worthwhile, rather than how to actually do it (which is all too common online, it seems).

    And, unfortunately, it seems like I'm not alone in being unaware of any modules based on the actually-meant-to-do-this supercap run-through chips.
     
  6. aXis

    aXis Member

    Joined:
    Jun 27, 2001
    Messages:
    5,330
    Location:
    Kalgoorlie, WA
    I think this will be too difficult to switch between series/parallel configurations. Easiest to charge them in series too, using a step-up (boost) converter. You can buy cheap balancer modules for the supercaps to make sure that they don't individually exceed 2.5 or 2.7V.


    After all this, it may still be far simpler to have a small USB LiPo powerbank (or the equivalent modules that you can buy in kit form), and just make sure the RPi can detect when mains goes off and just shutdown.
     
    Last edited: Oct 7, 2019
  7. Privatteer

    Privatteer Member

    Joined:
    Mar 19, 2006
    Messages:
    814
    Why not tackle it from a different direction.
    Use the Pi to activate/deactivate the printer power via a relay.

    Second option is a timer relay on the power circuit. Press/switch off to activate. Sends signal to Pi to shut down, holds power for x time then shuts down everything.
     
  8. OP
    OP
    Thalyn

    Thalyn Member

    Joined:
    Jun 2, 2005
    Messages:
    440
    If it seems like I'm paraphrasing or over-interpreting things, I probably am. I'm more a "solder monkey" than an electrical engineer - I can work a soldering iron plenty good enough, but I only have a fairly fundamental understanding of electronics.

    So effectively I'd boost the voltage from 5v up to whatever I plan on using - such as 7.5v for 3 caps in series - and then buck it down to 5v to power the unit. Use a balancer, as either a module or zener/diode divider, to keep everything in check, since 3 caps is more likely to encounter problems than 2.

    If I were to go the LiPo method, it'd probably be easier to just get a pre-built LiPo HAT and use it as normal, rather than my original musings of attempting to outfit it with supercaps instead. But this seems like it's really not an ideal application for a battery with such a limited recycle life, which is why I'm looking into this alternative in the first place. Plus, what's the fun in using something that already exists exactly as it was designed? Yes, if I found something based on a suitable supercap chip I was planning on doing exactly that, but it seems such a beast doesn't exist.

    As it stands, the Pi and printer are both currently powered from the same PSU - just that the printer is feeding directly off 12v while the Pi has a 5v buck in the middle. As such, when I switch it off (either at the wall or when I eventually mount a switch on the PSU itself) the Pi will also immediately lose power. I don't really have any interest in changing this, since I don't have any use for the Pi other than the printer.

    The timer is an interesting idea, though. I'd have to over-allow for those times you know it's going to take longer than usual to shut down, but a 60-second delay should cover just about every situation. Hmmm...
     
  9. aXis

    aXis Member

    Joined:
    Jun 27, 2001
    Messages:
    5,330
    Location:
    Kalgoorlie, WA
    Yeah close, but on the discharge side I'd go for a buck/boost converter as it will transition from 7.5V to below 5V very quickly. You'll need the boost portion to be able to get longer runtimes (or increase to more capacitors in series)

    In fact, it might be better to run the system with 5 supercaps in series, charged from your 12V supply. You can then have the existing 5V buck converter fed by either the 12V supply or the supercaps. A few strategic schottky diodes to stop things back-feeding and you'd be OK.
     
  10. mtma

    mtma Member

    Joined:
    Aug 12, 2009
    Messages:
    4,938
    FWIW:

    The Pi supposedly can run from 3.3V, and most likely you will find that it's mostly operable all the way down to 2.7V because most of the peripherals on board seem to be the typical 3V3 or 5V nominal rail design. Obviously if you have USB devices they may not be as tolerant.

    Due to the V squared term in the capacitor energy equation 5V to 2.7 is about 70 percent of the total energy available.

    IOW, if you wanted to go real simple with two series super-caps with bleeders, you could keep them filled via a resistor and use a diode (the pseudo ideal kind on the pi being the most favourable, otherwise a good low Vf schottky to hold up the 5V input.)

    Ideally you want to disconnect the USB devices that don't need to be using the supercap if possible - that would be more fiddling around of course.
     
  11. aXis

    aXis Member

    Joined:
    Jun 27, 2001
    Messages:
    5,330
    Location:
    Kalgoorlie, WA
    And yet, the experience from many people using a PI is that it's very sensitive to voltage, to the extent it's better using a 5.2V supply than a 5V one. Maybe if you supply the SOC directly with regulated 3.3V, but not via the 5V input.
     
  12. aXis

    aXis Member

    Joined:
    Jun 27, 2001
    Messages:
    5,330
    Location:
    Kalgoorlie, WA
    I've knocked up a basic example:

    Click to view full size!


    Notes
    - all of the diodes are low loss schottky diodes, about 0.2V forward drop.
    - the LM317 regulator was just a stand-in. Use a proper DC-DC converter.


    This has the main 12V supply branching off to feed either the 5V DC-DC converter, or the capacitor storage system.

    In the capacitor storage,
    - There is an initial diode to prevent it back-feeding the 12V when it goes off.
    - Next is a 12V incandescent lamp (eg a bare G4 halogen bulb like this) as a cheap form of current limiting. Size it to reduce the inrush, 5W or less should be OK.
    - The set of 5 capacitors are connected in series.
    - Parallel with each capacitor is a resistor to make sure they all stay balanced. 10k might also work with lower losses
    - An output diode connects to the DC converter

    Also, there is a voltage divider connected to the 12V supply. The tap in this divider should then go to a spare digital input on the RPi. When the power supply goes off, you can detect this pin going low and then trigger emergency shutdown.
     
    Last edited: Oct 8, 2019
  13. callan

    callan Member

    Joined:
    Aug 16, 2001
    Messages:
    4,808
    Location:
    melbourne
    Capacitors in series is a stupid idea. you'll add to voltage but waste any additional capacity you might get (total charge will be the same no matter how many capacitors are in series.)
    I don't have a useful answer for the OP but series capacitors is not it.

    Callan
     
  14. Privatteer

    Privatteer Member

    Joined:
    Mar 19, 2006
    Messages:
    814
    Something along a 2 contact switch then and a delay off timer controlling the PSU would be my suggestion as a simple solution.
    1 contact to signal the pc on open or close to shutdown.
    2nd contact cuts the power to timer, and 60 secs latter it can turn off/unlatch the psu power.

    If you want a momentary push button some timers will work on a pulse input to trigger.
     
  15. aXis

    aXis Member

    Joined:
    Jun 27, 2001
    Messages:
    5,330
    Location:
    Kalgoorlie, WA
    There was a reason I called the circuit "basic".

    The design is not intended to give extra charge, it's there to put the working voltage into a more usable and efficient range. It also saves the cost & complexity of extra DC-DC converters.
     
    Last edited: Oct 9, 2019
  16. dakiller

    dakiller (Oscillating & Impeding)

    Joined:
    Jun 27, 2001
    Messages:
    7,911
    Location:
    Gippsland
    If you do the maths, the energy stored by putting capacitors in series and and increasing the total voltage by the number of capacitors, or by paralleling capacitor at the same voltage, come out the same.

    Seeing supercaps don't come in high voltage values and it is hard to deal with the bottom end of the discharge curve, the series option will work out better here.

    My thoughts are that this is a terribly complicated solution. I would either make the Pi control power to the printer via a soft switch, or harden the Pi to not care about having the power yanked on it.
     
  17. aXis

    aXis Member

    Joined:
    Jun 27, 2001
    Messages:
    5,330
    Location:
    Kalgoorlie, WA
    Doing some a rough iterative math, if you have to support a 5W load across the two different capacitor configurations:

    1) 5 x 10F in parallel for 50F total. Starting 2.5V, ending 1.8V which is the DC converter cutoff - 15.1 seconds runtime
    2) 5 x 10F in series for 2F total. Starting 12V, ending 6V which would be the cutoff for a plain buck converter = 21.7 seconds runtime. You could wring out a bit more with a buck/boost.

    A modest improvement in runtime using the series config just due to usable voltages.
     
  18. OP
    OP
    Thalyn

    Thalyn Member

    Joined:
    Jun 2, 2005
    Messages:
    440
    Good catch. Can probably just use buck/boost the whole way - it'd be superfluous for charging, but if I buy a handful of them I can more easily find a use for the others later if they go both ways.

    Part of me was wondering just how far I can push that. Because I'm strictly using this as a "last gasp" GPS to shut it down, so long as the SD card, SoC, and RAM are functional than the rest of the board can just shut down entirely for all it matters. I know from experience with a Pi2 that the wired LAN will drop out almost immediately (I've seen it drop at 4.9v) but that's irrelevant.

    In terms of hardware, it already doesn't care. Sometimes cheaper SD cards apparently have issues, but I'm using a SanDisc so it should be safe. Unfortunately, Raspian is a Linux-based system, which means file handles. And Linux file handles don't like to be left open.
     
  19. aXis

    aXis Member

    Joined:
    Jun 27, 2001
    Messages:
    5,330
    Location:
    Kalgoorlie, WA
    If you're using the appropriate file system structure, the SD card bases OS's can copy files into and run from temporary ramdisks. I know there's not a lot of spare RAM, but it prevents the issues with open handles as those are only ever in the tempfs ram disks.

    You might lose log files etc, if that's not important then dont stress.
     
  20. mtma

    mtma Member

    Joined:
    Aug 12, 2009
    Messages:
    4,938
    Might be a point to run some io inspection tools on the distribution that you're using to see what it actually does with its SD card. I have an suspicion that aside from copying STL's to storage, Octoprint caches most of the important stuff on RAM. Not sure if the camera functions are run out of RAM too though.

    Obviously if you are trying to do a Prusa-style restart-able print function it might be a different story.
    Probably as axis says, there's something at play in the design that causes the Pi to not like that in certain circumstances, like the inbound converter not having good PSRR against 5V transients or something else that cross couples disturbances to the SoC. I haven't tried it personally though.
     

Share This Page

Advertisement: