4
\$\begingroup\$

I'm trying to design a circuit that will control the power to a raspberry pi with a button. The basic usage is:

  1. first button press-> rasp powers up.
  2. second button press-> rasp continues with power but detects that should shutdown.
  3. (After the shutdown sequence is done, raspberry shuts off).

The design envisioned is a circuit with a normally off button that is connected to a binary counter (74LS161AN). The idea is to count the button presses and use the XOR of the counter's 2 least significant bits as a control for the power to the rasp. The XOR I intend to use is 74LS86. The msb of the counter's 2 bits is how the rasp detects it should shutdown. The rasp cuts its power by ouputing a High to a gpio that is connected to the counter reset.

This button/counter contraption is sort of working on a breadboard but now needs a transistor that actually takes the output of the XOR and controls the voltage in the rasp. power. Do you think that BD135 is a good choice for this? (datasheet) I chose it because Raspberry is powered by a 1.2A power supply, therefore the transistor needs to handle more current (bd135 has max collector current of 1.5A). It also needs to be NPN.

I have a few doubts if this is going to work, for example, how do I know if the XOR can supply enough current for the transistor base? Actually what does it mean when the high level output current of the XOR is -0.4mA ?

If this transistor would not work, could you point one that does and explain the reasoning to select it? I am a bit lost..

Thank you very much.

PS: between the button and the counter there is a 555timer in monostable to clear the bounces.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Why does it need to be NPN? A P-ch MOSFET would work better for a simple power switch. \$\endgroup\$
    – Oli Glaser
    Aug 13, 2013 at 1:31
  • \$\begingroup\$ A PNP transistor would also work better than a NPN, though I agree that the P-ch MOSFET works best due to acting as a resistor vs. acting as a diode under saturation. \$\endgroup\$ Aug 13, 2013 at 2:01
  • \$\begingroup\$ I thought it needs to be npn so that it becomes active when xor_out is high. Probably it is also possible with a pnp :) \$\endgroup\$
    – Tiago A.
    Aug 13, 2013 at 12:27

1 Answer 1

3
\$\begingroup\$

Something along the lines of this circuit would work:

PMOS Switch

Simulation:

PMOS Switch Simulation

Any decent logic level P-ch MOSFET with suitable current capability will work. An example is the NDP6020P. The NPN can be almost any small, general purpose NPN (e.g. 2N2222, 2N3904, BC337, etc)

\$\endgroup\$
2
  • \$\begingroup\$ Thank you for the help. Can I ask a few more questions please? Not sure if I get this correctly. When xor_out is low, Q1 is off. M1 sees a V_in voltage at gate and does not allow current through the load. When Xor_out is high, current flows through R1->Q1 but why does this close M1? Also, why is there a need for R2 and R3? Thanks! I'm trying to learn this. \$\endgroup\$
    – Tiago A.
    Aug 13, 2013 at 12:48
  • 1
    \$\begingroup\$ The P-ch MOSFET is opposite polarity to the N-ch, so when the gate is pulled to ground (by XOR going high and turning Q1 on) it turns on. When Q1 is off, R1 pulls the gate high again turning M1 off. R2 is to limit current into the base of Q1, and R3 is just to make sure Q1's base stays low if XOR is high impedance or something (R3 is not essential for operation) \$\endgroup\$
    – Oli Glaser
    Aug 13, 2013 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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