[Guide] Graceful shutdown switch without Pololu [RETIRED]

Various user-contributed guides for hardware-related things
User avatar
HoolyHoo
Posts: 766
Joined: Sat Jul 09, 2016 9:34 pm
Has thanked: 206 times
Been thanked: 741 times

Re: [Guide] Graceful shutdown switch without Pololu

Post by HoolyHoo » Sun Sep 18, 2016 2:42 pm

Your getting the kernel panic because the circuit is not working and you have set the dtoverlay in config file.
With dtoverlay you are supposed to turn off the power yourself after gpio pin is set or in this circuit it does it with the jfet. It waits three seconds after shutdown initiated and if power is not cut you get that. Bottom line circuit is not working.
Last edited by HoolyHoo on Sun Sep 18, 2016 2:45 pm, edited 1 time in total.

User avatar
HoolyHoo
Posts: 766
Joined: Sat Jul 09, 2016 9:34 pm
Has thanked: 206 times
Been thanked: 741 times

Re: [Guide] Graceful shutdown switch without Pololu

Post by HoolyHoo » Sun Sep 18, 2016 2:43 pm

RxBrad wrote:@Camble @myPiZero

A couple times in this thread, I've seen mention of Python monitoring scripts and modifying Popcorns power monitor. Is Popcorn's script absolutely necessary? On the one of my setups that has the monitoring script installed, I thought I modified Popcorn's script as instructed, but now I wonder if I did it wrong. This seems to be the one point in the first post that's still kind of vague, and might be a source of a lot of people's problems....
Yes his script is necessary or pi will not know you have turned it off.

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

Re: [Guide] Graceful shutdown switch without Pololu

Post by Camble » Sun Sep 18, 2016 2:51 pm

@myPiZero You're right that the resistor probably doesn't need to be there for a JFET, but the circuit seems to be more stable with it there. It doesn't hurt to have a pull-up/down on the gate. Although it's mentioned as a resistor across the Gate/Source, it's really a pull-down to ground. The GPIO pin has an internal pull-up/down resistor anyway, but again, it doesn't hurt to have it.

@RxBrad Popcorn's script is necessary in order for the Pi to process the signal to shutdown. You do not need the script to have keep-alive signal from GPIO to the JFET. That is configured in /boot/config.txt

User avatar
RxBrad
Posts: 278
Joined: Fri Jul 22, 2016 9:10 am
Has thanked: 125 times
Been thanked: 160 times
Contact:

Re: [Guide] Graceful shutdown switch without Pololu

Post by RxBrad » Sun Sep 18, 2016 3:19 pm

Sigh... still no luck.. Since I'm new to Linux, let me lay out how I tried to handle the Popcorn script...

1. Successfully SSH'ed into my Pi Zero

2. Enter this command and wait for install to finish:

Code: Select all

cd ~;git clone https://github.com/NullCorn/GBZ-Power-Monitor.git
3. Edit the file by typing:

Code: Select all

sudo nano ~/GBZ-Power-Monitor/gbz_power_monitor.py


And then changing this:

Code: Select all

GPIO.setup(powerGPIO, GPIO.IN, pull_up_down=GPIO.PUD_UP)
...to this:

Code: Select all

GPIO.setup(powerGPIO, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
Ctrl-X, say Y to save changes to the default proposed filename.

4. EDIT: THIS WAS WRONG -- SEE BELOW ... Making it start on boot. First type:

Code: Select all

sudo nano /etc/rc.local
Before the "exit 0" line, add this:

Code: Select all

echo "@reboot     /usr/bin/nice -n 19 /usr/bin/python ~/GBZ-Power-Monitor/gbz_power_monitor.py" >> mycron; crontab mycron;rm mycron
Ctrl-X, say Y to save changes to the default proposed filename.

Then restart the Pi...
Last edited by RxBrad on Sun Sep 18, 2016 4:06 pm, edited 1 time in total.
Image
Image Image

User avatar
HoolyHoo
Posts: 766
Joined: Sat Jul 09, 2016 9:34 pm
Has thanked: 206 times
Been thanked: 741 times

Re: [Guide] Graceful shutdown switch without Pololu

Post by HoolyHoo » Sun Sep 18, 2016 3:26 pm

RxBrad wrote:Sigh... still no luck.. Since I'm new to Linux, let me lay out how I tried to handle the Popcorn script...

1. Successfully SSH'ed into my Pi Zero

2. Enter this command and wait for install to finish:

Code: Select all

cd ~;git clone https://github.com/NullCorn/GBZ-Power-Monitor.git
3. Edit the file by typing:

Code: Select all

sudo nano ~/GBZ-Power-Monitor/gbz_power_monitor.py


And then changing this:

Code: Select all

GPIO.setup(powerGPIO, GPIO.IN, pull_up_down=GPIO.PUD_UP)
...to this:

Code: Select all

GPIO.setup(powerGPIO, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
Ctrl-X, say Y to save changes to the default proposed filename.

4. Making it start on boot. First type:

Code: Select all

sudo nano /etc/rc.local
Before the "exit 0" line, add this:

Code: Select all

echo "@reboot     /usr/bin/nice -n 19 /usr/bin/python ~/GBZ-Power-Monitor/gbz_power_monitor.py" >> mycron; crontab mycron;rm mycron
Ctrl-X, say Y to save changes to the default proposed filename.

Then restart the Pi...
Do not do the line with "sudo nano /etc/rc.local". Just add the crontab line. If you already edited rc.local either erase or start over. The rc.local is one way of getting a python script to start on boot, crontab is another. Your trying to do both.

User avatar
RxBrad
Posts: 278
Joined: Fri Jul 22, 2016 9:10 am
Has thanked: 125 times
Been thanked: 160 times
Contact:

Re: [Guide] Graceful shutdown switch without Pololu

Post by RxBrad » Sun Sep 18, 2016 3:31 pm

@HoolyHoo Ah, so just type that last code as a command on the command line? I thought it was supposed to run that each time at startup, and local.rc was what I came up with after Googling....
Image
Image Image

User avatar
HoolyHoo
Posts: 766
Joined: Sat Jul 09, 2016 9:34 pm
Has thanked: 206 times
Been thanked: 741 times

Re: [Guide] Graceful shutdown switch without Pololu

Post by HoolyHoo » Sun Sep 18, 2016 3:38 pm

RxBrad wrote:@HoolyHoo Ah, so just type that last code as a command on the command line? I thought it was supposed to run that each time at startup, and local.rc was what I came up with after Googling....
Yes do everything as you said except the line with rc.local. I would start with fresh image to make sure. Also the crontab line is from the command line and is all in one command. That will write into crontab which will execute your script every time on boot.

User avatar
KrxXxiT
Posts: 25
Joined: Sat Jun 18, 2016 3:13 am
Location: Croatia
Has thanked: 27 times
Been thanked: 6 times

Re: [Guide] Graceful shutdown switch without Pololu

Post by KrxXxiT » Sun Sep 18, 2016 5:30 pm

Thanks @RxBrad for testing this out. For a moment I thought I was going nuts :roll:
I after all this I think the problem lies in @popcorn's script, as it wasn't designed to be used in conjunction with @Camble's circuit. When @Camble releases his script (he referred to it in a previous post) I'm sure this should work flawlessly. I hope @Camble can incorporate @popcorn's video warnings, that's one of the main reasons why I pursued this graceful shutdown method, as previously I was thinking to simply hook up a 7 segment display or something like those Lipo warning alarms they put on airsoft and rc car batteries to see when the voltage drops low enough to shutdown manually.
I bought a pololu and all to make @popcorn's because I liked the automated video warning method, then I stumbled across @Camble's method and decided to switch.
After a long day of tinkering, (and a bottle of wine to unwind) I need to sleep, it's 1:30am where I am and the misses wants me to give it a rest already. :D
Goodnight guys ;)

User avatar
RxBrad
Posts: 278
Joined: Fri Jul 22, 2016 9:10 am
Has thanked: 125 times
Been thanked: 160 times
Contact:

Re: [Guide] Graceful shutdown switch without Pololu

Post by RxBrad » Sun Sep 18, 2016 7:49 pm

So, after a fresh Retropie install on the latest 4.0.2 and correctly setting up Popcorn's script, I simply cannot get the switch working with a Fairchild FET on any of the 4 configurations. And I may have killed my SD card trying, as now it won't even get past the Retropie splash screen. Hopefully a reformat and reinstall will fix it...

For now, it's bedtime. I guess I'll just wait for the Vishay FET...
Image
Image Image

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

Re: [Guide] Graceful shutdown switch without Pololu

Post by Camble » Mon Sep 19, 2016 2:35 am

@KrxXxiT All I'll be doing is releasing a modified version of Popcorn's script for each of my shutdown boards. The videos and everything else will remain the same.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest