(yet another) Power Bank Stay-On Circuit - Page 1
Forum section: electronics / projects

author: DrG
author_rank: Super Contributor
timestamp: February 26, 2021, 11:22:30 pm
content: I was reading this threadhttps://www.eevblog.com/forum/projects/power-bank-issues/msg3474652/#msg3474652and it reveals the problem with using some of these power banks, thinking that they are only batteries. They decide to turn off if there is not enough current being drawn. A while ago, I bought a Jackery Giant+ - 12000 mAh and, although it does charge a phone, it is useless for powering small circuits…just like the thread talked about.There was even a link to some newer packs with “Always On” technology…some interesting videos and so on. Consequently, I got the idea to build one for my pack and searched around. Many use a 555 type IC circuit which put me off a bit, not that there’s anything wrong with thatHere is a pretty nice one and I like the micro approachhttps://blog.zakkemble.net/smart-power-bank-keep-alive/So, I thought I would try my hand at designing/programming/building one. Here is what I came up with so far, and, it works! I used what I had and what I knew how to do and what I could figure out.Simple schematic (EDIT:Corrected):Simple program:Code:/** -> USE AT YOUR OWN RISK <-** File: main.c* Author: DrG** Created on February 26, 2021, 12:06 PM* MPLAB X IDE v5.40* XC8 2.31* DFP 1.4.56* NOTE: Make sure that the backup reset condition flags option* is selected under MPLAB X Project Properties > XC8 Linker > Runtime* GP1 Current load* GP2 on LED*/#include <xc.h>#define _XTAL_FREQ 4000000// These values worked for my Jackery#define WDTcounts 12 //~2.3 sec / count#define PULSETIME 150 // load presentation time (msec)#pragma config MCLRE = OFF, CP = OFF, WDTE = ON__persistent uint8_t counter;void main(void) {// these are needed for any resetsOPTION=0b11011111;TRIS = 0b111001; // configure GP1 and GP2 as outputsif( (__powerdown==1) && (__timeout==1) ){// POR resetGPIO = 0b000110; // GP1 and GP2 on__delay_ms(1000);GPIO = 0b000000;counter=0;}else{// it is a WDT resetcounter+=1;if(counter==WDTcounts){GPIO=0b000110; // GP1 and GP2 on__delay_ms(PULSETIME);GPIO=0b000000; // LEDs offcounter=0;}}SLEEP();}By using the “lowly” PIC10F202, it is very easy to change the program parameters.Normally, I would have programmed the 202 using asm. With MPASM going away, however, I felt like I either had to go to their new asm or try it in C. I chose the latter....C in that tiny space, heh - turns out that there is plenty of space to spare.While it is a very simple program, I was completely unaware of how you get to the status register bits in XC8 and spent longer than I would like to admit proving that, indeed, XC8 has startup code (also present on any reset/restart) that smashes the status bits.I was also completely unaware that XC8 allows a persistent variable type that will keep its value across a WDT reset from sleep. I might actually have been able to deliver enough current for the battery to stay on using just the three output ports on the PIC, but I decide that the 4401 would be a good idea in case I wanted/needed to increase the load for other batteries. I also did not know for sure how much current would be needed for this pack to stay on.I have mclr disabled - so, POR, and WDT during sleep was all I needed to consider. The only other reset would, potentially, be from some kind of spurious pin change during sleep, but I would handle it as I would a WDT reset, so I am not even looking for it in code.I tried to be systematic about figuring out the interval between no load and when it shuts down – hand timing it at first and then backing off the value for the WDT time out counts. So, hand timing and watching a meter, showed a shutdown at ~30 sec. Using the maximum WDT prescaler yields ~2.3 sec to time out. Thus, I decided on counting 12 WDT resets or ~27.6 sec before turning on the "load".I also tried to be systematic about deciding on the duration of the load pulse. I ended up with 150 msec, which is longer than I would have thought, but at 100 msec, it showed inconsistent results.It does what I wanted it to do, but now comes the hard part (for me)…getting it off of a breadboard and into an enclosure. I have lots of projects still sitting on breadboards…some of them even work

author: Peabody
author_rank: Super Contributor
timestamp: February 27, 2021, 04:49:40 am
content: That looks pretty good to me. I just wonder if there might be a way to put the circuit inside the powerbank so you wouldn't have to mess with the connectors. Of course then you would need an on/off switch for it.I'd like to ask a question about the Zak Kemble circuit you found. He has an opamp driving the gate of a P-channel mosfet as the load. But this kinda violates everything I know about high and low side switching. It seems it should be an N-channel mosfet. With the P-channel, as the opamp turns it on, the source voltage would drop, which would turn it back off again. But I've always been impressed with Zak's work, and he's selling the device on Tindie, so I assume it works. But how? Does the P-channel provide a kind of negative feedback for the opamp?

author: DrG
author_rank: Super Contributor
timestamp: February 27, 2021, 05:20:42 pm
content: Quote from: Peabody on February 27, 2021, 04:49:40 amSince anything I make is a "prototype"I am likely to just slap it on a perfboard and try not to solder my fingers together....maybe I will add a couple of pieces of plexiglas or invest in some shrink wrap tape or some other fakakta method. But, I only need one and this one does what I want, so it is a success in my book....and that's always fun.Yeah, it would be nice to fit it into the power bank in this video (he uses a 555 type circuit) he did that (although not much in the way of seeing it inside there.I don't know enough about that aspect of Kemble's circuit, I am ok admitting that...I might be able to figure it out, but only after many hours. I have only used mosfets in 'very safe' and simple switches. His circuit is nice in that he is using a pot input to the 601 to control current. I'm sure that there are others around who could weigh in: toward that end, here is the schematic (fromhttps://blog.zakkemble.net/smart-power-bank-keep-alive/):

author: Peabody
author_rank: Super Contributor
timestamp: February 27, 2021, 11:04:00 pm
content: I posted a question on his blog, and got this response:"The circuit is a typical constant current source, but without an output load which then makes the MOSFET the load, dissipating all of the power. The load would normally sit between drain and ground."I guess to me it's a constant (or adjustable) current sink, which would call for an N-channel mosfet. But it may be that his design makes the pot adjustment a lot less touchy. If I have time I'll breadboard it and see how it behaves.

author: wizard69
author_rank: Super Contributor
timestamp: February 28, 2021, 12:53:06 am
content: funny how I came across these keep awake circuits this week. In any event if the power bank is to be used to power your own circuits, would it not make sense to integrate the keep awake tech into your custom project? It is one thing if the circuit is to be used to power a cell phone or other closed device, but if you are building a project that will use a power bank it would seem to me that the project should take care of its power needs. It would save the stress of finding the cable or modifying the pack.In any event throwing a microprocessor at this, with the simple circuit you have, sets an example.

author: DrG
author_rank: Super Contributor
timestamp: February 28, 2021, 04:01:02 am
content: Quote from: wizard69 on February 28, 2021, 12:53:06 amYeah, I think that would make sense in certain situations - in fact, I think that is what the OP in the thread that I initially cited was looking to do....if he couldn't get a power pack that wouldn't shut down.

author: wizard69
author_rank: Super Contributor
timestamp: February 28, 2021, 03:43:28 pm
content: Quote from: DrG on February 28, 2021, 04:01:02 amI literally just purchased one of these power banks a couple of weeks ago. In part to have a standby charging solution but also to be a power source for projects. it was so cheap I was originally considering disassembly to get the batteries. Then this week I started to see these keep awake circuits all over the place and it strikes me that I should just keep it as is.

author: DrG
author_rank: Super Contributor
timestamp: February 28, 2021, 09:16:35 pm
content: Quote from: wizard69 on February 28, 2021, 03:43:28 pmHaving already decided that I am going to stick the circuit on perfboard, I am trying to decide how I want this thing to look. I have only these power banks.I have two of the real small ones, and I have not even tested them for shut down. I have used them though. The other two, including the Jackery that gave rise to the project, definitely shuts down.The perfboarded circuit will be primarily for use with the Jackery. But, now I am not even certain I want to stick a second USB connector on it. Why not just put a two terminal screw connector on it instead of an 'out' USB connector since I will be using it as a "no shut down" PS? Why not put both? Do I add a switch to remove it from the circuit? Why bother since I can just unplug it from the Jackery?I suppose that it will also work for the other power pack as well, but likely not optimally.In fact, in a pinch, you can always just stick a resistor in parallel with +/- to prevent shut down - at the cost, of course of increased battery drain well in excess of the 'stay on' circuit.Geez, all these decisions, I better go take a nap

author: Zero999
author_rank: Super Contributor
timestamp: March 01, 2021, 11:52:49 am
content: I doubt a constant current circuit is necessary.How much current is required to keep it awake? You could probably skip the BJT, connect 150R to GP0 & GP1 and 0V and pulse them both. Even if the current is over the maximum rating, the duty cycle is so low, it won't do any damage.

author: DrG
author_rank: Super Contributor
timestamp: March 05, 2021, 07:29:37 pm
content: To complete the thread/project:I slapped the circuit onto perfboard.It will get use, likely just as a battery PS for a breadboard.The Inland pack required a 400 ms pulse time (longer than the Jackery), but the time to shutoff was also longer at ~40" (worked with a 16 WDT count =~ 36.8"). For practicality of efficiency, I programmed the PIC with "common denominator values" so it works with both. Of course, I could program two chips and so on - lots of flexibility. Anyways, it works.

author: SilverSolder
author_rank: Super Contributor
timestamp: March 05, 2021, 07:49:27 pm
content: Is there no way to open the pack up and mod its infernals?For example, come up with a tiny PCB that manages charging/protection that could be grafted into any power bank to make it "constant power on"... and maybe give it other cool features too, e.g. coulomb counting state-of-charge indication, remote control, programmable current limit, etc. etc. etc.

author: ElectricPower
author_rank: Frequent Contributor
timestamp: October 18, 2021, 04:12:08 am
content: Old topic i know, but i copied chematic on the video over from Carlsons Lab and made my own circuit on breadboard and it worked perfectly.I have also designed a PCB for that.

author: Peabody
author_rank: Super Contributor
timestamp: October 18, 2021, 03:19:24 pm
content: Thanks for posting this. I would just suggest that you add the processor's part number to the schematic. I assume it's an ATTiny85, but it doesn't actually say.

author: ElectricPower
author_rank: Frequent Contributor
timestamp: October 18, 2021, 03:20:33 pm
content: Quote from: Peabody on October 18, 2021, 03:19:24 pmNo, that is an 555 timer.Same chematic that Carslons Lab video over shows. But he uses an another timer i think is better regards to power usage. And i use an mosfet, not an BC817 transistor.

author: Peabody
author_rank: Super Contributor
timestamp: October 18, 2021, 04:16:36 pm
content: I guess I glanced too quickly since it's obvious what it is. Sorry.

author: ElectricPower
author_rank: Frequent Contributor
timestamp: October 18, 2021, 10:12:49 pm
content: Quote from: Peabody on October 18, 2021, 04:16:36 pmNo problem

author: ElectricPower
author_rank: Frequent Contributor
timestamp: October 18, 2021, 11:55:27 pm
content: Quote from: ElectricPower on October 18, 2021, 04:12:08 amI have one question for this circuit...I have changed the BC337 transistor with an IRLML2502 logic level n-channel mosfet as seen in chematic over. Is it still ok to use 4.7K resistor to the gate? And do i need to pull the gate to ground with an 10k?

author: ElectricPower
author_rank: Frequent Contributor
timestamp: October 19, 2021, 04:15:24 am
content: Made som changes to my board layout. I placed components on booth sides and created the board smaller.The physical size on the board is now 27 x 14mm.

author: Peabody
author_rank: Super Contributor
timestamp: October 19, 2021, 02:26:09 pm
content: About your question on the gate resistor - a much lower value would be more typical for a mosfet gate resistor. Something like 100 ohms. That would allow faster switching time and reduce dissipation in the mosfet. For this purpose, I'm not sure it matters much, but it it were my decision I think I would use a lower value.I don't think a pulldown resistor is needed. The timer output is always active if there is power, so the gate is not going to float.

author: ElectricPower
author_rank: Frequent Contributor
timestamp: October 19, 2021, 03:33:14 pm
content: Btw. I see now that i have connectet the mosfet wrong. Drain is connectet to ground. It should be source to the ground....I will change that and post new chematic soon.

author: ElectricPower
author_rank: Frequent Contributor
timestamp: December 06, 2021, 04:57:48 am
content: Here is my new schematic. i have ordered PCB of this from JLPCB and it works perfectly.There are tree components that you need to change regards to pulse-time, off-time and load.The 47K resistor = ~0.5 second on-time. (double the value = doble the on-time)The 3.3M resistor = ~25 seconds off-time. (double the value = double the off-time)The 51R resistor = ~100mA load. (double the value = halve the load)The timer i use in ICM7555. Same pinout as the ordinary 555-timer.

author: mino-fm
author_rank: Regular Contributor
timestamp: December 06, 2021, 08:20:01 am
content: Quote from: ElectricPower on December 06, 2021, 04:57:48 amSorry, but most powerbanks won't accept this timing and this low current.Testing several PBs over years there are typical values of Ton = 0,3 s, periode = 4,5 s and pulse current = 200 mA. This will fit about 90% of PBs and only needs low power dissipation.As an example some (newer) Anker PBs (20 Ah) need Ton = 3 s every 100 s. Other ones need pulses < 4,5 s or they will be power down after a short time < 1 minute.My suggestion uses an ATtiny25 (USB-A stick) and a simple software which has to be modified for special PBs.

author: ledtester
author_rank: Super Contributor
timestamp: December 06, 2021, 08:47:57 am
content: @mino-fmYou should mention your web page for this project:http://mino-elektronik.de/Powerbank/powerbank.htmIt's clear you've spent some time investigating this problem. The section "periodic charging with power bank" is also very interesting.

author: Zero999
author_rank: Super Contributor
timestamp: December 06, 2021, 09:20:46 am
content: Quote from: Peabody on February 27, 2021, 11:04:00 pmA current source requires a P-channel MOSFET, with the reference on the positive rail and a sink an N-channel MOSFET with the reference on the negative rail. In this case, it's arbitrary whether a current source, or sink is used.I wouldn't bother with an MCU, MOSFETs or anything like that. The 74HC14, with one gate configured as an oscillator, with a low duty cycle, feeding the remaining gates, with their inputs and outputs connected in parallel, driving a resistor. If the duty cycle is low, it won't matter if the supply current rating of the IC is exceeded a bit, as it will cool down, between pulses.

author: prosper
author_rank: Regular Contributor
timestamp: December 07, 2021, 03:45:38 am
content: I just built a 555-based one. Seems like a pretty ideal solution for this problem. Low part count, small, super cheap. Deadbug style with mostly 0805 parts on a dip8, fits into most places where i need it

author: ElectricPower
author_rank: Frequent Contributor
timestamp: December 07, 2021, 04:19:19 am
content: I agreed.I just do not know why i should use an microcontroller for this.My circuit works perfectly. But i know that other power banks may force me to do som tweaks regards to puls time and load etc.~100mA pulse that last about 1 second or more is all that takes. I have tested this on four different powerbanks and it works. But i do not say that it works an all powerbanks. For that we possibly need to change a couple of resistors. No problem.

author: mino-fm
author_rank: Regular Contributor
timestamp: December 07, 2021, 12:22:54 pm
content: Quote from: ElectricPower on December 07, 2021, 04:19:19 amI don't know why I should use an ICM7555 for it.A simple resistor (47 Ohm) works perfectly

author: ElectricPower
author_rank: Frequent Contributor
timestamp: December 07, 2021, 12:41:43 pm
content: Quote from: mino-fm on December 07, 2021, 12:22:54 pmBecause it's waste of power?

author: Zero999
author_rank: Super Contributor
timestamp: December 07, 2021, 02:06:28 pm
content: Quote from: ElectricPower on December 07, 2021, 12:41:43 pmThe 7555 typically only uses 40µA, 300µA at extreme temperatures, which is more than an MCU, but low enough not to matter in most applications.https://www.nxp.com/docs/en/data-sheet/ICM7555.pdf

author: ElectricPower
author_rank: Frequent Contributor
timestamp: December 07, 2021, 02:13:39 pm
content: Quote from: Zero999 on December 07, 2021, 02:06:28 pm

author: mino-fm
author_rank: Regular Contributor
timestamp: December 07, 2021, 05:35:44 pm
content: Quote from: Zero999 on December 07, 2021, 02:06:28 pmATtiny only needs 7 µA @ 5 V. I am the winnerYou cannot solve a problem only looking at one minor point. You have to see the whole current consumption of wakeup-circuit and internal losses of powerbank which nobody really knows.Further on: the main point is keeping powerbanks alive. The timing shown for ICM7555 would only work for one of my four powerbanks. So it is only a trial but not a useful solution for other users.You are using large capacitors of 10 µF. Did you consider their initial value of +/- 20% (I guess) or their temperature drift? If you like to power GPS-trackers they have to work outside not knowing about temperature or humidity.Myself I startet with RC-circuits to keep it simple. But going on it was no fun to adjust the timing for other PBs again and again. Optimizations of timing worked over night but failed at sunshine. It's been a painBe happy to get your PBs working. But only a microcontroller can ensure stable and adjustable timing in different environments at low costs.

author: Zero999
author_rank: Super Contributor
timestamp: December 07, 2021, 07:22:19 pm
content: Quote from: mino-fm on December 07, 2021, 05:35:44 pmIt's not my circuit.There are plenty of ways to do this. You say you tested your circuit with several, but that doesn't mean it'll work for any power banks. I doubt there's a solution which will work for all power banks, without draining the battery too quickly.I very much doubt stable timing is required. A potentiometer should suffice. Heck I'd probably just use a couple of transistors, or something like that. I'm not anti-MCU, but in this case having to reprogram it, for different power banks, would be too much of a fag, especially if I'm away and don't have the programmer handy. If I were to go down the MCU route, I'd do something more elaborate and allow the user to program the on/off time and current.

author: SilverSolder
author_rank: Super Contributor
timestamp: December 07, 2021, 08:57:46 pm
content: Is it an option to open the power bank and modify it to work as it should?Maybe a physical switch and a small voltage regulator IC is all it would take?

author: ElectricPower
author_rank: Frequent Contributor
timestamp: December 11, 2021, 02:48:39 am
content: Works like a sharmhost gif online

author: mino-fm
author_rank: Regular Contributor
timestamp: December 11, 2021, 02:21:38 pm
content: Quote from: Zero999 on December 07, 2021, 07:22:19 pmI did so.