Tackling Graceful Shutdowns on the GBZ

Various user-contributed guides for software-related things
User avatar
Oxodao
Posts: 131
Joined: Wed Jun 01, 2016 11:35 am
Location: 127.0.0.1
Has thanked: 4 times
Been thanked: 30 times
Contact:

Re: Tackling Graceful Shutdowns on the GBZ

Post by Oxodao » Wed Jul 13, 2016 2:49 pm

Saint memmie, marne France, 51470
That would be nice :)

Yeah that's maybe what I'll endup doing if there is no other way
Arduino sketch for the gamepad (Teensy replacement): http://github.com/oxodao/GBZGamepad

Quatrerwin
Posts: 56
Joined: Thu May 05, 2016 5:32 pm
Location: WI, USA
Has thanked: 2 times
Been thanked: 10 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by Quatrerwin » Thu Jul 14, 2016 1:06 am

@Camble Were you able to try the MOSFET solution with both MOSFETs yet? If so, do you have an original DMG-01 power switch or are you using a true DPDT switch? I'm trying to figure out if this will be doable with the original power switch (the wiring diagram for it suggests it will not work if I'm reading it correctly and I won't be able to test it with my Raspberry Pi Zero for a few days until I get my mini HDMI adapter in the mail).

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

Re: Tackling Graceful Shutdowns on the GBZ

Post by Camble » Thu Jul 14, 2016 2:13 am

Quatrerwin wrote:@Camble Were you able to try the MOSFET solution with both MOSFETs yet? If so, do you have an original DMG-01 power switch or are you using a true DPDT switch? I'm trying to figure out if this will be doable with the original power switch (the wiring diagram for it suggests it will not work if I'm reading it correctly and I won't be able to test it with my Raspberry Pi Zero for a few days until I get my mini HDMI adapter in the mail).
I'm using a DPDT switch.

I've been working at that for a while now, but only making slow progress. The depletion MOSFET was turning back on as soon as I flipped the power switch, meaning the PowerBoost would shut off instantly. At the moment I've got EN shorted to ground through a large resistor. When I flip the switch, this pulls EN up to BAT, turning on the PowerBoost. This works just fine, but the LEDs on the PowerBoost flicker all the time. I'm trying to come up with a timed solution which cuts this pull-up after a few seconds to allow the Pi to take over.

Right now I'm waiting on delivery of some N-Channel JFETs to try out. They're already a few days late or I would have probably posted my results by now.

It's not difficult to build a small timer circuit which delays power off for a set time. But this isn't as elegant and there's always the risk that the Pi doesn't safely shut down in time. I've been pulling my hair out with this at times, but I'm sure there has to be a way to do it.
Last edited by Camble on Thu Jul 14, 2016 7:42 am, edited 1 time in total.

dboSS
Posts: 78
Joined: Tue May 10, 2016 8:30 pm
Has thanked: 9 times
Been thanked: 5 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by dboSS » Thu Jul 14, 2016 7:29 am

Anyone thinking about selling this board?
This is the very needed feature I want to add to my gameboy
:)

User avatar
NyaSu
Posts: 11
Joined: Wed May 18, 2016 11:17 am
Has thanked: 3 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by NyaSu » Thu Jul 14, 2016 12:46 pm

Oxodao wrote:My problem is that the Pololu is not available nowhere cheap from france...
Isn't 4€ cheap? :D

Sure, shipping isn't, but it gets fine if you're not buying only this :lol:

User avatar
Oxodao
Posts: 131
Joined: Wed Jun 01, 2016 11:35 am
Location: 127.0.0.1
Has thanked: 4 times
Been thanked: 30 times
Contact:

Re: Tackling Graceful Shutdowns on the GBZ

Post by Oxodao » Thu Jul 14, 2016 1:04 pm

Inb4, shipping... I have nothing else to buy... even less on this site that has not much..
4€ pololu + 20c 47k resistors ... 4.20€ products, 5.90€ shipping...
I don't plan on buying anything else...
Arduino sketch for the gamepad (Teensy replacement): http://github.com/oxodao/GBZGamepad

Quatrerwin
Posts: 56
Joined: Thu May 05, 2016 5:32 pm
Location: WI, USA
Has thanked: 2 times
Been thanked: 10 times

Re: Tackling Graceful Shutdowns on the GBZ

Post by Quatrerwin » Fri Jul 15, 2016 12:31 am

Camble wrote: I'm using a DPDT switch.

I've been working at that for a while now, but only making slow progress. The depletion MOSFET was turning back on as soon as I flipped the power switch, meaning the PowerBoost would shut off instantly. At the moment I've got EN shorted to ground through a large resistor. When I flip the switch, this pulls EN up to BAT, turning on the PowerBoost. This works just fine, but the LEDs on the PowerBoost flicker all the time. I'm trying to come up with a timed solution which cuts this pull-up after a few seconds to allow the Pi to take over.

Right now I'm waiting on delivery of some N-Channel JFETs to try out. They're already a few days late or I would have probably posted my results by now.

It's not difficult to build a small timer circuit which delays power off for a set time. But this isn't as elegant and there's always the risk that the Pi doesn't safely shut down in time. I've been pulling my hair out with this at times, but I'm sure there has to be a way to do it.
I can't figure out why you would need a resistor between the EN and GND pins or even any timing circuit to control this.

If I'm reading the diagram right nothing should be connected through the switch when the switch is on (pins 5 & 6 active), so there would be no current flowing between the drain and source. When you turn the switch off (pins 1 and 2 active), GPIO27 connects to GND on the raspberry pi, pulling it low, initializing the shutdown. Now there could be current flowing between the drain and source (EN and GND), but GPIO14 should be set to high already, keeping the depletion MOSFET off. Only when the raspberry pi shuts off (or prematurely pulls GPIO14 low) should the EN and GND pins be connected. I could see for a brief moment there might be no gate-source voltage once the switch is flipped, but I'm wondering if putting the main switch on the drain instead of the source would fix that or if that would cause any issues.

I haven't actually been able to try the MOSFET solution yet, but I will be able to soon (the remainder of the parts I need just shipped!). I could be wrong since I don't have much of a background in electronics yet. I'm really interested in the rest of your findings regarding this solution though!

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

Re: Tackling Graceful Shutdowns on the GBZ

Post by Camble » Fri Jul 15, 2016 3:04 am

@Quaterwin

[spoiler="If you mean this diagram..."]Image[/spoiler]
It doesn't work. The PowerBoost shuts off as soon as the MOSFET's source is connected to ground. A resistor over the gate and source might prevent this, but I'm unsure. I'll test it out this weekend.

I'm working off this at the moment, so you can see why the pull down resistor is there between EN and GND. EN is pulled up manually by connecting it to BAT. Once the Pi boots, a GPIO pin takes over to keep EN high.

Because the above solution uses a momentary switch I've been trying to use the depletion MOSFET to cut this pull up after turning on the Pi. My first idea was to add a delay with a capacitor, but I've ditched this in favour of using the GPIO pin to keep the EN high and also turn off the MOSFET.

Progress is slow as I'm kind of in the same boat when it comes to electronics.
Last edited by Camble on Fri Jul 15, 2016 3:24 am, edited 1 time in total.

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 » Fri Jul 15, 2016 3:19 am

Very interesting.
I've done the Popcorn Pololu solution, it's nice but need a switch to poweroff the powerboost when not used.

If I understand what you are working on Camble, it seems better as the powerboost is switched of automatically.
If you manage to make it works, I think I'll switch to it. ;)
Last edited by SidSilver on Fri Jul 15, 2016 3:28 am, edited 1 time in total.

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

Re: Tackling Graceful Shutdowns on the GBZ

Post by Camble » Fri Jul 15, 2016 3:26 am

SidSilver wrote:Very interesting.
I've done the Popcorn Pololu solution, it's nice but need a switch to poweroff the powerboost when not used.

If I understand what you are working on Camble, it seems better as the powerboost is switched of automatically.
The monetary switch works very well. Hold the button for a few seconds and the Pi boots. Everything shuts down cleanly as you'd expect. The problem is only due to the slide switch. If you were to continue to hold the power button, the charging LEDs on the powerboost go haywire. That can't be a good state for it to be in.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest