Author Topic: (yet another) Power Bank Stay-On Circuit  (Read 12290 times)

0 Members and 1 Guest are viewing this topic.

Offline DrGTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 1199
  • Country: us
(yet another) Power Bank Stay-On Circuit
« on: February 26, 2021, 11:22:30 pm »
I was reading this thread https://www.eevblog.com/forum/projects/power-bank-issues/msg3474652/#msg3474652 and 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 that :) Here is a pretty nice one and I like the micro approach https://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: [Select]
/*
 *                    -> 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 resets
    OPTION=0b11011111;
    TRIS = 0b111001; // configure GP1 and GP2 as outputs
    if( (__powerdown==1) && (__timeout==1) ){
        // POR reset
        GPIO = 0b000110;    // GP1 and GP2 on
        __delay_ms(1000);   
        GPIO = 0b000000;
        counter=0;
        }
    else{
     // it is a WDT reset
     counter+=1;
     if(counter==WDTcounts){
        GPIO=0b000110;       // GP1 and GP2 on
        __delay_ms(PULSETIME);
        GPIO=0b000000;       // LEDs off
        counter=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


« Last Edit: February 27, 2021, 04:00:57 am by DrG »
- Invest in science - it pays big dividends. -
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: us
Re: (yet another) Power Bank Stay-On Circuit
« Reply #1 on: February 27, 2021, 04:49:40 am »
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?
 

Offline DrGTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 1199
  • Country: us
Re: (yet another) Power Bank Stay-On Circuit
« Reply #2 on: February 27, 2021, 05:20:42 pm »
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?

Since 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 (from https://blog.zakkemble.net/smart-power-bank-keep-alive/ ):

« Last Edit: February 27, 2021, 05:24:53 pm by DrG »
- Invest in science - it pays big dividends. -
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: us
Re: (yet another) Power Bank Stay-On Circuit
« Reply #3 on: February 27, 2021, 11:04:00 pm »
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.
 
The following users thanked this post: DrG

Offline wizard69

  • Super Contributor
  • ***
  • Posts: 1184
  • Country: us
Re: (yet another) Power Bank Stay-On Circuit
« Reply #4 on: February 28, 2021, 12:53:06 am »
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.
 

Offline DrGTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 1199
  • Country: us
Re: (yet another) Power Bank Stay-On Circuit
« Reply #5 on: February 28, 2021, 04:01:02 am »
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. 

Yeah, 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.
- Invest in science - it pays big dividends. -
 

Offline wizard69

  • Super Contributor
  • ***
  • Posts: 1184
  • Country: us
Re: (yet another) Power Bank Stay-On Circuit
« Reply #6 on: February 28, 2021, 03:43:28 pm »
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. 

Yeah, 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.

I 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.
 

Offline DrGTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 1199
  • Country: us
Re: (yet another) Power Bank Stay-On Circuit
« Reply #7 on: February 28, 2021, 09:16:35 pm »
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. 

Yeah, 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.

I 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.

Having 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 :)
« Last Edit: February 28, 2021, 09:25:03 pm by DrG »
- Invest in science - it pays big dividends. -
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19477
  • Country: gb
  • 0999
Re: (yet another) Power Bank Stay-On Circuit
« Reply #8 on: March 01, 2021, 11:52:49 am »
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.
 
The following users thanked this post: splin

Offline DrGTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 1199
  • Country: us
Re: (yet another) Power Bank Stay-On Circuit
« Reply #9 on: March 05, 2021, 07:29:37 pm »
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.
« Last Edit: March 05, 2021, 07:31:14 pm by DrG »
- Invest in science - it pays big dividends. -
 

Offline SilverSolder

  • Super Contributor
  • ***
  • Posts: 6126
  • Country: 00
Re: (yet another) Power Bank Stay-On Circuit
« Reply #10 on: March 05, 2021, 07:49:27 pm »

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.
 

Offline ElectricPower

  • Frequent Contributor
  • **
  • Posts: 297
  • Country: no
  • I have many opinions but have no idea
    • Turer, fjas & slabberas
Re: (yet another) Power Bank Stay-On Circuit
« Reply #11 on: October 18, 2021, 04:12:08 am »
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.



« Last Edit: October 18, 2021, 04:14:21 am by ElectricPower »
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: us
Re: (yet another) Power Bank Stay-On Circuit
« Reply #12 on: October 18, 2021, 03:19:24 pm »
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.
 

Offline ElectricPower

  • Frequent Contributor
  • **
  • Posts: 297
  • Country: no
  • I have many opinions but have no idea
    • Turer, fjas & slabberas
Re: (yet another) Power Bank Stay-On Circuit
« Reply #13 on: October 18, 2021, 03:20:33 pm »
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.
No, 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.
« Last Edit: October 18, 2021, 03:23:24 pm by ElectricPower »
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: us
Re: (yet another) Power Bank Stay-On Circuit
« Reply #14 on: October 18, 2021, 04:16:36 pm »
I guess I glanced too quickly since it's obvious what it is.  Sorry.
 

Offline ElectricPower

  • Frequent Contributor
  • **
  • Posts: 297
  • Country: no
  • I have many opinions but have no idea
    • Turer, fjas & slabberas
Re: (yet another) Power Bank Stay-On Circuit
« Reply #15 on: October 18, 2021, 10:12:49 pm »
I guess I glanced too quickly since it's obvious what it is.  Sorry.
No problem :)
 

Offline ElectricPower

  • Frequent Contributor
  • **
  • Posts: 297
  • Country: no
  • I have many opinions but have no idea
    • Turer, fjas & slabberas
Re: (yet another) Power Bank Stay-On Circuit
« Reply #16 on: October 18, 2021, 11:55:27 pm »
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.




I 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?
 

Offline ElectricPower

  • Frequent Contributor
  • **
  • Posts: 297
  • Country: no
  • I have many opinions but have no idea
    • Turer, fjas & slabberas
Re: (yet another) Power Bank Stay-On Circuit
« Reply #17 on: October 19, 2021, 04:15:24 am »
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.



 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: us
Re: (yet another) Power Bank Stay-On Circuit
« Reply #18 on: October 19, 2021, 02:26:09 pm »
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.
 

Offline ElectricPower

  • Frequent Contributor
  • **
  • Posts: 297
  • Country: no
  • I have many opinions but have no idea
    • Turer, fjas & slabberas
Re: (yet another) Power Bank Stay-On Circuit
« Reply #19 on: October 19, 2021, 03:33:14 pm »
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.
 

Offline ElectricPower

  • Frequent Contributor
  • **
  • Posts: 297
  • Country: no
  • I have many opinions but have no idea
    • Turer, fjas & slabberas
Re: (yet another) Power Bank Stay-On Circuit
« Reply #20 on: December 06, 2021, 04:57:48 am »
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.

« Last Edit: December 06, 2021, 04:59:43 am by ElectricPower »
 

Offline mino-fm

  • Regular Contributor
  • *
  • Posts: 143
  • Country: de
Re: (yet another) Power Bank Stay-On Circuit
« Reply #21 on: December 06, 2021, 08:20:01 am »

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.

Sorry, 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.
 
The following users thanked this post: thm_w, ledtester

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3034
  • Country: us
Re: (yet another) Power Bank Stay-On Circuit
« Reply #22 on: December 06, 2021, 08:47:57 am »
@mino-fm

You should mention your web page for this project:

http://mino-elektronik.de/Powerbank/powerbank.htm

It's clear you've spent some time investigating this problem. The section "periodic charging with power bank" is also very interesting.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19477
  • Country: gb
  • 0999
Re: (yet another) Power Bank Stay-On Circuit
« Reply #23 on: December 06, 2021, 09:20:46 am »
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.
A 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.
 

Offline prosper

  • Regular Contributor
  • *
  • Posts: 78
  • Country: ca
Re: (yet another) Power Bank Stay-On Circuit
« Reply #24 on: December 07, 2021, 03:45:38 am »
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
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf