Tackling Graceful Shutdowns on the GBZ

Various user-contributed guides for software-related things
Post Reply
prerunnerseth
Posts: 279
Joined: Fri May 06, 2016 5:36 pm
Has thanked: 16 times
Been thanked: 229 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by prerunnerseth » Mon May 16, 2016 7:27 am

My powerpath controller demo board comes in today. Once I have this tested and working on the bench I will integrate it into the boost/battery board and order a few boards to test with.

Popcorn,

I havent had a chance to go back and read everything. Are you getting an active low or high from the Pi to signal that a shutdown is done or is it that the pin shuts down and go High Z?

User avatar
Popcorn
Trailblazer
Trailblazer
Posts: 354
Joined: Thu May 05, 2016 12:58 am
Location: Berlin
Has thanked: 29 times
Been thanked: 71 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by Popcorn » Mon May 16, 2016 10:08 am

prerunnerseth wrote:My powerpath controller demo board comes in today. Once I have this tested and working on the bench I will integrate it into the boost/battery board and order a few boards to test with.

Popcorn,

I havent had a chance to go back and read everything. Are you getting an active low or high from the Pi to signal that a shutdown is done or is it that the pin shuts down and go High Z?
Yeah, I know this thread is kinda rambling, as I've been iterating through various ideas, so I'll try to post things when ideas are more concrete and less formative. Should make less posts to have to go through :)

So presently, I am simulating everything with buttons. I have 3.3V going to a GPIO input for the Low Battery. And I have a regular switch for the power. Both work as expected. When each are tripped, my daemon runs the appropriate shutdown sequence. The LBO is active high and is tripped low to 0V when there is a low battery condition like this video I posted yesterday with a HUD display overtop of MAME and EmulationStation

Since I don't have my battery yet, I can't do a live test but, however, today unfortunately I came to realize that the Low Battery Output of the Powerboost is actually pulled High, up to the Battery voltage level, and when it drops below 3.2V, then it's pulled to Low. Because of this, there's up to 4.2V of the battery potentially going to GPIO, and since it's over the 3.3V GPIO threshold and I don't want to add more components, I need to look for an alternative.

On the bright side, it looks like I found a viable workaround. I'm investigating using the Teensy to read the Voltage level. The ADC is limited to 3.3V input, but the main power can accept up to 5V. And the guys on the Teensy forums have seemed to figure out a way to use this with some algebraic functions to map out Voltage level versus ADC levels which gives a fairly accurate Battery level status. Genius stuff. The plus side of this is if we can read the battery level, then we can also make a HUD display for it. Since I've been figuring out how to map things to the Frame Buffer on the top layers.

Anyway, I'm not an electrical engineer but I'd be curious if you could make sense of some of this stuff.

https://forum.pjrc.com/threads/26117-Te ... lert/page2

That's where I'm at.

prerunnerseth
Posts: 279
Joined: Fri May 06, 2016 5:36 pm
Has thanked: 16 times
Been thanked: 229 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by prerunnerseth » Mon May 16, 2016 10:28 am

Popcorn wrote:
prerunnerseth wrote:My powerpath controller demo board comes in today. Once I have this tested and working on the bench I will integrate it into the boost/battery board and order a few boards to test with.

Popcorn,

I havent had a chance to go back and read everything. Are you getting an active low or high from the Pi to signal that a shutdown is done or is it that the pin shuts down and go High Z?
Yeah, I know this thread is kinda rambling, as I've been iterating through various ideas, so I'll try to post things when ideas are more concrete and less formative. Should make less posts to have to go through :)

So presently, I am simulating everything with buttons. I have 3.3V going to a GPIO input for the Low Battery. And I have a regular switch for the power. Both work as expected. When each are tripped, my daemon runs the appropriate shutdown sequence. The LBO is active high and is tripped low to 0V when there is a low battery condition like this video I posted yesterday with a HUD display overtop of MAME and EmulationStation

Since I don't have my battery yet, I can't do a live test but, however, today unfortunately I came to realize that the Low Battery Output of the Powerboost is actually pulled High, up to the Battery voltage level, and when it drops below 3.2V, then it's pulled to Low. Because of this, there's up to 4.2V of the battery potentially going to GPIO, and since it's over the 3.3V GPIO threshold and I don't want to add more components, I need to look for an alternative.

On the bright side, it looks like I found a viable workaround. I'm investigating using the Teensy to read the Voltage level. The ADC is limited to 3.3V input, but the main power can accept up to 5V. And the guys on the Teensy forums have seemed to figure out a way to use this with some algebraic functions to map out Voltage level versus ADC levels which gives a fairly accurate Battery level status. Genius stuff. The plus side of this is if we can read the battery level, then we can also make a HUD display for it. Since I've been figuring out how to map things to the Frame Buffer on the top layers.

Anyway, I'm not an electrical engineer but I'd be curious if you could make sense of some of this stuff.

https://forum.pjrc.com/threads/26117-Te ... lert/page2

That's where I'm at.
No no... skip the Teensy. you can do this with a couple very small fets. Let me do a quick simulation to show you.

User avatar
Popcorn
Trailblazer
Trailblazer
Posts: 354
Joined: Thu May 05, 2016 12:58 am
Location: Berlin
Has thanked: 29 times
Been thanked: 71 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by Popcorn » Mon May 16, 2016 10:37 am

prerunnerseth wrote:
No no... skip the Teensy. you can do this with a couple very small fets. Let me do a quick simulation to show you.
Yeah, but the point that I'm trying the Teensy is two-fold. One to solve this >3.3V potental input but more importantly, so I can get the actual battery level which would be amazing. Then I could have a HUD status bar with the actual battery level on screen at all times. Something that is missing. So that's what I'm exploring. Let me know if you have any ideas

prerunnerseth
Posts: 279
Joined: Fri May 06, 2016 5:36 pm
Has thanked: 16 times
Been thanked: 229 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by prerunnerseth » Mon May 16, 2016 10:38 am

OK sorry, I went back and looked at the Data sheet. The LBO output of the TPS6109 is simply an open drain output. It pulls low on the transistor which biases the transistor and allows current to flow to the LED. You simply need to Move the emitter of the Transistor to the 3.3V rail. Then tie the top of the LED to your input. this will give you a logic high when you have LBO asserted. There may be enough leakage through the Transistor to bias the high impedance GPIO input of the Pi, so I would suggest replacing the PNP with a PFET like the BSS84.

How does your HUD status bar work? you can simply configure one of the available ADC inputs of the pi to read the battery level. Then you would have to have code on the PI to read that and display a battery level.

User avatar
Popcorn
Trailblazer
Trailblazer
Posts: 354
Joined: Thu May 05, 2016 12:58 am
Location: Berlin
Has thanked: 29 times
Been thanked: 71 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by Popcorn » Mon May 16, 2016 10:52 am

Yeah, seems like this guy did something similar with the Powerboost and wiring it up to the LED led

http://www.stuffaboutcode.com/2016/01/p ... nitor.html

I didn't believe/know the Pi Zero had any onboard ADC. That's why I'm looking at the Teensy because there's a bunch of them that are unused on there.

prerunnerseth
Posts: 279
Joined: Fri May 06, 2016 5:36 pm
Has thanked: 16 times
Been thanked: 229 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by prerunnerseth » Mon May 16, 2016 10:56 am

Popcorn wrote:Yeah, seems like this guy did something similar with the Powerboost and wiring it up to the LED led

http://www.stuffaboutcode.com/2016/01/p ... nitor.html

I didn't believe/know the Pi Zero had any onboard ADC. That's why I'm looking at the Teensy because there's a bunch of them that are unused on there.
Let me double check, but most processors have atleast a few GPIO pins that can be configured as DAC or ADCs.

prerunnerseth
Posts: 279
Joined: Fri May 06, 2016 5:36 pm
Has thanked: 16 times
Been thanked: 229 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by prerunnerseth » Mon May 16, 2016 11:02 am

prerunnerseth wrote:
Popcorn wrote:Yeah, seems like this guy did something similar with the Powerboost and wiring it up to the LED led

http://www.stuffaboutcode.com/2016/01/p ... nitor.html

I didn't believe/know the Pi Zero had any onboard ADC. That's why I'm looking at the Teensy because there's a bunch of them that are unused on there.
Let me double check, but most processors have atleast a few GPIO pins that can be configured as DAC or ADCs.
Well Crap.... I don't see any that are configurable as ADC. That sucks.

prerunnerseth
Posts: 279
Joined: Fri May 06, 2016 5:36 pm
Has thanked: 16 times
Been thanked: 229 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by prerunnerseth » Mon May 16, 2016 11:05 am

Popcorn wrote:Yeah, seems like this guy did something similar with the Powerboost and wiring it up to the LED led

http://www.stuffaboutcode.com/2016/01/p ... nitor.html

I didn't believe/know the Pi Zero had any onboard ADC. That's why I'm looking at the Teensy because there's a bunch of them that are unused on there.
So whats wrong with using this method? I thought you wanted to get a battery level and not just a low battery indicator. I could even add a 2 minute timer circuit to this that would force a shut down if you didnt already initiate one within 2 minutes.

User avatar
Popcorn
Trailblazer
Trailblazer
Posts: 354
Joined: Thu May 05, 2016 12:58 am
Location: Berlin
Has thanked: 29 times
Been thanked: 71 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by Popcorn » Mon May 16, 2016 11:09 am

prerunnerseth wrote:
Popcorn wrote:Yeah, seems like this guy did something similar with the Powerboost and wiring it up to the LED led

http://www.stuffaboutcode.com/2016/01/p ... nitor.html

I didn't believe/know the Pi Zero had any onboard ADC. That's why I'm looking at the Teensy because there's a bunch of them that are unused on there.
So whats wrong with using this method? I thought you wanted to get a battery level and not just a lower battery indicator.
Nothing except if we use the Teensy, we get a battery level reading as a bonus. Going that route, we'd need to make a little breakout board, build a circuit and solder more components. I want to try to use what we have instead of adding more. That's the thought process anyway.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest