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 https://www.sudomod.com/forum/viewtopic ... 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 https://www.youtube.com/watch?v=bTmN9hY8rpo&t=537s. 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: 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
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.