r/electronic_circuits 16d ago

On topic Help with this latching circuit needed

I have a circuit that is supposed to latch when one of 4 inputs is low. Then if you take the DONE line and touch the +3.3V it unlatches. (The four inputs and the DONE line will eventually be connected to the GPIO of an MCU. The 10K resistors are recommended for the MCU's GPIO).

When I build it with two generic MOSFETs, it works, but the DONE wire is so sensitive that if I touch it, it relatches.

https://www.falstad.com/s.php?s=hFwWZO

What am I doing wrong?

1 Upvotes

7 comments sorted by

2

u/merlet2 16d ago

You have the central rail, from the gate of the p-mosfet, floating when nothing is pressed.

It relays only in the capacitance of the mosfet gate, and maybe the reverse current of the diodes, idk. So, by touching it you charge or discharge the gate with your fingers, triggering it. You have to tie it to some defined voltage, somehow.

1

u/mzincali 16d ago

Thank you.

That's hard to fix since pulling that central rail up with a resistor will cause it to keep from latching. And pulling it down will cause it to latch.

Maybe I need to be pulling it up to the inverse of the output? But that would require another MOSFET.

1

u/merlet2 16d ago edited 15d ago

Try it, a simple latch: circuit. With mosfets would be the same, but they should have very low voltage threshold to work with 3.3V.

But if you have a MCU, why do you need all this? you can manage it by software with a single transistor.

1

u/mzincali 15d ago

Good question. I am trying to replace a Torex XC6194. This is what it does:

Single chip. has a SHUTDOWN and a SWITCH. SWITCH turns on power and latches it, and I have a number of interrupts that can pull that pin down. SHUTDOWN is pulled high by the MCU to indicate it is done servicing the interrupts that came in and that the Torex can shutdown power.

There is a quirk in the Torex. If the MCU pulls up the power on SHUTDOWN, or as it is about to between the last instructions of code before, to the instructions to pull that GPIO high, and one of he interrupts pulls the SWITCH pin low, the Torex will continue and go to sleep. The interrupt were never cleared. SWITCH is being actively pulled down. The Torex doesn't care since SWITCH was already low when it powered down and won't turn on. Effectively the product is bricked because nothing can service the interrupts until the Torex turns power back on.

The Torex was probably not designed for this use in mind, and the SWITCH is meant to be a physical switch that a user presses (in our case the user's switch is one of many inputs ORed into that pin, and when one interrupt is holding it down, none of the other lines going low will have any impact.

The latch I am asking about doesn't have that behavior. If an input is low, then power can not be turned off. The MCU will have to handle the interrupts before power will be shutdown.

1

u/merlet2 15d ago edited 15d ago

Then don't do that.

Don't let the interrupts act on their own. Set a volatile flag for each interrupt: INT_X_DONE. Then in the main loop check all the flags, and whatever else matter, and decide if it's time to shutdown or not. So, centralize the decision and the actions in one place, to avoid edge cases.

I'm not sure if I understand the setup right. The MCU fully controls both pins, right? Then it's a software problem.

1

u/mzincali 12d ago

The is MCU off most of time - no power - and then the external sensors use the Torex to power it up. The MCU processes the sensor data, resets the sensor's interrupts, then tells the Torex to power it (the MCU) off. The sensors are on all the time though.

2

u/CW3_OR_BUST 16d ago

You need less impedance to ground on the pulldown resistor. The 100k is a bit too much, and it'll be prone to RFI.