ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: on off switch

Sat Mar 21, 2015 11:40 pm

Hi there,

I am still travelling, so I can't easily study schematics on my tiny phone screen. However, I suggest you remove the wire to the Pi GPIO. The circuit works in conjunction with a program on the Pi, which you don't have yet.

The program monitors the GPIO to look for a button press (meaning "I want to shut down). Then it starts the shutdown process and finally cuts the power.

Without the GPIO connection it ought to start up with a short press and power down with a long press. Those functions are contained in the circuit and are independent of the GPIO.

That's my guess anyway.

paulv
Posts: 525
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands

Re: on off switch

Sun Mar 22, 2015 2:41 am

Good and simple to build solution!

If you want to completely automate the starting and stopping, or have a standalone (embedded) application, have a look here: http://www.raspberrypi.org/forums/viewt ... 08#p714308

h4z4rD
Posts: 6
Joined: Fri Mar 20, 2015 2:18 pm

Re: on off switch

Sun Mar 22, 2015 9:05 am

ame wrote:Hi there,

I am still travelling, so I can't easily study schematics on my tiny phone screen. However, I suggest you remove the wire to the Pi GPIO. The circuit works in conjunction with a program on the Pi, which you don't have yet.

The program monitors the GPIO to look for a button press (meaning "I want to shut down). Then it starts the shutdown process and finally cuts the power.

Without the GPIO connection it ought to start up with a short press and power down with a long press. Those functions are contained in the circuit and are independent of the GPIO.

That's my guess anyway.
And you are right again, now power on and hold for off work normally, i just gotta find a way to write a program. if any of you guys know where i can find code from someone who allready got it to work please share.

Kind regards and thanks a bunch :)

User avatar
Burngate
Posts: 5000
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK
Contact: Website

Re: on off switch

Sun Mar 22, 2015 10:33 am

Not sure I fully understand the situation (just had a quick look) but the original circuit uses IRF7319, which has an N-channel and a P-channel fet. You appear to be using IRF8313, which has two N-channel fets.
Without going into it too deeply, my thought is that you can't swap N- & P-channel fets willy-nilly and expect it to still work.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: on off switch

Mon Mar 23, 2015 1:13 am

h4z4rD wrote:
ame wrote:Hi there,

I am still travelling, so I can't easily study schematics on my tiny phone screen. However, I suggest you remove the wire to the Pi GPIO. The circuit works in conjunction with a program on the Pi, which you don't have yet.

The program monitors the GPIO to look for a button press (meaning "I want to shut down). Then it starts the shutdown process and finally cuts the power.

Without the GPIO connection it ought to start up with a short press and power down with a long press. Those functions are contained in the circuit and are independent of the GPIO.

That's my guess anyway.
And you are right again, now power on and hold for off work normally, i just gotta find a way to write a program. if any of you guys know where i can find code from someone who allready got it to work please share.

Kind regards and thanks a bunch :)
So, probably you have something driving that GPIO low (a program, or driver, or some default situation), or maybe it is due to your choice of IRF8313. According to the documentation, when the Pi drives the GPIO low the circuit will cut the power after a few seconds. You can test this by connecting the wire that would go to the GPIO to ground instead (after a few seconds the power will be cut). You need to write a program that will perform the tasks described in the documentation.

Specifically:
  • It should configure GPIO 4 to call an interrupt service routine when it sees a falling edge or an input low.
  • The interrupt service routine should initiate a shut-down of the any applications running and whatever I/O they use.
  • Once the applications have been shut-down safely, your program should reconfigure GPIO 4 as an output and set it low.
If you are lucky, someone else has written something that does this specifically for this circuit. Or written something similar that you can adapt.

If not, it is left as an exercise for the reader.

h4z4rD
Posts: 6
Joined: Fri Mar 20, 2015 2:18 pm

Re: on off switch

Sat Mar 28, 2015 9:13 pm

Hi guys, an update.
First, i wasnt using IRF8313 i just selected it for the schematic. In the real build I used the original part. Second i managed to find a script that works, credit to MrLeeh ( http://www.instructables.com/id/Raspber ... wn-script/ ). Now when i press once while its off it boots on, when i press once while its on it shuts down, and 5 sec shutdown cutting power. Only problem is when it shuts down via script power does not go off when pi is safely shut down, just stands there with the red light (meaning it is safe to power off). I just gotta figure that one out and its done ;) If anybody has any suggestions it would be helpfull, for now it looks i gotta find a way to write the code that drives gpio4 output low before doing shutdown sequence so it will turn off after rpi has shut down safely...

Kind regards

P.s. another question, is this script eating alot of processor power becouse of constant loop, and if it is how can i lower it?

randallsussex
Posts: 13
Joined: Thu Oct 10, 2013 5:13 pm

Re: on off switch

Fri Apr 10, 2015 8:56 pm

I have been looking for a inline USB power switch that is computer controlled for my solar powered raspberry pi projects. My problem is not so much turning off, but getting the Raspberry Pi turning back on only when the battery is sufficiently charged.

I found this: http://www.switchdoc.com/usb-powercontrol-board/

It has a control line that you can turn on and off with a GPIO, a controller board, another computer or connected straight to a LiPo battery. They implemented hysteresis so it turns off about 3.4V and won't turn back on until 3.9V.

Works for me perfectly. Now I don't have that "brown out" condition that kills Raspberry Pi SD cards with constant reboots as the battery recovers.

It's just off a successful kickstarter (I got in on it right before the close) and they have it for sale now on Amazon and Tindie.

Randall

oube
Posts: 4
Joined: Sun May 24, 2015 7:04 am

Re: on off switch

Sun May 24, 2015 7:09 am

neilf wrote:
SirLagz wrote: I like that, nice and easy.
I'm assuming you had to cut something to make it do that ?
Yes, you have to cut one track. Rather, you have to scrape gently until you scratch just through the track and then stop. It's a multi-layer board so you have to proceed carefully, but it's not difficult if you're used to hacking micro boards.

You can just see the cut at the end of the red cable if you view the first shot full size. I did four of these switched boards - they take about an hour each to complete - and the resultant ease and convenience has been well worth it.
Do you have a youtube video on how you cut the track, the tool you used to scrape and pretty much how you did it?

ingridrvma
Posts: 1
Joined: Fri Aug 21, 2015 4:27 am

Re: on off switch

Fri Aug 21, 2015 4:31 am

neilf wrote:I added an onboard miniature on/off switch to all my boards as soon as I got them a year ago. There was no need for a cutout in the case as I mount my Pis in wafer cases so that I can get at all the GPIOs.

I couldn't imagine using a Pi without an on/off switch now - it's so convenient. Mind you, I mostly run RISC OS which is very easy and quick to shut down (two clicks :D ).
Sorry for the very noob question, but how can this be adapted for the Raspberry Pi 2? What are the parts / pieces needed?
Thank you!

ayhlai
Posts: 2
Joined: Tue Dec 27, 2016 9:15 am

Re: on off switch

Tue Dec 27, 2016 9:32 am

Hello all!

I have just posted my own implementation of raspberry pi power switch using digispark attiny85 in codeproject. Hope you all like it!

https://www.codeproject.com/Tips/110598 ... gispark-At


A demo video can be found here:

https://www.youtube.com/watch?v=uzu2XiQ ... e=youtu.be

ayhlai
Posts: 2
Joined: Tue Dec 27, 2016 9:15 am

Re: on off switch

Tue Feb 14, 2017 6:07 pm

Hi All,

I have posted my implementation of the Pi Switch with remote control to kickstarter if anyone is interested :D

Here the link:

https://www.kickstarter.com/projects/14 ... reator_nav

thanks!

pa5ca
Posts: 6
Joined: Tue Dec 13, 2016 2:12 pm

Re: on off switch

Wed Sep 06, 2017 9:36 am

Hi Guy's I have build the http://www.mosaic-industries.com/embedd ... controller
It works okay but can some one help me with a python script to let the described switch works as it supposed to do. Meaning It set the GPIO 4 as output while shutting down the power to my PI.
I'm pretty new here.. :roll:

Looking forward to the possible replies..

Yours

Frans...

awillame
Posts: 24
Joined: Tue Jun 14, 2016 4:56 pm
Location: Montreal, QC, Canada
Contact: Website

Re: on off switch

Sun Oct 29, 2017 11:19 pm

Altough this is not a power switch but a power button, this case have a button that you can connect to any pin of the Pi, whether the hard reset pins, or GPIOs like in this tutorial, to shut down smoothly the Pi.
Aluminum case for Raspberry Pi 3:
https://www.raspberrypi.org/forums/viewtopic.php?t=158301

User avatar
scruss
Posts: 1357
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: on off switch

Mon Oct 30, 2017 12:26 am

If we're going to keep this very old thread alive:
  1. I made a little combined reboot/shutdown button service, and drive it from a cheap surplus ATX power button. @Raspberry_Pi retweeted my announcement last weekend, and my server got hammered. Writeup here: Combined Restart / Shutdown Button for Raspberry Pi
  2. Pimoroni makes the very nice OnOff SHIM. Here's mine installed on a Zero W:
    shim.jpg
    OnOff SHIM
    shim.jpg (17.62 KiB) Viewed 431 times
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

Return to “Cases”

Who is online

Users browsing this forum: No registered users and 4 guests