[Guide] Graceful shutdown switch without Pololu [RETIRED]

Various user-contributed guides for hardware-related things
Post Reply
User avatar
Camble
Posts: 881
Joined: Thu May 05, 2016 2:31 am
Location: Scotland
Has thanked: 269 times
Been thanked: 487 times

[Guide] Graceful shutdown switch without Pololu [RETIRED]

Post by Camble » Sat Jul 23, 2016 8:33 am

Please note: This guide is depreciated. I will leave it here for archival reasons, but I will no longer be providing support for this shutdown solution

This guide explains how to build a very simple graceful shutdown circuit to your GameBoy Zero. It assumes you are using the Adafruit Powerboost 500C or 1000C.

Image Image Image Image
Note: Use opposite pairs of pins. This photograph shows both pairs on the same side of the switch. The DMG-01 switch has one pair on the left, and the other on the right.

If you'd prefer to buy a pre-made PCB, click here!

How it works:
Startup
  1. The JFET's default state is ON.
  2. The power switch is slid to the ON position.
  3. The EN/GND circuit is broken and the PowerBoost turns on.
  4. GPIO22 goes HIGH as the Pi boots.
  5. GPIO22 turns OFF the JFET, keeping the PowerBoost from shutting off.
Shutdown
  1. The power switch is slid to the OFF position.
  2. The 3.3v/GPIO27 connection is broken and a shutdown is signalled.
  3. GPIO22 goes LOW as the Pi shuts off.
  4. The JFET turns ON, closing the EN/GND circuit.
  5. The PowerBoost shuts off.
Shopping List:
  • 2N5460 P-Channel JFET Do not use Motorola JFETs. The brand I used is Vishay Siliconix. Check for this logo Image Thanks @RxBrad for identifying the logo!
  • 100K Resistor
  • DPDT Switch (optional)
Required for Low Battery Interface:
  • Diode (An 1N4148 will suffice)
  • ~500K Resistor
Things to note:
  • There are plenty other JFETs out there. I have tried several and read over datasheets for tonnes more. This is the only one I have found to have the correct values.
  • Although people have had problems with Fairchild JFETs, I have been able to replicate the circuit using the Fairchild 2N5460 by switching the Drain and Source pins.
  • Pin numbers used are BCM, not physical pin numbers. Get the Raspberry Pi pinout here.
Building the circuit:
[spoiler="Circuit Diagram"]Image[/spoiler]
JFET Pinout:
  1. Source > Ground
  2. Drain > Power Switch
  3. Gate > GPIO22
You can build this circuit any way you want. I used a piece of copper strip board and used epoxy to fix the switch to it. You can put your JFET anywhere, as long as your components are insulated from touching anything conductive. Be sure to check the pinout of the JFET before you start, as they are not all the same. Some have the gate on the middle pin, the 2N5460 does not.

Methodical wiring:
  1. JFET Source to Ground
  2. JFET Drain to switch pin 4
  3. JFET Gate to Keep Alive (GPIO22)
  4. 100K Resistor to Gate
  5. 100K Resistor to Source/Ground
  6. Switch pin 2 to Shutdown (GPIO27)
  7. Switch pin 3 to 3.3v
  8. Switch pin 4 to JFET Drain
  9. Switch pin 5 to EN
Troubleshooting:
If you are having trouble with the PowerBoost shutting off immediately, or kernel panic after shutdown, try the following.
  • Reverse the Source and Drain pins. That is to say the Drain is on Ground, and the Source is on switch pin 4. If you have a Fairchild JFET, this should work. This has also been reported to work with a J175 JFET.
  • Ensure the resistor is between the Gate and Ground.
  • Try a lower value resistor, such as 10K.
Below are some photos of the board I made. It's hard to see, but there is a resistor tucked away under the green/grey wires. Click to re-bigulate.

Image

Solder the EN and GND wires to the relevant pins on your PowerBoost. Connect the shutdown wire to GPIO27 and the keep alive wire to GPIO22.

Setting up the keep-alive pin
Once you've built the circuit, add the following line to /boot/config.txt. This will keep the JFET off while the Pi is powered.

Setting up the shutdown signal:
@Popcorn has a great power monitor script. Get the modified version here and install it on your Pi.

You're all set. Open the switch to power on the Pi. You can safely close the switch at any time. The Pi will safely shutdown before the JFET powers off the PowerBoost.

Low Battery Interface
If you'd like to interface with the LBO pin on your PowerBoost, you want the voltage to be at a safe level for the GPIO pin. Almost any switching diode will do the job and DO35 packaging will be easy to solder. I used a 1N4148 diode. The resistor should be at least 500K. Anything lower will cause the PowerBoost's low battery LED to illuminate.

You can include this circuit on the same board, it doesn't have to be separate. I drew a separate diagram to make sure it was easy to follow.

[spoiler="Circuit Diagram"]Image[/spoiler]

Thanks to:
@Popcorn for his GBZ-Power-Monitor
@Felix for his original suggestion of using a MOSFET instead of a relay.
@RazorX for prompting me to take another look at re-using the original switch.
@RxBrad for identifying the JFET brand logo.
Last edited by Camble on Wed Feb 08, 2017 5:23 am, edited 62 times in total.

User avatar
Ganreizu
Posts: 552
Joined: Thu May 05, 2016 8:20 am
Has thanked: 168 times
Been thanked: 97 times

Re: [Guide] Graceful shutdown switch without Pololu

Post by Ganreizu » Sat Jul 23, 2016 11:21 am

Where did you buy your mosfet? I don't immediately understand how to order some of those from what you linked to. :/ Though it seems you can only order them by the thousand lmao. Got extras to sell me?

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

Re: [Guide] Graceful shutdown switch without Pololu

Post by SidSilver » Sat Jul 23, 2016 11:40 am

Ganreizu wrote:Where did you buy your mosfet? I don't immediately understand how to order some of those from what you linked to. :/ Though it seems you can only order them by the thousand lmao. Got extras to sell me?
Look on EBay

User avatar
Ganreizu
Posts: 552
Joined: Thu May 05, 2016 8:20 am
Has thanked: 168 times
Been thanked: 97 times

Re: [Guide] Graceful shutdown switch without Pololu

Post by Ganreizu » Sat Jul 23, 2016 12:06 pm

Also where do the keep alive and shutdown wires go? Shutdown goes to the GPIO defined in that dtoverlay code i'm guessing.

Edit: Here's a link for the power switch for USA people (http://www.ebay.com/itm/10-Pcs-x-6mm-Hi ... SwqfNXiOQo)

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

Re: [Guide] Graceful shutdown switch without Pololu

Post by Camble » Sun Jul 24, 2016 6:26 am

@Ganreizu Sorry I overlooked that. The shutdown wire goes to GPIO27 and the keep alive goes to GPIO4 (the dtoverlay line)

I did just link the datasheet for the FET, since I'm in the UK my links will probably not be useful for the majority. eBay is a good starting point, as @SidSilver mentioned but once I'd found the correct part number, it was easy enough to find websites which stock them.

Regarding spares, I don't unfortunately. I'm still looking at costing PCBs. Not sure if it'll be cost effective but we shall see.

User avatar
Ganreizu
Posts: 552
Joined: Thu May 05, 2016 8:20 am
Has thanked: 168 times
Been thanked: 97 times

Re: [Guide] Graceful shutdown switch without Pololu

Post by Ganreizu » Sun Jul 24, 2016 11:25 am

PCBs would be unbelievable for this. Thank you for your work!

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

Re: [Guide] Graceful shutdown switch without Pololu

Post by Camble » Mon Jul 25, 2016 4:44 am

I've added an alternative circuit diagram for those who want to re-use the original switch. I hadn't considered this previously, but I'll be using it myself so I will update the guide when I'm done. The original switch definitely has a much nicer action than these cheap Chinese switches.

User avatar
Mischief
Posts: 225
Joined: Sat May 21, 2016 7:50 am
Location: Wolverhampton, UK
Has thanked: 29 times
Been thanked: 68 times

Re: [Guide] Graceful shutdown switch without Pololu

Post by Mischief » Mon Jul 25, 2016 5:46 am

Nice work, is there a way of using this with the low battery warning?

I'm good at soldering however not very good with circuit diagrams, any chance of a simple diagram that's easy for novices to read (will be using the DMG switch)?

Thanks
John

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

Re: [Guide] Graceful shutdown switch without Pololu

Post by Camble » Mon Jul 25, 2016 6:08 am

@Mischief I'm looking at low battery next and will probably be using the LBO pin on the PowerBoost.

You should be OK if you follow the photographs of the prototype board I made, but I'll look at drawing an easy to read diagram tonight.

User avatar
Mischief
Posts: 225
Joined: Sat May 21, 2016 7:50 am
Location: Wolverhampton, UK
Has thanked: 29 times
Been thanked: 68 times

Re: [Guide] Graceful shutdown switch without Pololu

Post by Mischief » Mon Jul 25, 2016 8:13 am

Camble wrote:@Mischief I'm looking at low battery next and will probably be using the LBO pin on the PowerBoost.

You should be OK if you follow the photographs of the prototype board I made, but I'll look at drawing an easy to read diagram tonight.
Thanks, i'm good with a picture representation never been able to get my head around proper diagrams lol. Will be buying the parts soon i'm glad it can be used with the original switch as I already have mine hot glued in place ;)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest