Tackling Graceful Shutdowns on the GBZ

Various user-contributed guides for software-related things
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 » Mon Jul 18, 2016 4:23 am

So the N-channel depletion MOSFET was working as intended, until the power switch was closed. Everything just shut off straight away.

I finally have a working solution, using a P-channel JFET connected to the EN pin of the PowerBoost.

I am not sure if the resistor is necessary when using a depletion FET, but it seems to have eliminated a weird intermittent problem with powering off.

The only thing with this setup is that you can't switch off during early boot-up.

Here's a video.

Image

Be sure to add the following to /boot/config.txt

Code: Select all

dtoverlay=gpio-poweroff,gpiopin=4,active_low="y"
Last edited by Camble on Sat Jul 23, 2016 8:17 am, edited 3 times in total.

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 » Mon Jul 18, 2016 4:36 am

Looking forward to trying your solution! Thanks for your work!

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 » Mon Jul 18, 2016 4:51 am

Cool, let me know how you get on! I'm thinking of adding a short RC delay on power-off, just to be completely safe. 2 seconds or something like that.

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 » Mon Jul 18, 2016 5:53 am

I was thinking about adding a diode as well for some protection (raspberry pi gpio doesn't like voltages above 3.3V and I'm not sure what the current limit is)

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 » Mon Jul 18, 2016 6:00 am

The UART TX pin is 3.3v and it shouldn't be receiving any current. It keeps the JFET's gate at +3.3v. A diode won't hurt, but I don't think it's necessary.

The GPIO27 pin is simply shorted to ground when you want to signal a shutdown, so no protection required here either.

Something that would be more useful is a way to prevent the UART voltage fluctuating to as low as 1v while the Pi boots up. After about 5 seconds of bootup, it stabilises at 3.3v, but if you close the power switch before this happens, the PowerBoost will shut off. Strange, because the minimum cut-off gate voltage for this JFET is 750mV. Maybe just not enough to pinch off. I might try playing with the voltages some more.

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 » Mon Jul 18, 2016 8:45 pm

@Camble I'm playing around with the depletion MOSFET and I'm having difficulty turning it off. The MOSFET connects to the powerboost on the drain and source side (source going to ground, drain going to enable). The gate goes to the raspberry pi on the TXD pin. Since I have the raspberry pi zero getting its power from the powerboost, the ground is shared (I've also verified it). Is there any way you did the wiring to get it to work?

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 » Tue Jul 19, 2016 1:31 am

@Quatrerwin What MOSFET are you using? Can you check the voltage across the gate-source when the Pi is powered?

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 » Tue Jul 19, 2016 5:48 am

It would be this one: DN2530
At the terminals, gate-source voltage is 3.3V and the current is 40mA. I'm not sure if the positive voltage is an issue (I'm having difficulty imagining how to make it negative while still having the drain to source work). The drain is connected to the 5V source on the powerboost through an LED and resistor, the gate to TXD on the raspberry pi, and the source to the ground on the powerboost. Additionally I did try a 100k resistor between the gate and ground.

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 » Tue Jul 19, 2016 5:49 am

You need a P-channel depletion MOSFET or a P-channel JFET.

2N5460
Last edited by Camble on Sat Jul 23, 2016 4:13 am, edited 2 times in total.

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 » Tue Jul 19, 2016 5:55 am

I'm waiting on my p channel JFETs to arrive. Were you able to get the n channel depletion MOSFET to work without one?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest