User avatar
Gerrelt
Posts: 291
Joined: Sat Nov 10, 2012 9:01 am

Re: on off switch

Tue Oct 08, 2013 6:27 pm

mahjongg wrote:
Gerrelt wrote: Look at TinyCore, that does exacty what you describe.
IMHO its not powering off the PI that destroys the card, so it has nothing to do with the OS, or in fact with any software, its actually the card itself that will damage its own flash filing system when you suddenly remove power while it happens to be writing to flash, or worse, shifting data around because of its "wear leveling" mechanisms. However if you can minimize the number of times data is actually written to the SD-card you can minimize the risk.
If I understood correctly, tinycore doesn't do any disk writes after booting (unless the backup command is given by yourself).
You can even take disk out after boot, see this quote:
The Tinycore's website wrote: What is the Tinycore boot architecture?

Tinycore always boots to ram. This unique way has several advantages, like 100% functioning usb boot, awesome speed, and being able to boot without having the ability to access the boot device after booting. You're free to snag out the usb drive right after initrd is loaded, for example.
See: http://tinycorelinux.net/faq.html#arch

I've tested it, after startup I took the SD card out of one of my Squeezelite running Raspberries. It kept on playing.
my Raspberry Pi page: http://raspberry.gerrelt.nl

AD^24
Posts: 1
Joined: Fri Nov 15, 2013 1:21 pm

Re: on off switch

Fri Nov 15, 2013 1:42 pm

ame wrote:I posted this already, but I think it's quite an elegant design.

http://www.mosaic-industries.com/embedd ... controller
This is exactly what I've been looking for!

This will allow me to safely kill all processes as well. Not exactly an electrical engineer, but I have done some soldering, and this one seems quite straight-forward.

On the software side, it's very simple as well; just create some script to listen on the GPIO4 and call 'sudo shutdown' or whatever, and another one that just pulls the same pin. Then add the scripts to start-up and shutdown with update-rc.d to allow everything to close gracefully.

Anyone in here actually done something similar? Would love to know what problems you might have encountered.

BAKBoord
Posts: 7
Joined: Tue Nov 19, 2013 7:05 pm

Re: on off switch

Wed Nov 20, 2013 9:16 am

I've built a power switch for the Pi my self. I was very charmed of the solution Madnico, because it powers off the adpter, preventing it from consuming energy from the grid. The solution of Ame was also very elegant, so I combined these designs. I started a topic with full explanation (under construction, will post the code tonight there).

On start-up I start a script to listen to the GPIO pin. On shutdown another script is run to pull the GPIO pin low and signla the switch to turn everything off (enough delay to let the Pi come to a gracefull standstill). The first try was to put the second in the \etc\rc0.d directory, but it was never run (even when registered properly). RaspBMC uses Upstart and appearantly igenores to rc0.d folder.

Anyways, I have rewritten the scripts to UpStart and the switch works like a charm. Will post the scipts tonight here.

User avatar
Keeze
Posts: 11
Joined: Sun Aug 18, 2013 2:23 pm
Location: Netherlands

Re: on off switch

Wed Dec 04, 2013 12:56 am

AD^24 wrote:Anyone in here actually done something similar? Would love to know what problems you might have encountered.
Yeah, made the switch for a headless squeezebox player.

The script first turns off the amplifier, then switches to runlevel 1. When entering runlevel 1 a script detaches the swap partition and remounts al the partitions in read-only. Then it pulls the signal pin low and the pi is turned off. Have it workling for 2 months now and never had a failing SD-card.

barnstorm3r
Posts: 1
Joined: Fri Mar 21, 2014 10:48 pm

Re: on off switch

Fri Mar 21, 2014 10:50 pm


interfan6
Posts: 3
Joined: Sun Apr 27, 2014 1:46 pm

Re: on off switch

Sun Apr 27, 2014 1:49 pm

I got a switch with 3 legs, do i need a switch with 6 legs (both sides) to connect it or i can do it 3 ??
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 ).

neilf
Posts: 72
Joined: Sun Nov 11, 2012 8:14 am

Re: on off switch

Sun Apr 27, 2014 4:48 pm

interfan6 wrote:I got a switch with 3 legs, do i need a switch with 6 legs (both sides) to connect it or i can do it 3 ??
Electrically, a single-pole, double-throw switch (3 pins) will suffice, but mechanically you need the other three pins of a double pole switch to anchor it securely. That's if you're going to straddle the edge of the board, as I did.

interfan6
Posts: 3
Joined: Sun Apr 27, 2014 1:46 pm

Re: on off switch

Wed May 07, 2014 12:57 pm

Ok i manage to do it but for what is the red wire you use ? i didnt use it cause with it wouldnt work?
can you explain to me ?
neilf wrote:
interfan6 wrote:I got a switch with 3 legs, do i need a switch with 6 legs (both sides) to connect it or i can do it 3 ??
Electrically, a single-pole, double-throw switch (3 pins) will suffice, but mechanically you need the other three pins of a double pole switch to anchor it securely. That's if you're going to straddle the edge of the board, as I did.

neilf
Posts: 72
Joined: Sun Nov 11, 2012 8:14 am

Re: on off switch

Wed May 07, 2014 7:49 pm

interfan6 wrote:Ok i manage to do it but for what is the red wire you use ? i didnt use it cause with it wouldnt work?
can you explain to me ?
There's a cut in the track just above where the red wire is soldered. The switch bridges this gap and makes or breaks the circuit.

interfan6
Posts: 3
Joined: Sun Apr 27, 2014 1:46 pm

Re: on off switch

Thu May 08, 2014 8:03 am

Ok, its working but i didnt soldered that. I soldered it to the capacitor and to the end of the green thing.( i guess this is some kind of fuse). But when i solder the red wire there is no power at all, no matter the state of the switch - the power indicator has no light. Is it a problem not using it - electrical point of view?
neilf wrote: There's a cut in the track just above where the red wire is soldered. The switch bridges this gap and makes or breaks the circuit.

User avatar
Jufo
Posts: 25
Joined: Fri May 23, 2014 11:49 am
Location: Warsaw, Poland
Contact: Website

Re: on off switch

Mon Jun 16, 2014 6:26 am

ame wrote:I posted this already, but I think it's quite an elegant design.

http://www.mosaic-industries.com/embedd ... controller
I would like to make a similar circuit, maybe you know a replacement for the IRF7319 (SMD - Surface Mounted Devices) version of DIP (THT - Through-Hole Technology) ?
Best Regards
Robert

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

Re: on off switch

Mon Jun 16, 2014 7:04 am

Jufo wrote:
ame wrote:I posted this already, but I think it's quite an elegant design.

http://www.mosaic-industries.com/embedd ... controller
I would like to make a similar circuit, maybe you know a replacement for the IRF7319 (SMD - Surface Mounted Devices) version of DIP (THT - Through-Hole Technology) ?
Sorry, I don't. But, I have found that using SMD parts is not too difficult. You can do several things to make the SMD parts compatible with a through-hole design.

e.g.
* glue the SMD part onto a turned-pin DIP IC socket and solder thin wires from the IC pin sockets to the SMD part.
* glue the SMD part to your circuit board and do the same
* get an SMD carrier board like this https://www.futurlec.com/SMD_Adapters.shtml

Or you could make your own PCB. That's pretty easy too these days. I have used the toner transfer method, and hydrochloric acid + hydrogen peroxide for etching, but I have read it can be done with salt and vinegar too (takes a little longer).


User avatar
Jufo
Posts: 25
Joined: Fri May 23, 2014 11:49 am
Location: Warsaw, Poland
Contact: Website

Re: on off switch

Mon Oct 20, 2014 11:24 am

How to isolate (use optoisolator) the GPIO4 (PIN7) from the output of the IRF7319? (for security Raspberry PI):
http://www.mosaic-industries.com/embedd ... controller
Best Regards
Robert

electrfunch
Posts: 2
Joined: Tue Nov 04, 2014 9:44 pm

Re: on off switch

Tue Nov 04, 2014 9:46 pm

I use the https://www.yepkit.com/products/ykrud

Just an important disclaimer: I currently work at Yepkit.

User avatar
eddieddieddie
Posts: 3
Joined: Tue Jul 02, 2013 5:58 am
Location: New Zealand

Re: on off switch

Sun Dec 07, 2014 7:56 am

Another design for a module to control shutting down/powering off in an orderly way when the 'power' button is pressed: http://www.instructables.com/id/Raspber ... wn-Button/.

I've not actually tried it yet but it looks like a goer, and I like the use of a relay to handle the switching - you could run other peripherals through this also (i.e. powered USB hub) so they all go off when you turn off the Pi. My only concern with this is what happens if you power off from the OS - it doesn't look like this circuit will pick this up and go into power-off state (I think).

Plus it does seem a bit weird haven't another micro-controller just to handling turning it off - but maybe that's just me!

User avatar
Richard-TX
Posts: 1545
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: on off switch

Mon Dec 08, 2014 7:29 am

Joe Schmoe wrote:I wish to point out (again!) two salient facts:

1) If an on/off switch were really necessary, it'd have been included in the base hardware. This is pretty standard accepted fact in all things relating to computer hardware.

2) The need for an on-off switch is looking at the wrong end of the problem. What we need (and which I sincerely believe is possible; I'm a little surprised that no one has taken up my suggestion to implement and publicize a solution) is a version of the OS that doesn't self-destruct when power is removed. Basically, this would be done by making the OS read-only and/or in RAM.
I have been removing power without issuing a shutdown or powerdown on all my Rpis for almost 2 years and have never encountered a problem when using Toshiba SD cards. One pi is turned on and off via a few times every single day. I use premium SD cards made by Toshiba. I tried cheap cards and they don't last. Conclusion? The issue isn't the Rpi or the OS but crummy SD cards . There are times when you get exactly what you pay for. SD cards is one of those items.

If you are experiencing file system corruption when removing power, I would try adding a sync() to your app after it writes to a file.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: on off switch

Mon Dec 08, 2014 8:10 am

I have been removing power without issuing a shutdown or powerdown on all my Rpis for almost 2 years and have never encountered a problem when using Toshiba SD cards. One pi is turned on and off via a few times every single day.
+1 on that. Just to be clear, I've never had a corruption problem either (knock word, and all that…).

Although:
  • 1) I don't do it (turn off power w/o shutting down) very often. Not like you, anyway...
    2) I don't know what brand (or, more importantly, what maker) of SD card I'm using. But I don't buy super-cheap stuff, in any case.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

User avatar
Gert van Loo
Posts: 2433
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: on off switch

Mon Dec 08, 2014 8:32 am

Switching power off without shutting down CAN upset your SD-card
It has happened about three times to me in the years and each time it took me quite some time to get back where I was.**
So I always try to shut-down beforehand.
Unfortunately that is not always possible, especially if the image did not see the HDMI on start-up.
Nowadays I try to remember to enable SSH and force HDMI on but I sometimes forget. (getting old!)
I use a mix of different SD-cards, but most are Sandisk (at least that is what they SAY they are....)

**I now install FTP and use Filezilla to make regular copies of the most actual data.
A shame FTP is not default installed. It is a lot more useful then all the other <censored> which comes with the default image.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: on off switch

Mon Dec 08, 2014 8:41 am

A shame FTP is not default installed. It is a lot more useful then all the other <censored> which comes with the default image.
+1 on that. But isn't the current "thinking" that both "ftp" and "telnet" are "obsolete"?

Obsoleted by ssh (and friends)…?
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

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

Re: on off switch

Fri Mar 20, 2015 2:26 pm

Hi guys i built this switch http://www.mosaic-industries.com/embedd ... controller but i have problems with it, each time i connect cable Pi automaticly goes on without even pressing the button, stays on for like 5 sec and then goes off, and repeats the process in loop. Anyone knows what the problem might be? Did i have to write some kind of software to configure pin 7 or something? Im kinda noob at pi so i would appreciate if you could help me with this issue.

Here are my project schematic http://prntscr.com/6j3ka9 and board http://prntscr.com/6j3k18

Cybergei
Posts: 5
Joined: Fri Mar 20, 2015 5:23 pm

Re: on off switch

Fri Mar 20, 2015 5:45 pm

Most users are right, an abrupt shutdown will kill your SDCard. There is no real way to do it accept to use one of two options:

ATX Raspi - which will perfectly serve the purpose you want
or You will need two separate buttons. On a switch to connect the power and keep it connected. Two a button connected to a pin which is monitor for High/Low and executes a graceful shutdown script.

Damage is your main issue.

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

Re: on off switch

Sat Mar 21, 2015 3:53 am

There is an error in your schematic. Compare yours to the original and you will see it. If you can't, I'll tell you later. I'm on a train right now.

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

Re: on off switch

Sat Mar 21, 2015 11:02 am

Omg you mean pin 4 of jumper should go on c1 instead directly od D1? Omg im such an idiot :D Is there any other errors you see? ill try to fix that, powering on and off was due to bad adapter i fixed that now it just comes on if jumper is on auto on position and i guess i should write shutdown routine. Can anyone help with that, since i dont know how to code this part:

When the Raspberry Pi is first powered up, GPIO 4 is automatically configured as an input with passive pull-up. That is the behavior we want, so you don't need to do anything to guarantee it. Subsequently, the application program should do the following:
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.
Setting the output low resets the MOSFET switches to their OFF state after several seconds, turning OFF your Raspberry Pi.

Thanks btw ;)

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

Re: on off switch

Sat Mar 21, 2015 4:05 pm

This is my corrected scheme, now it powers on normally but shuts down after 3 seconds, you have any idea why?
http://prntscr.com/6jj85h

P.s. Red line means i cut that part out and i added another connection (green line)

Return to “Cases”

Who is online

Users browsing this forum: No registered users and 3 guests