0
\$\begingroup\$

I have this latching circuit to turn on and off an MCU (ATTINY 167) and a led Driver, by using a 8.4V Lipo battery.

It works fine: pressing the button turns it on and pressing again turns it off. Also, with the help of users here from stackexchange, I implemented a ALWAYS ON state controlled by an output pin from the MCU and also a FORCED OFF state by another MCU output pin, if I want to control the circuit from within the MCU.

But I'm having a minor problem:

I plug the battery and press the button to turn on the circuit. The circuit powers on. I then remove the battery with the circuit powered on, without pressing the button to power the circuit off.

In this case, if I plug the battery again, the circuit turns on automatically, with no need to press the button to turn it on. And it happens everytime I unplug the battery with the circuit powered on, even if I wait a couple of hours with the battery physically disconnected.

If I power the circuit and press the button to turn the circuit off, and then I remove the battery, with the circuit in a OFF state, then when I plug the battery again the circuit stays off and only turns on when I press the on/off momentary button. So it works as it should.

Can that 1uF capacitor be holding some charge when I disconnect the battery with the powered on and when I re-connect the battery it acts like a "trigger"?

So is there a way to ... if the battery is removed and re-inserted, to force the circuit to turn on initially in an always off and/or in an always on state? So it always behave the same way when first powered?

Attached is the working simulation of the circuit, although the effect of disconnecting the battery while the circuit is "on" and reconnecting it the circuit turning itself "on" automatically doesn't happen in the simulation.

Working Simulation

Latching circuit

\$\endgroup\$
1
  • \$\begingroup\$ I would check to see if the problem is residual gate charge on the MOSFETs. \$\endgroup\$
    – ErikR
    Jun 15, 2021 at 19:58

2 Answers 2

1
\$\begingroup\$

The way your circuit is set up, when the capacitor is charged, the circuit is off; and when the capacitors is empty the circuit is on. Capacitors get discharged over time, so I am not surprised the circuit always comes up "on" when you remove the batteries for a few hours.

If you want the circuit to always come up "on", you can connect a large resistor across the input terminals in order to always discharge capacitor when the battery is disconnected. The downside is it will waste a tiny bit of battery power all the time. Sometime like 1-2 megaohms will probably work well -- it will discharge the capacitor in under 30 seconds when the battery is unplugged; and only waste microamperes of current.

If you want the circuit to always come up "off", you need to redesign the it so that discharged capacitor = circuit is off. One way to do so is to switch how the capacitor is connected -- instead of connecting it between ground and button, connect it between input and button. I have not analyzed the circuit very carefully, but there is a chance this'll do what you need.

\$\endgroup\$
4
  • \$\begingroup\$ I have this simulation of my circuit, if you would like to check it working.. I tried changing the capacitor but couldnt make it work... thanks! tinyurl.com/yggwlybr \$\endgroup\$
    – Rodrigo
    Jun 16, 2021 at 11:44
  • \$\begingroup\$ I tried the 2M resistor to an always on... it didn't work in the simulation.... And it adds a delay between the press on and press off. This is the simulation with the resistor in place.. tinyurl.com/yeq3ba6m \$\endgroup\$
    – Rodrigo
    Jun 16, 2021 at 11:57
  • \$\begingroup\$ Weird -- this version with moved capacitor (my 2nd option) seems to work for me: tinyurl.com/ygeh4bhd . I haven't tried the 2M resistor version, but I've noticed that on my PC, the simulation is at least 10x slower than realtime.. so you might need to wait for a while. \$\endgroup\$
    – theamk
    Jun 17, 2021 at 3:40
  • \$\begingroup\$ Ok! Will try it in real-life! \$\endgroup\$
    – Rodrigo
    Jun 19, 2021 at 15:34
0
\$\begingroup\$

You have no discharge path for the gate capacitance of the N-channel FET (the one not attached to the MCU). Try putting a large value resistor (1 Meg will probably work) between the gate and ground. This should bleed off the gate voltage so that you will always start in the "off" state. You may need a resistor to discharge the cap as well.

\$\endgroup\$
3
  • \$\begingroup\$ Ok. Will try that! How is the resistor to discharge the cap wired? Also... if... I wanted to everytime I plug the battery it starts on an ON "state", how could it be done? \$\endgroup\$
    – Rodrigo
    Jun 16, 2021 at 13:58
  • \$\begingroup\$ Just add the resistor between the gate and ground. Starting in the "on" state is trickier but I would experiment with a capacitor between the drain and source on the P-channel FET. It would be dependent on the rise time of the application of power. \$\endgroup\$ Jun 17, 2021 at 13:03
  • \$\begingroup\$ Thanks! Will try it also in my circuit! \$\endgroup\$
    – Rodrigo
    Jun 19, 2021 at 15:34

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.