piBeacon: 10- battery backup- safe shutdown

Posted on
Fri Jul 01, 2016 10:16 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

piBeacon: 10- battery backup- safe shutdown

I would like to come up with a setup that shuts the rPi down in a safe way and also protects the rPi SSD from sudden powerloss

attached my first try to setup a soft shutdown for a rPi

States:

1. power supply on right is on and +5V goes to rPi 5V in
trickle charge to battery through R3 (220Ohm) ~ 3mA (to be adjusted)
Buck is idle as the diode voltage D3 is < 0.6V = off (5.5 --> 5V when regular power is on), no current flows through diode D3

2. power goes off:
relay on right goes off
buck supplies 5.5V-0.65 = 4.85 V to rPi (must be > 4.75V). The capacitor > 100uF helps to remove any spikes up/down
Pin x goes to low and triggers program on rPi to issue sudo shutdown -h now command
Buck/ battery supplies power until rPi is shut down
Pin-Y --> TXD GPIO pin goes to low after shut down, switches relay on left off. .. power to rPi goes off
all power is off

3. push button Pin-X to ground for >2 seconds starts a sudo shutdown -h now process
pin-Y --> TXD GPIO goes to 0, shuts down Battery relay.
power still on.

4. restart through second switch "RUN-GROUND" pins starts the system after regular shutdown to system halt.


Any comments form interested parties?

Karl

remarks:
the 2 round boxes are the components from a saint smart dual relay switch board.
The right relay has all parts besides the relay and the reverse voltage diode removed.
The opto coupler and transistor etc are all on the SainSmart board.
We need to add few components to a dual saint smart relay board (2 diodes, 3 resistors, 1 capacitor, a BUCK, NiMH batteries, a shutdown and start moment switch+ some cables
Normally the opto-coupler has an open input (lower part). Here we connect it to ground so that it is on as default. The connection between the led and the optocoupler has to be added. Its voltage is max 2.2V and it can draw max 3mA (R1 ~ 1kOhm, R2=510Ohm) If pin-Y goes to 0 the opt-coupler is off and the relay goes off

R3=220Ohm
R4=2KOhm
R5= 3KOhm
battery= 3* 1.2V NiMH AA cells
buck = step up Voltage converter that operates > 3.5 V input and can deliver 1.5Amps & 5-6 V

relay states shown are power off states.

TXD GPIO goes to 0 after regular software issued shutdown. That is a designed feature of the rPi
Attachments
Screen Shot 2016-07-01 at 22.47.22.png
Screen Shot 2016-07-01 at 22.47.22.png (57.35 KiB) Viewed 2208 times

Posted on
Sat Jul 02, 2016 7:16 am
johnpolasek offline
Posts: 911
Joined: Aug 05, 2011
Location: Aggieland, Texas

Re: piBeacon: battery backup- shutdown

Wouldn't adding 1 more Battery in place of the BUCK and diode be easier? or is the 4.8 nominal too close to the 4.75 min to be safe?

Posted on
Sat Jul 02, 2016 8:06 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: battery backup- shutdown

YES, ...
the voltage of a NiMH can go below 1.2V. We must use a diode between battery and rPi, otherwise the current goes the wrong way..Then we need not 4 but 5 NiMH : it is then 6.0-0.65= 5.35 V that a little bit too high and the voltage of a NiMH can also go higher than 1.2.

I guess we need some form of voltage regulator... Initially I wanted to use a single cell, but the BUCKs don't work with 1.x Volt, or at least I have not found one, the lowest Vin I found is 3.3V --> 3 cells

There are many options.. I now have all the parts and will play around with it this weekend.


Karl

Posted on
Sat Jul 02, 2016 5:17 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: battery backup- shutdown

This one actually works.

I had to redesign the right part. There was a logical flaw in it.

here how it works:

1. power on right part delivers power to the Rpi, left part is idle, as the output voltage is smaller than the one from the right. But the relay is on and delivers the idle current for the left BUCK. (~ 10mA) and a trickle charge to the NiMH battery ~ 2.. 15 mA (3xAA) depending on charge level

2. when power(right goes off) TX-gpio goes low and triggers python pin listener program (after 2 secs wait) and issues "sudo shutdown -h now"
when rPi is down the TD-gpio pin goes low and switches off the left relay

3. when power comes back right part delivers power and after restart the left relay goes on and the battery is on standby again.

THIS ACTUALLY WORKS.

The BUCKS have to be well selected. the left one must have a low idles current ~ 8-10 mA, the right one just has to be able to deliver the power for the rPi.


Karl,

will post the BUCKS used once I have this running for some days.
Attachments
Screen Shot 2016-07-03 at 15.55.22.png
Screen Shot 2016-07-03 at 15.55.22.png (67.04 KiB) Viewed 2048 times

Posted on
Sun Jul 03, 2016 11:29 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

piBeacon: battery backup- safe shutdown

New version:

tuned: # of seconds to stay up after shut down,
a little bit simplified

In the software there are 2 pins defined, to be released in 2 days:

1.)shut-down-input-pin: triggers shut down if pressed for > x seconds
2.)shut-down-output-pin: is set high after start. That will close the relay. When the rPi shuts down, that pin goes off and supplies no more current into the transistor. The resistor. After the capacitor is empty the transistors shuts off and hence the relay and the battery is disconnected form the left BUCK. Otherwise it would get depleted from the idle current into the buck.

The next thing I am looking into are the resistors R3 and R6:
-R3 must accommodate the idle current into the buck so that the battery is not depleted.
-R6 should be just enough to keep the NiMH trickle charged.

If any one is interested, let me know.

Karl


total ~$ 25-35 about the same as the Rpi

One other advantage you can use any power supply 4-10 V: 10 V ~ 1 Amp, 5 V 2 Amp, thats the magic of the BUCKs (Watt =V*A stays constant - overhead )
Attachments
Screen Shot 2016-07-04 at 23.42.17.png
Screen Shot 2016-07-04 at 23.42.17.png (101.39 KiB) Viewed 1985 times

Posted on
Wed Jul 06, 2016 12:14 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: battery backup- safe shutdown

List of tested BUCKs (all purchased from amazon)

1. DROK® DC-DC3.5-28V to1.25-26V LM2596 & LM2577 Boost/Buck Voltage Converter Step Up/Down 12V/24V 3A Volt Regulator Power Transformer with High..
$8.56 to be used on the right hand side from DC power in. It can take 3.7 ..12 V. It is the cheapest (up and down) regulator.

2. SUNKEE LM2577 DC-DC Adjustable Step-up Power Converter Module
$6.95 to be used on the left side. If you ONLY use 5 V in you could also use it on the right hand side for AC power in. It has a low 5mA idle current

3. DROK® LM2587 Auto Step Up Down Converter 24W 2A Boost Buck Module DC 3-35V to 1.2-30V Solar Energy Power Supply Charging Board Battery Voltage..
$10.28 to be used on the right hand side. a little smaller that #1 but $ 2 more

4. SMAKN® New DC-DC LM2577 Adjustable Step-up Power Supply Module 3.5-30v to 4-30v Dc Power Regulator Boost Voltage Converter
$ 7.99 for the left side. a little bit bigger

5. GEREE DC-DC Boost Converter Step Up 3-32V to 5-35V Voltage Adjustable Module XL6009
$ 7.43 for the left side

DEAD on arrival:
- CycleMore LM2596 LM2596S Step Down Adjustable Power Supply buck converter Module DC-DC Input 3V-40V Output 1.5V-35V
-SainSmart LM2577 DC-DC Power Supply Step-up Adjustable Power Converter Module, 3.5-30V to 4-30V
-DROK® 25W 3A Adjustable DC-DC Voltage Converter Automatic Boost Buck Volt Regulator 3-15V to 0.5-30V12V Step-up/Step-down Power Supply Transformer


My choice:
#1 and # 2. that gives you the cheapest solution with an option to use 4-12V DC in

if you restrict VIN DC to %V you could use 2x #2

If you go to high Amps (2A+) I suggest you add cooling radiator.. you can use the finger test. if you can still touch it no extra cooling needed.

The rPi in the piBeacon setup runs at 0.5 .. 0.8 Amp, the rPi3 a little bit more


Karl

Posted on
Fri Jul 08, 2016 6:54 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: piBeacon: 10- battery backup- safe shutdown

here a pic of the pc-board ( 7cm x 4.5cm = small test board ) and batteries
One could probably make it a little bit smaller, but is roughly the size of the 3 NiMH AA batteries.

you can see the

- 2 BUCKs, both are "step up" = output voltage is higher than input voltage , which limits the input voltage to +5= USB cable. if you take a step up/down you could use any input voltage > 3.5V
the left is the the one for the battery, the right for the normal power in. 2 SUNKEE LM2577 DC-DC Adjustable Step-up Power Converter Module, $7 each
- the relay= blue box
- between the 2 BUCKS are the 2 transistors, the timing capacitor..
- bottom right are the power diodes and the voltage splitters ...
- bottom right the pins to connect the SIGNAL in and out to the rPi for : power shut off --> rPI and rPi going down --> pc-board
- 3 AA NiMH rechargeable batteries

when put into a box, the batteries would be under the pc-board.

I guess that is it for me.

Karl.
Attachments
Screen Shot 2016-07-08 at 19.42.21.png
Screen Shot 2016-07-08 at 19.42.21.png (1.27 MiB) Viewed 1911 times
Screen Shot 2016-07-08 at 19.42.21.png
Screen Shot 2016-07-08 at 19.42.21.png (1.27 MiB) Viewed 1911 times

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest

cron