0
\$\begingroup\$

I'm trying to include a 5V soft latch switch into a circuit I've already made. The circuit consists of an ATtiny84, DFPlayerMini, a 3V DC motor, and a few other small components. Basically what I'm trying to accomplish with this is I want to press the button so that the circuit I've made is completed which thus powers the devices on. And if the button is pressed twice, then the circuit is disconnected; however, if the button is not pressed twice, after a certain duration, the ATtiny84 will disconnect the circuit. Here's the circuit (not mine): enter image description here Source

I'm using a 5V 2A power supply and I'm wondering whether this is appropriate to use without any modification. Moreover, if it is, how might I get the ATtiny84 to disconnect the circuit? I was thinking of sending out a HIGH signal from one of the ATtiny84 pins to the conjunction of resistors R4, R6, and R5 but I'm not entirely sure if that would work. Many thanks! : )

EDIT: I'm using a circuit that combines the ideas from @DELTA12 (below), as well as from another that I got off another forum; however, I'm having trouble getting it to work. The program aspect seems to be doing just fine but for some reason the toggle functionality (turning it on and turning it off) seems to work once, after that nothing happens. For it to work again I need to remove the power and apply it again. Any idea why this is happening?

Here's the circuit that I'm using (the second one is the one I'll be using once I get the toggle functionality to work):

schematic

simulate this circuit – Schematic created using CircuitLab

schematic

simulate this circuit

\$\endgroup\$
3
  • \$\begingroup\$ Where's the load (output)? Also, is there any particular reason you are using BJTs instead of MOSFETS? If all you want is a power latch, you could use a much simpler circuit since your microcontroller can do the latching. \$\endgroup\$
    – DELTA12
    Commented Dec 16, 2023 at 8:47
  • \$\begingroup\$ Is Q3 meant to run in reverses active mode? Are the terminals connected incorrectly in the schematic? Should it be a PNP instead of an NPN? I'm not sure what the intent is. \$\endgroup\$ Commented Dec 29, 2023 at 23:42
  • \$\begingroup\$ @MathKeepsMeBusy Hi! Q3 (an NPN) is meant to negate the out from the sensors such that the sensors can also turn on the ATtiny84 as if the button were pressed. I haven't tested this out since I'm having trouble with the toggle functionality from the button but it's more a concept right now and I'm not entirely sure if it'll work as intended. \$\endgroup\$
    – A Friend
    Commented Dec 31, 2023 at 23:24

1 Answer 1

0
\$\begingroup\$

Here is a simple button circuit I use for power latching with an AVR128DA32. It relies on the microcontroller to do the latching, therefore if you program freezes, it won't be able to unlatch without you disconnecting the power source manually. enter image description here

PWR_EN is also connected to an MCU (microcontroller) IO pin and can drive a gate of an N-channel MOSFET here. When you connect the power source, R10 will pull the gate down and keep the load disconnected. When you press the button, it will drive PWR_EN high and switch the load (MCU) on. Then, your MCU program can also start driving PWR_EN high which latches the power and you can now release the button. D1 provides one-way isolation, so that you can still use the button as an input for the MCU after PWR_EN is latched, therefore you can write a program that will stop driving PWR_EN from the MCU if the button is pressed later. If your source is 5V and your MCU is also 5V, then you don't need R11, which I used as a voltage divider since my battery is at a higher voltage than the MCU.

\$\endgroup\$
5
  • \$\begingroup\$ Interesting, I didn't know you could do this! However, you mentioned near the end that a program is needed to stop PWR_EN, the program I've written executes a function, however, checking to see if the button was pressed doesn't seem ideal to include given how I wrote the program. If I am interpreting your response correctly, are there alternatives? Could I perhaps use an ATtiny85 to handle the latching while using the ATtiny84 to do all the functionality when the circuit is connected? Many thanks! : ) \$\endgroup\$
    – A Friend
    Commented Dec 18, 2023 at 22:14
  • \$\begingroup\$ Yes, you need a software check and IO write to unlatch it. You could use another MCU, but that seems overkill to me. I don't understand why can't you do the checking on the same MCU. You can have the check in an interrupt and thus not have it affect the program execution in any way unless the button is actually pressed. \$\endgroup\$
    – DELTA12
    Commented Dec 19, 2023 at 7:40
  • \$\begingroup\$ Hi! I'm using Arduino software and I didn't know Arduino had interrupts but I've just checked them out and it's definitely what I need for my program given your approach! However, could you elaborate on your method? Specifically, PWR_EN, the type and value of D1, as well as what VBAT is? Thanks in advance! : ) \$\endgroup\$
    – A Friend
    Commented Dec 19, 2023 at 21:47
  • \$\begingroup\$ D1 can be any kind, Schottky or silicon (I'd go witch Schottky). VBAT here is my battery source voltage. In your case, just connect that to the 5V input. PWR_EN I believe I already described, that's the gate signal for an N-channel mosfet. \$\endgroup\$
    – DELTA12
    Commented Dec 20, 2023 at 10:57
  • \$\begingroup\$ I apologize for the late reply but I've combined the ideas from your circuit and another to make the soft-latching circuit which seems to work but the only problem I face now is that the toggle functionality seems to work once. The circuit is provided above, any idea why this behavior is happening? Many thanks! : ) \$\endgroup\$
    – A Friend
    Commented Dec 29, 2023 at 22:29

Your Answer

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

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