Tackling Graceful Shutdowns on the GBZ

Various user-contributed guides for software-related things
User avatar
Zeke2040
Posts: 22
Joined: Tue May 17, 2016 2:11 pm
Location: Alabama, USA
Has thanked: 3 times
Been thanked: 1 time

Re: Tackling Graceful Shutdowns on the GBZ

Post by Zeke2040 » Fri May 27, 2016 10:19 pm

prerunnerseth wrote:Well my boards came in and I made a mistake :(. I used a different package of mybpushbutton controller than tested with and it seems one of the missing pins was actually needed. I'll have to order more
Ugh! Sorry to hear that. Looking forward to seeing it come together.

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 » Sat May 28, 2016 6:05 am

Ok, here's the Power and Battery monitor finished. I've been testing it out and it works quite well.

Firstly, follow this wiring diagram. Here I'm using the Pololu Mini Slide Switch LV.

Image

PLEASE NOTE: In the diagram, the Pololu's built-in slide switch is set to On, this is from their website. We need this always in the OFF position.

For the software monitor, you'll need to use SSH and log onto the Pi. Default user PI and password "raspberry"

You should be able to do this if you have a Wifi adapter on the Pi Zero and then connect from a computer on the same Wifi network. (Use Putty on PCs)

Code: Select all

ssh pi@retropie.local
At the command prompt, making sure you are the Pi user, type this to download the monitor and the videos:

Code: Select all

cd ~;git clone https://github.com/NullCorn/GBZ-Power-Monitor.git
You can then test it out by issuing this command:

Code: Select all

python ~/GBZ-Power-Monitor/gbz_power_monitor.py
Once you are satisfied that it detects your power switch and the low battery warnings, you can add it to the startup easily using the crontab of the pi user. I chose this method rather than messing with services because you'd don't have to be the root user.

Simply enter this line on the command prompt to add the monitor on startup.

Code: Select all

echo "@reboot     /usr/bin/nice -n 19 /usr/bin/python ~/GBZ-Power-Monitor/gbz_power_monitor.py" >> mycron; crontab mycron;rm mycron
Videos of it in action

https://www.youtube.com/watch?v=TRkEfD04unk
Low Battery Warning

https://www.youtube.com/watch?v=nRJ42oSrIg4
Power Switch test

Let me know how it works for you guys.

User avatar
Fleder
Posts: 849
Joined: Thu May 05, 2016 9:04 am
Location: Germany
Has thanked: 183 times
Been thanked: 258 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by Fleder » Sat May 28, 2016 6:26 am

@[mention]Popcorn[/mention]
I am sorry, i am sure this was already answered, but will the push button switch work as well instead of the slide switch?

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 » Sat May 28, 2016 7:04 am

Fleder wrote:@[mention]Popcorn[/mention]
I am sorry, i am sure this was already answered, but will the push button switch work as well instead of the slide switch?
Yes, the push button will work. Put UART TX to CTRL. Everything else should be wired the same. We can also use the OFF pin and GPIO-Poweroff but CTRL should work fine.

Image

SidSilver
Posts: 263
Joined: Sun May 22, 2016 6:22 am
Location: France
Has thanked: 137 times
Been thanked: 37 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by SidSilver » Sat May 28, 2016 7:16 am

Is it possible to use the pololu's board switch as main switch instead of adding another ?

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 » Sat May 28, 2016 7:22 am

SidSilver wrote:Is it possible to use the pololu's board switch as main switch instead of adding another ?
If you mean the on-board switch, it's super super tiny and won't work with the original DMG power switch.

If you mean the Emergency Latching Switch is not actually mandatory, but I recommend it just in case. It's there in the event of a kernel panic or some other condition where the monitor fails to power the pololu off. It's also there to disconnect the batteries when putting away the unit for longer periods.

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 » Sat May 28, 2016 7:39 am

I've fixed my boards and ordered another the second revision. I was also able to make the board a little smaller. I did confirm by hacking in the correct package that they will function as intended.

SidSilver
Posts: 263
Joined: Sun May 22, 2016 6:22 am
Location: France
Has thanked: 137 times
Been thanked: 37 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by SidSilver » Sat May 28, 2016 7:46 am

Popcorn wrote:
SidSilver wrote:Is it possible to use the pololu's board switch as main switch instead of adding another ?
If you mean the on-board switch, it's super super tiny and won't work with the original DMG power switch.
Ok. Thanks. I didn't realize the actual size of the on-board switch.

Final question, can you remember me what is the transistor for ?

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 » Sat May 28, 2016 8:04 am

Just found a small bug that will prevent the videos from playing on the Low Battery warnings. If you cloned the git repository before now, do this to grab the latest version. Sorry.

Code: Select all

cd ~/GBZ-Power-Monitor;git pull origin master
If you are reading this and haven't grab it previously, then you don't need to do this. (Although doing it never hurts to be up-to-date)

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 » Sat May 28, 2016 8:08 am

SidSilver wrote:
Popcorn wrote:
SidSilver wrote:Is it possible to use the pololu's board switch as main switch instead of adding another ?
If you mean the on-board switch, it's super super tiny and won't work with the original DMG power switch.
Ok. Thanks. I didn't realize the actual size of the on-board switch.

Final question, can you remember me what is the transistor for ?
It acts like a simple switch. When the Low Battery LED saturates the transistor, it pulls the GPIO line low and our monitor detects that. When it's not, it's pulled high. Since the voltage on the LED is variable, this is the safest way to know for sure that there is a Low Battery condition.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest