Tackling Graceful Shutdowns on the GBZ

Various user-contributed guides for software-related things
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 » Wed May 11, 2016 9:40 am

Image

I have mine mapped to:

PIN 8/ GPIO14 going to the ON pin of the Pololu
PIN 11/GPIO17 going to the Power Switch to listen for case changes (but you can pick whatever free GPIO pin)
PIN 6/Ground is going to the other side of the Power Switch

I don't have my Powerboost yet to test the Low pin, but I imagine this is fine.

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 » Wed May 11, 2016 11:35 pm

OK, it looks like I can put a tactile switch on the EN pin and GND pin on the Powerboost and use it as a reset button. According, to the documentation, if you close a loop between those two, it will cut the power.

https://learn.adafruit.com/adafruit-pow ... st/pinouts

The only question is, does anybody know if we are using those pins with Wermy build?

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 » Thu May 12, 2016 9:17 am

Hi all,

I got my Powerboost 1000C today and can confirm that everything will work exactly as planned.

I threw together some ASCII art for you guys (old school, i know) to show you how it's configured:

Code: Select all

                              __________________________________________________
                             |              __________________________________  |(LowBatt)
                             |             |                      (Off Signal)| |                       
               [USB PowerIn] |      [ON/OFF Switch]   [Audio Amp AC]          | | 
                     |       |             | (on only)      ▲                 | |
                     ▼       |             ▼                |                 ▼ ▼
[Battery] ◄-► [Powerboost 1000C] -► [Pololu Switch]  --► [GBZ AC]  ◄---►  [GPIO Ports] 
                     ▲                     ▲ (off only)     |                   | 
                     |                     |                ▼                   |
         [Emergency Reset Button]          |        [Video Screen AC]           |
                                           |____________________________________|
                                           (UART TX killed on clean shutdown)
You guys should be safe to buy the Pololu slide switch and use that or the Mini push button version without any problems.

In this test, I was able to make the emergency reset kill all power to the whole system, even when the power was remaining in the ON position on the Pololu. So in the event of a Kernal Panic, we can kill the power. I was also able to perform all of the other tests successfully I did before as well.

Here's a picture of my prototype.

Image

The push button to the far right is the Reset button. The push button between the Pololu switch and USB breakout is the main on/off switch. Everything works exactly as expected. Exciting!

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

Re: Tackling Graceful Shutdowns on the GBZ

Post by Camble » Thu May 12, 2016 10:16 am

This is awesome!!

User avatar
chiz
Posts: 228
Joined: Thu May 05, 2016 12:05 am
Has thanked: 29 times
Been thanked: 119 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by chiz » Thu May 12, 2016 4:29 pm

@Popcorn
Thanks for pursuing and sharing this! I didn't have the time to go back to my set-up and I don't think I need to since you already cracked it. :D

Do you mind if you can post the exact pin connections? As you know since I removed the even-numbered GPIO pins on my RPi2 I'm wondering if your set-up can work on the odd-numbered pins as well.

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 » Thu May 12, 2016 5:44 pm

chiz wrote:@Popcorn
Thanks for pursuing and sharing this! I didn't have the time to go back to my set-up and I don't think I need to since you already cracked it. :D

Do you mind if you can post the exact pin connections? As you know since I removed the even-numbered GPIO pins on my RPi2 I'm wondering if your set-up can work on the odd-numbered pins as well.
Hey @chiz,

Thanks! Yeah, based on the tip from @Masato, I changed my setup to use GPIO 8 / BCM 14 - UART TX which seems to provide a stable High state from the moment of power on. This way we don't have to wait for the OS to boot up, and for the GPIO pins to initialize and set as an output.

But previous to that, I was running it on GPIO 27 / BCM 13 as an output and it was working fine. Was killing the signal on shutdown which tripped the switch off. You would be able to do this no problem, since it's an odd numbered port.

Pins 7, 11, and 13 are ripe for the picking and Pin 9 is a ground and is closeby too.

And another benefit of picking those ports is that there's no conflict with @prerunnerseth's guide on wiring up the gamepad to GPIO, so you can run power AND control the gamepad from GPIO at the same time, if you like.

In the next days, I'll get all the listener daemon code setup and will post it here.

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 » Thu May 12, 2016 6:36 pm

Popcorn,

I'm going to look into this a little bit myself. I think i can come up with a simple circuit based on this. Power is my business. My company makes power related ICs. Don't tell any of them im using a TI boost controller though.. HAHA. My plan is to impliment this with the original GB slide switch. Slide switch one direction and the power is applied using a similar P-Fet powerpath. Then when the switch is slid the opposite direction it will trigger a state output to tell the RPi to shut down, this state would also be able to be initiated by a Low Batt signal. Then once you lose the high state on one of the GPIO pins the actual power path is cut.

This sound right to you? If I have time I will start playing with simulation tomorrow. If any of you are curious about simulation my company makes one of the best free simulation software available with a pretty vast support community.

Its called LTSpice

http://www.linear.com/designtools/software/#LTspice

User avatar
chiz
Posts: 228
Joined: Thu May 05, 2016 12:05 am
Has thanked: 29 times
Been thanked: 119 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by chiz » Thu May 12, 2016 7:44 pm

@prerunnerseth
Since you mentioned about power, might as well consider creating the circuit with Powerboost + Pololu switch combined. Not only it makes your product unique in the market but for us makers, you shrink the footprint by combining both rather than having to use these two separate products.

While you're at it, consider also adding solder points/leads for LEDs for different statuses, i.e., powered on, low bat, charging, full, etc. This way, we only need to solder the LEDs and have them exposed anywhere in the case.

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 » Thu May 12, 2016 8:11 pm

Sounds great and by all means @prerunnerseth! Can't wait to see what you come up with.

+1 for @chiz's suggestions. also I'd add that it needs the ability for this manual reset feature to be there too, which I think has become a key feature. For kinda the same reason why we have fire extinguishers around; hopefully never needed, but thankful to have them around and nearby when we do.

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 » Fri May 13, 2016 5:34 am

Popcorn wrote:Sounds great and by all means @prerunnerseth! Can't wait to see what you come up with.

+1 for @chiz's suggestions. also I'd add that it needs the ability for this manual reset feature to be there too, which I think has become a key feature. For kinda the same reason why we have fire extinguishers around; hopefully never needed, but thankful to have them around and nearby when we do.
Sounds good. Ill look into it. I think i found one of our pushbutton controllers that will work with a slide switch and do all these functions. I need to play with it in simulation to make sure the less momentary action of a switch works fine with it.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest