Author Topic: Raspberry Pi on/off toggle circuit design  (Read 4078 times)

0 Members and 1 Guest are viewing this topic.

Offline Racer_RobTopic starter

  • Newbie
  • Posts: 4
  • Country: gb
Raspberry Pi on/off toggle circuit design
« on: March 12, 2017, 12:45:41 pm »
Hello, I'm trying to design a circuit to turn a Raspberry Pi (RPi) on/off using a single toggle switch.

For those unfamiliar with the RPi, it'll turn on immediately power is supplied but shutdown must be initiated in the software by the user and the shutdown procedure must complete before power is disconnected.

The basic operating principle of my circuit is a follows:

Toggle switch closed:
  • The transistor activates and closes the 3V relay; the RPi powers up.
  • The capacitor is charged.
  • A RPi GPIO pin is held high. The voltage is set by the 20k/30k voltage divider

Toggle switch opened:
  • The GPIO pin immediately goes low. This triggers a script on the RPi to initiate shut down
  • The capacitor discharges, holding the transistor closed and the RPi powered long enough for shut down to be completed.

This is the first circuit I've truly designed from scratch so I'm looking for feedback on a few points, as well as any general comments:
  • Is the general operating principle sound?
  • Are any additional components needs for protection? (e.g. I included a flyback diode)
  • How do I select a model of transistor to use?
  • Should I use a polarized (electrolytic) capacitor?

Please keep in mind I'm an inexperienced (but very willing to learn hobbyist), so go easy! :)
 

Offline retrolefty

  • Super Contributor
  • ***
  • Posts: 1648
  • Country: us
  • measurement changes behavior
Re: Raspberry Pi on/off toggle circuit design
« Reply #1 on: March 12, 2017, 12:59:44 pm »
Quote
but shutdown must be initiated in the software by the user and the shutdown procedure must complete before power is disconnected.

 For the we (the few I guess) that don't do Pi, What is the reason for this? What if a unplanned power outage happens anyway?

Thanks
 

Offline fcb

  • Super Contributor
  • ***
  • Posts: 2117
  • Country: gb
  • Test instrument designer/G1YWC
    • Electron Plus
Re: Raspberry Pi on/off toggle circuit design
« Reply #2 on: March 12, 2017, 01:04:45 pm »
I've recently developed a product for a customer that uses RPI3 (against my advice) - we have no controlled shutdown procedures or anything vaguely like that - haven't had any problems in the field so far.
https://electron.plus Power Analysers, VI Signature Testers, Voltage References, Picoammeters, Curve Tracers.
 

Offline Racer_RobTopic starter

  • Newbie
  • Posts: 4
  • Country: gb
Re: Raspberry Pi on/off toggle circuit design
« Reply #3 on: March 12, 2017, 02:04:34 pm »
Quote
but shutdown must be initiated in the software by the user and the shutdown procedure must complete before power is disconnected.

 For the we (the few I guess) that don't do Pi, What is the reason for this? What if a unplanned power outage happens anyway?

Thanks


The RPi has an SD card which provides the initial storage for the Operating System and files, it's recommended in the documentation (see item 4) that the board is shutdown before powering off or the card may be corrupted. https://www.raspberrypi.org/documentation/installation/sd-cards.md

I've seen the advice repeated on numerous websites. How important it really is to follow it I don't know but I wanted to challenge myself to devise a solution anyway.
 

Offline tombi

  • Regular Contributor
  • *
  • Posts: 163
  • Country: au
Re: Raspberry Pi on/off toggle circuit design
« Reply #4 on: March 14, 2017, 03:34:58 pm »
I made something like this recently but rather than a fixed wait I got the Pi to notify the power control when shutdown is complete. Using the dt-overlay stuff you can choose a GPIO pin you want to go high when it shuts down and then you can use that to make your power control turn off the power.

Other ideas - use a P channel MOSFET instead of a relay. Also I used a two colour LED to indicate standby/on modes.

Tom
 

Offline lwatts666

  • Supporter
  • ****
  • Posts: 76
  • Country: au
Re: Raspberry Pi on/off toggle circuit design
« Reply #5 on: March 14, 2017, 09:51:12 pm »

Have a look at the URL Below. It seems to cover all the bases, but still requires software to complete the shutdown:

http://www.mosaic-industries.com/embedded-systems/microcontroller-projects/raspberry-pi/on-off-power-controller
 

Offline Racer_RobTopic starter

  • Newbie
  • Posts: 4
  • Country: gb
Re: Raspberry Pi on/off toggle circuit design
« Reply #6 on: March 18, 2017, 10:34:10 am »
Thanks for the suggestions folks, it looks like I've got a few things to work through but I'll post an update when I get there  :)

I like the idea of including an indicator LED. I'm not too familiar with MOSFETs and I imagine (other than perhaps cost and physical size) in this application there's no negative in sticking with the relay. I'll take a look at them anyway but I want to be able to walk before I run!
 

Offline Racer_RobTopic starter

  • Newbie
  • Posts: 4
  • Country: gb
Re: Raspberry Pi on/off toggle circuit design
« Reply #7 on: March 26, 2017, 11:31:05 am »
In the end I did include a P-channel MOSFET...

  • When the toggle switch is in the lower position power is supplied directly to the Raspberry Pi through the switch.
  • The UART TX pin of the Pi is high when the board is on and this, via the NPN transisitor, also allows power to be supplied through the P-channel MOSFET.
  • (Luckily I don't require the UART for this project)
  • When the toggle switch is switched to the off position, a GPIO pin on the Pi goes high, triggering the software to start shutting down.
  • Power continues to be supplied to the board via the MOSFET until the UART TX pin goes low which happens when the board has finished shutting down.
  • Power is then disconnected from the Pi.

I've tried this on a breadboard with a dummy load instead of the Pi and it seems to work ok. Can anyone see any flaws, additional protection I could add, areas to improve, general comments?
 

Offline LukeW

  • Frequent Contributor
  • **
  • Posts: 686
Re: Raspberry Pi on/off toggle circuit design
« Reply #8 on: March 27, 2017, 02:09:50 am »

http://www.mosaic-industries.com/embedded-systems/microcontroller-projects/raspberry-pi/on-off-power-controller

You'll find this interesting to read.

http://www.uugear.com/product/wittypi2/

This is an off the shelf product which does the sort of thing you're looking for - but I'm not sure if they provide schematics or anything like that.

 
The following users thanked this post: lwatts666

Offline tombi

  • Regular Contributor
  • *
  • Posts: 163
  • Country: au
Re: Raspberry Pi on/off toggle circuit design
« Reply #9 on: March 27, 2017, 02:14:14 pm »
I suggest putting it into LTSPICE. If you google a bit you can find models for the MOSFET.

Then you can check all your numbers including power dissipation.

Tom
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf