My Safe Shutdown Solution - Pololu and Logic Chip

Having trouble with your GBZ build? Ask your questions here!
Post Reply
Posts: 27
Joined: Sat Dec 29, 2018 8:21 pm
Been thanked: 7 times

My Safe Shutdown Solution - Pololu and Logic Chip

Post by 3kidsinaustin » Sun Feb 24, 2019 3:14 pm

[NOTE] If anyone can provide direction on how to flip these pictures so they appear upright, please let me know!

The Gameboy I built is intended to be a birthday gift for my daughter, turning 8. As I was building the project in my mind, one of the things I became acutely aware of was the danger of her not safely shutting the unit down through the RetroPie menu, then turning off the power switch. I went round and round with what would be the best method to insure the Raspberry Pi was safely turned off each time. That took a lot of research!

There are some great posts I used as a start for this circuit, the one I relied most heavily on was ... t=shutdown. @Camble had created a production version of a similar circuit, but by the time I was starting my build, he had sold out his stock for the Banggood power supply edition and was not ready to replenish. Of note, I had already committed to using the generic power supply to charge my battery and run the unit. So, had to strike out on my own.

Fortunately, I stumbled across a YouTube video done by someone putting a Pi into a Game Gear. He had devised a solution that looked very doable and was based on a Pololu switch, which I had already purchased. Link to the video is here He starts going into detail at 4:30 into the video. His circuit became the basis for what I built for my GBZ.

Here is a drawing of the circuit I used to build the circuit:
2019-02-24 14.28.05.jpg
Diagram of Circuit
2019-02-24 14.28.05.jpg (2.82 MiB) Viewed 802 times
I used a Pololu #2810 which has the slider switch. In the video by 16bitbench he used the Pololu model that has a momentary switch versus a slider. Another note, as you see in the top left I included a voltage regulator in the drawing. This is not used for the GBZ as the power supply provides a steady +5v. I added in the 9v and voltage regulator into the drawing because I am also modifying a portable DVD player to include a Raspberry Pi and RetroPie with two controllers for my twin boys.

The logic chip I used is a 74HC02 and the wiring is detailed in the lower left-hand part of the drawing. It is a NOR logic gate and pretty cheap to get. The main power switch is represented by the switch in my “schematic” between the Pololu and the 74HC02. Everything else should hopefully be fairly self-explanatory.

I used a 560uf capacitor because I had several on-hand from another project. The resistor between the Raspberry Pi GPIO 16 and the 74HC02 was a bit of trial and error as I wanted to make sure the circuit had enough current to power the Pi until it was safely shutdown, then kill all the power. The 20k ohm resistor did the trick.

Brief summary of the circuit: The Pololu switch and 74HC02 are powered all the time by the battery. I believe current draw is nominal. When the main power switch is turned on, current flows into the 74HC02 which in turn sends a +5v signal to the control pin on the Pololu switch (through pin 3B). When the ON pin receives +5v, the Pololu turns on the power to the connected devices – in this case the Raspberry Pi (I also attached my display monitor to the other output so I could verify the shutdown process). Once the RPi is on, it begins charging the capacitor through GPIO 16. To enable this feature, the following needs to be entered into the config.txt file:

Code: Select all

This will turn board pin 16 (GPIO 23) to HIGH while the RPi is on, LOW when it is off.

The other interaction between the circuit and the RPi is through board pin 18 (GPIO 24). When this pin receives a HIGH signal, the Pi begins the shutdown process. Current stops flowing from pin 16 shortly into the shutdown process. The capacitor begins to discharge, keeping the logic circuit open and sending a HIGH signal to the ON pin of the Pololu switch, which keeps power safely flowing to the Pi while it goes through the shutdown process. Eventually, the capacitor discharges enough that the signal goes LOW to the ON pin of the Pololu, which then turns off the power flowing to the Pi.

Building the unit was fairly simple. I strove to make the circuit into as small a footprint as possible. Even so, it still ended up seeming HUGE as I was placing all the components into the shell. The big footprint was the capacitor. The 560uf is big in diameter and set the overall height of the overall height of the circuit. Since it was setting the height, I felt I had space to use a socket for the logic chip, making it easier to solder to the board and allowing me to swap it out if anything shorted it out. In hindsight, might be good to attempt to solder it directly to the board and take a chance, plus use some wires to move the capacitor to an empty space.

Cost was pretty cheap. I already had the capacitors and resistors, but figure a couple of bucks if you source from AliExpress. The Pololu switch was $3.49 apiece plus shipping and handling. I ordered three for a future projects and to help defray the shipping cost. The 74HC02 logic chips were $3.00 (including shipping) for a package of 5. Whole thing could be built for $10 or so. A real evolution would be making a printed circuit board and integrating the vital parts of the Pololu switch, plus using surface mount components to shrink the size. That might have been what @Camble did with his circuit?

Any questions, I'll do my best to answer. I should have done this writeup closer to after I built the circuit. Had to refresh my memory in a bunch of places!

Again, sorry about the upside-down pictures.
Shutdown Rear.jpg
Backside of the circuit board
Shutdown Rear.jpg (837 KiB) Viewed 802 times
Shutdown Front.jpg
View of components without logic chip inserted into socket
Shutdown Front.jpg (768.49 KiB) Viewed 802 times
Shutdown Dimensions.jpg
Shutdown Dimensions.jpg (691.44 KiB) Viewed 802 times
First Build Done! viewtopic.php?f=43&t=7444

User avatar
Posts: 2878
Joined: Thu May 05, 2016 8:33 am
Location: Rogers, AR
Has thanked: 1433 times
Been thanked: 3093 times

Re: My Safe Shutdown Solution - Pololu and Logic Chip

Post by Helder » Sun Feb 24, 2019 11:27 pm

So this uses a slide switch or momentary tactile button? Have you tried other value caps? You could get a low profile 470uf electrolytic or tantalum if that would work in the circuit.
My Sale Threads:

Retro PSU, 3.5A output!

Chat with me and other members

Don't contact me about obtaining my board files (as you will not get them). Don't contact me about any of my boards if they are sold out, they will be restocked as soon as I can get them.

Don't support thieves like ckliang who copied my AIO to resell and is now cloning the mintyPi, support the original creators and not the thieves!

Posts: 219
Joined: Tue Jan 31, 2017 11:06 am
Location: Tianjin / China
Has thanked: 23 times
Been thanked: 51 times

Re: My Safe Shutdown Solution - Pololu and Logic Chip

Post by McGyver » Mon Feb 25, 2019 12:01 am

Or more smaller caps in parallel to minimize hight.
As well for the integrated circuit if helpfull: To minimize hight you could use it without socket. Bent the IC pins by 90degrees to outside and solder them direct to the cupper side of your board.

Posts: 27
Joined: Sat Dec 29, 2018 8:21 pm
Been thanked: 7 times

Re: My Safe Shutdown Solution - Pololu and Logic Chip

Post by 3kidsinaustin » Mon Feb 25, 2019 5:33 am

I used the slide version, but I believe the tactile button can work as well. The slider stays in the OFF position, then when you send 5v to the ON pin, the Pololu turns on the attached components. When voltage removed, it turns the components off.

Great ideas on the caps. I used what I had on hand, thinking I would have plenty of room at the end. I ended up relocating some components on the USB hub and was able to close the case.
First Build Done! viewtopic.php?f=43&t=7444

User avatar
Posts: 272
Joined: Fri Jul 22, 2016 9:10 am
Has thanked: 121 times
Been thanked: 158 times

Re: My Safe Shutdown Solution - Pololu and Logic Chip

Post by RxBrad » Mon Feb 25, 2019 6:45 am

This is the one thing we're a bit short on in this community: standalone safe shutdown solutions for slide switches. Thanks for this!

I might need to give this a try when I eventually build another GBZ.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest