[Guide] Graceful shutdown switch without Pololu [RETIRED]

Various user-contributed guides for hardware-related things
larsen2011
Posts: 35
Joined: Sun Jul 17, 2016 11:37 am
Has thanked: 16 times
Been thanked: 4 times

Re: [Guide] Graceful shutdown switch without Pololu

Post by larsen2011 » Sun Dec 04, 2016 1:29 pm

Somehow I don't get it fully working.

So while playing I receive this message, quite often. And I really want to get rid of it, so if someone knows how these interruptions can be switched off, please let me know....
IMG_7511.JPG
IMG_7511.JPG (1.52 MiB) Viewed 9540 times
Now to my biggest issue: I receive that message, and flip my switch to the off position, but nothing happens... No shut down. If I'm using my power cord and switch the GB off, it directly goes off...
IMG_7513.JPG
IMG_7513.JPG (1.65 MiB) Viewed 9540 times
Once the battery level is low enough, the shutdown script starts and shuts down the GB as it should though...
IMG_7512.JPG
IMG_7512.JPG (1.55 MiB) Viewed 9540 times
If someone could help me out with the first onscreen message, and even more important, could explain why the GB doesn't switch off although I want to & force it with the switch (if someone has an idea on how to fix this, please also let me know)...

User avatar
Camble
Posts: 885
Joined: Thu May 05, 2016 2:31 am
Location: Scotland
Has thanked: 269 times
Been thanked: 488 times

Re: [Guide] Graceful shutdown switch without Pololu

Post by Camble » Sun Dec 04, 2016 4:24 pm

@larsen2011 You can tweak the batteryTimeout value in the power monitor script. Try increasing it, start by doubling it and see how that feels.

Alternatively:

Look for this line:

Code: Select all

if bounceSample > int(round(batteryTimeout / sampleRate * 0.1)):
0.1 is 10% of the timeout value. Increase this value to 0.2 or 0.5

larsen2011
Posts: 35
Joined: Sun Jul 17, 2016 11:37 am
Has thanked: 16 times
Been thanked: 4 times

Re: [Guide] Graceful shutdown switch without Pololu

Post by larsen2011 » Mon Dec 05, 2016 3:32 am

Thanks @camble

I noticed that the LBO diode is flickering and that I'm receiving these messages during the flickering stage, until the LBO diode is solid lid. At that point, I receive the shutdown video as in my last picture.

Would it be an option to use a resistor with more than the 500k to reduce the flickering? Instead of changing code?

User avatar
Camble
Posts: 885
Joined: Thu May 05, 2016 2:31 am
Location: Scotland
Has thanked: 269 times
Been thanked: 488 times

Re: [Guide] Graceful shutdown switch without Pololu

Post by Camble » Mon Dec 05, 2016 6:07 am

larsen2011 wrote:Thanks @camble

I noticed that the LBO diode is flickering and that I'm receiving these messages during the flickering stage, until the LBO diode is solid lid. At that point, I receive the shutdown video as in my last picture.

Would it be an option to use a resistor with more than the 500k to reduce the flickering? Instead of changing code?
That's just how it works. The voltage of your battery isn't set. When there is additional CPU load, there is extra current draw, and the voltage drops a little. I've even found that after a low battery shutdown, that the battery voltage is well above 3.2v. It's just while everything is powered that the voltage is slightly lower.

So basically, tweaking the software can give you the results you need. I doubt a higher value resistor would help, but you could try up to 1M. The datasheet for the boost converter chip recommends a 1M pull-down if the LBO pin is not required. Anything below 500K would see the low battery LED on all the time.

larsen2011
Posts: 35
Joined: Sun Jul 17, 2016 11:37 am
Has thanked: 16 times
Been thanked: 4 times

Re: [Guide] Graceful shutdown switch without Pololu

Post by larsen2011 » Mon Dec 05, 2016 12:44 pm

@camble
It's not getting better... Without modifying anything from yesterday to today, I immediately received the Low Battery Monitor during boot phase of the Pi. Switching off didn't work, and when the script wanted to switch off the Pi, I received a Kernel panic.

Even with getting power through Micro USB, I see that the Powerboost charging LED is on, still the same result.

Switched to Layout 2 below, same behavior but without the Kernel panic. So at least the graceful shutdown after the 60sec monitor video worked.

Any idea why the system thinks battery is low, even if it is charging? And why this overrules the charging?
IMG_7514.JPG
IMG_7514.JPG (317.96 KiB) Viewed 9492 times

User avatar
Camble
Posts: 885
Joined: Thu May 05, 2016 2:31 am
Location: Scotland
Has thanked: 269 times
Been thanked: 488 times

Re: [Guide] Graceful shutdown switch without Pololu

Post by Camble » Mon Dec 05, 2016 1:17 pm

larsen2011 wrote:@camble
It's not getting better... Without modifying anything from yesterday to today, I immediately received the Low Battery Monitor during boot phase of the Pi. Switching off didn't work, and when the script wanted to switch off the Pi, I received a Kernel panic.
Switching off during the low battery warning won't work. The script is busy keeping an eye on the LBO pin to see if it's solid. Bear in mind I didn't write the power monitor script, but am working on a new one (among many other things).

What is the actual voltage of the battery? As I've said, under load (eg. during bootup), the battery voltage will fall slightly. If your battery is low enough that putting extra drain on it pulls the voltage below 3.3v, the PowerBoost LBO pin will go low and signal a low battery.

It may help to study the PowerBoost schematic and the boost converter chip schematic. You'll see that the LBO pin is a simple comparator. The LBO pin is either "battery voltage" or zero. When the battery voltage fluctuates, the pin drops low and back high again, causing the LED to flicker. That is why the script was written to monitor the pin closely for a period of time, rather than just respond to the pin dropping low. This is also why the power switch won't work during a low battery warning.

https://learn.adafruit.com/assets/24638 (bottom-left corner shows the LBO pin on the boost chip)
https://cdn-shop.adafruit.com/datasheets/tps61090.pdf (page 4 shows the comparator inside the boost chip)

What is the value of your pull-down resistor on the JFET gate? Did you read this post? Try replacing it with a 10K resistor and see if that prevents the kernel panic. This should be a pull-down to ground at the JFET gate. You could also try removing it completely, as GPIO pins have internal pull-up/down resistors.

wbarber69
Posts: 1
Joined: Thu Dec 15, 2016 2:08 pm

Re: [Guide] Graceful shutdown switch without Pololu

Post by wbarber69 » Thu Dec 15, 2016 2:12 pm

Can i use a different gpio than 17. the screen i am looking into getting uses 2-21

User avatar
Camble
Posts: 885
Joined: Thu May 05, 2016 2:31 am
Location: Scotland
Has thanked: 269 times
Been thanked: 488 times

Re: [Guide] Graceful shutdown switch without Pololu

Post by Camble » Thu Dec 15, 2016 4:51 pm

wbarber69 wrote:Can i use a different gpio than 17. the screen i am looking into getting uses 2-21
https://pinout.xyz/

23 or 24 should be free and aren't reserved for anything else

Mr Ribbon
Posts: 12
Joined: Fri Dec 16, 2016 3:54 am
Been thanked: 2 times

Re: [Guide] Graceful shutdown switch without Pololu

Post by Mr Ribbon » Fri Dec 16, 2016 4:03 am

Will a ds lite power switch work and fit ?
Attachments
7c1c20bb7cdeff89da9673bc4ed590a2.jpg
7c1c20bb7cdeff89da9673bc4ed590a2.jpg (11.08 KiB) Viewed 9406 times

User avatar
RxBrad
Posts: 278
Joined: Fri Jul 22, 2016 9:10 am
Has thanked: 125 times
Been thanked: 160 times
Contact:

Re: [Guide] Graceful shutdown switch without Pololu

Post by RxBrad » Fri Dec 16, 2016 7:11 am

I've noticed that this circuit works great on battery power alone. For whatever reason, if you're connected to a charger when you flip the switch, it instantly cuts the power.

Does the GPIO voltage from the Pi perhaps send a slightly different voltage when charging and not charging, and this difference is enough to throw off the circuit? And if so, any guesses how to remedy this?

I'm using the 2A Pi power supply from Pimoroni as my charger, for what it's worth.
Image
Image Image

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest