0
\$\begingroup\$

I am a bit electronically challenged and need to hold an input pin high for about 8-10 seconds. I am implementing this solution: https://github.com/NeonHorizon/lipopi/blob/master/README.power_up_power_down.md, which works fine, but I have to hold the power on switch for 10 seconds before the Pi sets the UART pin high (and keeps it high). I looked at some explanation of RC circuits, and they seem to all have the same charge delay as discharge delay. Maybe I need a diode in there somewhere? Basically, I'd like to have the capacitor charge quickly, and discharge slowly through the resistor.

enter image description here

Following onto Flàvio's suggestion, can anyone tell me if using a transistor for isolation will work, something like this? The hoped for outcome is:

  • Press switch
  • Capacitor charges
  • When switch is released, capacitor keeps base of transistor high until GPIO 14 goes high as a result of the Raspberry Pi powering up.
  • By the time the capacitor would have discharged, GPIO 14 takes over to keep the transistor conducting, and EN remains high.
  • To power down, when the switch is pressed again, the Raspberry Pi reads GPIO 18 and a script instructs the Pi to power down
  • After shutdown, GPIO goes low, the capacitor discharges, and the powerboost cuts power to the Pi.

enter image description here

(fixed transistor orientation)

\$\endgroup\$
1
\$\begingroup\$

By adding the capacitor C1 you can achieve that. Note that the time it takes before the capacitor empties is roughly R*C, in my example below about 10s.

The downside of using this aproach is that it will also take as long to turn off the circuit as you need the same RC time.

A note on your original schematic: the two diodes in series are a very dirty way of dropping the voltage (if it drops the voltage at all), you can better use the resistive divider (R2 and R3) shown in my schematic, with the correct values depending on your battery.

schematic

simulate this circuit – Schematic created using CircuitLab

Edit: Personally, I would use the UART pin to turn on the circuit and another one to turn the circuit off. You could use GPIO18 to turn off the circuit actually. By having it set as input by default, and only using it as an output when you want to switch off the circuit. Your circuit would then reduce to the one below, with a quick switch off time (R2*C1 = 2s).

schematic

simulate this circuit

|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ Will the 100K through the UART be sufficient to pull EN low when the Pi is turned off? Otherwise the powerboost module will always be on \$\endgroup\$ – svenyonson Apr 22 '18 at 14:07
  • \$\begingroup\$ It will be plenty, but it takes longer. When uart goes low, it takes about 10s before EN is low ass well, due to the fact that C1 has to be discharged... \$\endgroup\$ – Douwe66 Apr 22 '18 at 14:25
  • \$\begingroup\$ That is OK, it just means that the Pi will have power (but still be shut down) for about 8 seconds. I like the simplicity of this design. The only issue now is that C1 is a physically large capacitor, unlikely to fit in the small case. But making the capacitor smaller and R1 large enough makes R1 no longer function as a pulldown for EN \$\endgroup\$ – svenyonson Apr 22 '18 at 14:29
  • \$\begingroup\$ You could use a tantalum capacitor or low voltage (e.g. 6.3V) elctrolytic one. Those are not large at all... \$\endgroup\$ – Douwe66 Apr 22 '18 at 14:36
  • \$\begingroup\$ If you don't mind chaning the PI code a little, you could do it even simpler, see my edit! \$\endgroup\$ – Douwe66 Apr 22 '18 at 14:43
0
\$\begingroup\$

schematic

simulate this circuit – Schematic created using CircuitLab

You can use this circuit to have a fast charge and calculate R to make it discharge as slow as you wish by turning Q2 on from a microcontroller pin or any digital signal.

EDIT: Vout is the voltage across C1.

|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ Thanks Flàvio. The problem here is that input signal that needs to be held high (EN) has a required 100K pull down, which will discharge the capacitor almost immediately. Somehow I need to isolate the RC circuit from EN such that the capacitor is forced to use R2 for discharge. I've added the original circuit to my post. \$\endgroup\$ – svenyonson Apr 21 '18 at 20:02
0
\$\begingroup\$

Hmm, your transistor is upside down. I haven't checked the rest of the workings of your circuit.

Can you drive a GPIO low right before shutting down? Why don't you try this:

schematic

simulate this circuit – Schematic created using CircuitLab

R3 keeps M1 off.

When someone presses SW, it turns M1 on, which keeps M2 on (which keeps M1 on after SW is released).

D1 prevents M2 from pulling Read-Button Low, so R1 pulls Read-button High. When someone presses SW again, you read a "Low".

You can then drive "Turn-off" low. M2 turns off, R3 turns M1 off. Enable then goes low.

p.s.: I haven't checked how your Adafruit breakout works, so I'm assuming this is something close to what you need.

|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ That's funny, I for some reason thought I needed to flip it, but I had it right the first time. \$\endgroup\$ – svenyonson Apr 22 '18 at 14:18
  • \$\begingroup\$ The Adafruit has to have EN pulled low in order to keep it from powering up, so driving it low won't help - it needs a 100K pull down to keep it low. \$\endgroup\$ – svenyonson Apr 22 '18 at 14:25
  • \$\begingroup\$ The basis for the original design is that the Pi will make the UART high on startup and go low when the Pi is shutdown - even if there is still power applied to the Pi (from the Adafruit powerboost). So when it shuts down, EN goes low, which removes power from the Pi. Reapplying power with the switch pulls EN high, which gives the Pi power again, which causes it to boot and drive the UART high, which then keeps EN high. But it doesn't keep the UART high initially, it toggles a bit before remaining steady, which is why the RC network is needed. \$\endgroup\$ – svenyonson Apr 22 '18 at 14:25
  • \$\begingroup\$ @svenyonson -- maybe put the UART with the RC filter on the "turn-off" pin then? would that work? Also you can still add the pull down resistor to the Enable net, I just assumed the powerboost had an internal pull down \$\endgroup\$ – Wesley Lee Apr 22 '18 at 18:43
0
\$\begingroup\$

Thanks to all for your suggestions. I found a simple solution as shown below. I had a similar solution early on, but the RC values were such that the resistor (2M) was too high a value to function as a pull down, and so EN was always high, which kept the Pi powered on. Thanks to Douwe66 for giving me the idea to use a higher value (100uf) capacitor, which let me use the existing 100K pulldown to complete the RC network. And using a voltage divider instead of two diodes in series to step down the voltage for GPIO 18 actually reduced the component count. Wesley's solution may have worked, but the component count was too high.

I would have accepted Dowwe66 first solution, except that it left GPIO 18 high all of the time (which would have caused the Pi to shutdown immediately after the shutdown monitor daemon became active) and also that the UART TX cannot be used as a path to ground for the EN pulldown (internal resistance while powered off is about 27M).

All in all, I learned a lot , and now have a working solution. Thanks!

enter image description here

|improve this answer|||||
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.