Author Topic: Polarized capacitor could be charged either way  (Read 1998 times)

0 Members and 1 Guest are viewing this topic.

Online PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: us
Polarized capacitor could be charged either way
« on: January 08, 2025, 04:09:33 pm »
Shown below is my circuit for a mailbox notifier.  The circuit is powered down when idle, and both sides of C2 are at V+, which is 5VDC or less.  Then when the door is opened, the switch closes, and the left side is grounded, which also lowers the right side to ground, turning on the mosfet.  The right side then starts to charge up, but is brought back down then the NPN turns on.

If the door is closed and the switch opens before the D1 Mini has finished transmitting, then the left side will start to charge through R3.  However, if the door is left open, or not properly closed, or the magnet is knocked off the door (all of which have happened), then the Mini will turn off the NPN while the door switch to ground remains closed, and then the right side of C2 will charge up to 5V.

I want to use reasonably available (through-hole) parts for this, which would not include a non-polarized electrolytic capacitor, so I'm wondering if I can get away with violating the polarity of even a tantalum capacitor at this voltage and with current limited by the 1Meg resistor.  I would put the positive side on the right since that would be correct polarity when the door is left open for an extended period.

Also, does the voltage rating of the capacitor affect the answer?

As a hobbyist, I just haven't dealt with this situation before.  So I would appreciate any guidance on this issue.
« Last Edit: January 08, 2025, 04:11:38 pm by Peabody »
 

Offline golden_labels

  • Super Contributor
  • ***
  • Posts: 1511
  • Country: pl
Re: Polarized capacitor could be charged either way
« Reply #1 on: January 08, 2025, 07:18:43 pm »
Damage from wrong polarity comes in two phases ways:(1)
  • Shorts are formed within the capacitor.
  • High current through those shorts boils the electrolyte, leading to explosion, spilling out electrolyte, or venting out fumes.
Placing high resistance in series with the capacitor prevents the second. If high current isn’t possible, there is no source of heat and nothing is boiled.

However, they don’t protect against the first: forming shorts. In correct polarization electric field pushes ions against insulation layer between electrodes, with the insulation layer itself being supported — in the most literal mechanical sense — by the solid electrode. If polarization is wrong, the insulation layer is pushed towards electrolyte, which provides no support, and the layer dissolves into electrolyte.

So while in your idea the capacitor will never explode, it will still slowly deteriorate. With time losing its capacitance and leaking charge.

But also note it’s not like the entire insulation layer disappers instantly. It’s gradual, comes with time and total charge passed. With infrequent events it may survive years. Capacitors rated for higher voltages (like 400 V death caps) have a thick insulation layer and laugh in your face, if you try to intentionally destroy them by applying voltage in reverse (as long as it is not too high).

I just don’t understand, why would you insist on using a polarized capacitor, instead of a dirt cheap film one.


(1) (Later edit) While writing the post my brain was stuck in OP’s specific problem. The poor choice of words came from thinking about this specific scenario and the general case at the same time. Of course deterioration wouldn’t happen without current being somewhat limited, because the capacitor first releases the magic smoke.
« Last Edit: January 09, 2025, 08:46:53 am by golden_labels »
People imagine AI as T1000. What we got so far is glorified T9.
 
The following users thanked this post: ledtester


Online jpanhalt

  • Super Contributor
  • ***
  • Posts: 4080
  • Country: us
Re: Polarized capacitor could be charged either way
« Reply #3 on: January 08, 2025, 07:56:12 pm »
DigiKey has 411 radial lead 2.2 uF ceramic capacitors listed.  My experience with an exploding Tantalum (once) due to reverse polarity was not great.  But then, it wasn't designed for current limiting.
 

Online PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: us
Re: Polarized capacitor could be charged either way
« Reply #4 on: January 08, 2025, 10:29:19 pm »
I didn't think ceramic or even film capacitors as high as 2.2µF were widely used, or would be available in any hobbyist's stash.  I've never used one, or bought one.  Well, I'll look at those links.  Anyway, it appears using a polarized capacitor in that circuit isn't good for the long run, even with the low current.  Thanks very much for clarifying that.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 20533
  • Country: gb
  • 0999
Re: Polarized capacitor could be charged either way
« Reply #5 on: January 08, 2025, 11:24:03 pm »
Two 4.7µF aluminium electrolytic capacitors connected back-to-back could well be the most cost effective solution.
 

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 7663
  • Country: ca
  • Non-expert
Re: Polarized capacitor could be charged either way
« Reply #6 on: January 09, 2025, 12:07:02 am »
I didn't think ceramic or even film capacitors as high as 2.2µF were widely used, or would be available in any hobbyist's stash.  I've never used one, or bought one.  Well, I'll look at those links.  Anyway, it appears using a polarized capacitor in that circuit isn't good for the long run, even with the low current.  Thanks very much for clarifying that.

At these low voltages, 10uF and 22uF ceramic is common and cheap, used in lots of laptops.
https://www.lcsc.com/product-detail/Multilayer-Ceramic-Capacitors-MLCC-SMD-SMT_Samsung-Electro-Mechanics-CL21A226MAQNNNE_C45783.html
https://www.lcsc.com/product-detail/Multilayer-Ceramic-Capacitors-MLCC-SMD-SMT_Samsung-Electro-Mechanics-CL10A225KA8NNNC_C57895.html?s_z=n_2.2uf

Through hole obviously restricts available parts though
https://www.lcsc.com/product-detail/Multilayer-Ceramic-Capacitors-MLCC-Leaded_Dersonic-CD1E106MC9BER2F100_C2761733.html?s_z=n_10uf
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 
The following users thanked this post: sarahMCML

Offline CaptDon

  • Super Contributor
  • ***
  • Posts: 2252
  • Country: is
Re: Polarized capacitor could be charged either way
« Reply #7 on: January 09, 2025, 04:24:08 am »
Small non-polarized capacitors are used as tweeter crossover elements and are common. I have several dozen 1uf through hole mount capacitors that are non-polarized and used as bypass capacitors on digital logic boards. They are rated at 10vdc. Two back to back polarized capacitors DO NOT make the equivalent of a non-polarized capacitor and only the most dog shit design or craptastic manufacturer would make such a device. It can be done in very non-critical applications but makes a statement about the person or company that would do it!!
Collector and repairer of vintage and not so vintage electronic gadgets and test equipment. What's the difference between a pizza and a musician? A pizza can feed a family of four!! Classically trained guitarist. Sound engineer.
 

Online PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: us
Re: Polarized capacitor could be charged either way
« Reply #8 on: January 09, 2025, 05:17:49 am »
I have another version of the circuit (see below) which avoids the switch in polarity.  So a regular capacitor would work.  However, when the door is left open, the gate would be at the midpoint of the R1/R3 divider, and that can't be down more than the threshold voltage, or the Pro Mini could turn back on again and send out another notification.  But 100K and 2Meg yields 0.24V at 5V, and I don't think any mosfet would turn on at that voltage.
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 15240
  • Country: de
Re: Polarized capacitor could be charged either way
« Reply #9 on: January 09, 2025, 09:01:15 am »
2 µF film capacitors are already on the large side. Available, but no longer cheap and small.  2.2 µF ceramics are available with no problem, especially in SMD. One could also use 2 x 1 µF in parallel, as 1 µF is very common to get. With a little larger resistors for the 10 K the circuit should also work with a smaller capacitor, like 1 µF or if needed 100 nF.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 20533
  • Country: gb
  • 0999
Re: Polarized capacitor could be charged either way
« Reply #10 on: January 09, 2025, 09:26:03 am »
Does the reed switch have to go to 0V? Can it go between +V and the BJT's base, via another RC circuit?
 

Offline golden_labels

  • Super Contributor
  • ***
  • Posts: 1511
  • Country: pl
Re: Polarized capacitor could be charged either way
« Reply #11 on: January 09, 2025, 09:34:45 am »
Two back to back polarized capacitors DO NOT make the equivalent of a non-polarized capacitor and only the most dog shit design or craptastic manufacturer would make such a device. It can be done in very non-critical applications but makes a statement about the person or company that would do it!!
Not opposing the opinion about a commercial product using back-to-back electrolytics, and an example surfaced recently.

But the first part, about not making the equivalent of a non-polarized capacitor, is IMO more nuanced. I don’t want to argue in favor of using them this way, just talking about accuracy.

Bipolar electrolytic caps exist. They are nothing more than two anodes submerged in the cathode, in a single can. Literally a back-to-back configuration. Everything is designed to assure sufficiently long operation despite the unfavourable conditions, so this is not identical to just wiring two random polarized caps together. But that already shifts us from strong “DO NOT make the equivalent” to asking “how much of the equivalent they are?”

From the purely electrical perspective, the idea always seemed sound to me. Of course ESR and capacitance suffer, but in principle we do get the equivalent of a polarized capacitor. Am I missing anything?

Each time polarity changes one of the caps gets the beating. I wouldn’t like to be in position of the poor capacitors from “Capacitors before bridge rectifier” thread. 50 hits a second must hurt. But I can’t see how this is not electrically equivalent, if used where electrolytics would normally be employed.
People imagine AI as T1000. What we got so far is glorified T9.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 20533
  • Country: gb
  • 0999
Re: Polarized capacitor could be charged either way
« Reply #12 on: January 09, 2025, 11:15:22 am »
Two back to back polarized capacitors DO NOT make the equivalent of a non-polarized capacitor and only the most dog shit design or craptastic manufacturer would make such a device. It can be done in very non-critical applications but makes a statement about the person or company that would do it!!
Not opposing the opinion about a commercial product using back-to-back electrolytics, and an example surfaced recently.

But the first part, about not making the equivalent of a non-polarized capacitor, is IMO more nuanced. I don’t want to argue in favor of using them this way, just talking about accuracy.

Bipolar electrolytic caps exist. They are nothing more than two anodes submerged in the cathode, in a single can. Literally a back-to-back configuration. Everything is designed to assure sufficiently long operation despite the unfavourable conditions, so this is not identical to just wiring two random polarized caps together. But that already shifts us from strong “DO NOT make the equivalent” to asking “how much of the equivalent they are?”

From the purely electrical perspective, the idea always seemed sound to me. Of course ESR and capacitance suffer, but in principle we do get the equivalent of a polarized capacitor. Am I missing anything?

Each time polarity changes one of the caps gets the beating. I wouldn’t like to be in position of the poor capacitors from “Capacitors before bridge rectifier” thread. 50 hits a second must hurt. But I can’t see how this is not electrically equivalent, if used where electrolytics would normally be employed.
The problem with that rectifier circuit is the high ripple current, rather than the reverse bias.

This has also been discussed at the end of last year.
https://www.eevblog.com/forum/projects/simple-1-second-1ma-10ma-analog-oscillator-for-greenredwhiteblue-led-pulsing/msg5761537/#msg5761537

It works because the capacitors have parasistic diodes. Providing those diodes don't conduct for long, the capacitor will be fine.
 

Online PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: us
Re: Polarized capacitor could be charged either way
« Reply #13 on: January 09, 2025, 02:50:58 pm »
Does the reed switch have to go to 0V? Can it go between +V and the BJT's base, via another RC circuit?

I don't understand what you have in mind.  I don't see a way to do that.
 

Online PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: us
Re: Polarized capacitor could be charged either way
« Reply #14 on: January 09, 2025, 03:15:26 pm »
With a little larger resistors for the 10 K the circuit should also work with a smaller capacitor, like 1 µF or if needed 100 nF.

Did you mean the 100K G/S resistor?  I have to admit that the choice of the 100K was just my ballpark guess at what would reliably prevent noise or interference from triggering the mosfet.  If the MCU gets to the point of powering up, it's going to assert D2, then send a notification, and I don't want that to happen falsely.  And it didn't much matter if it was a lower value than necessary because current flows through it only for a few seconds twice a day.  But I would be interested in more educated views of how big that resistor might be and still work reliably.

 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 20533
  • Country: gb
  • 0999
Re: Polarized capacitor could be charged either way
« Reply #15 on: January 09, 2025, 07:30:25 pm »
Does the reed switch have to go to 0V? Can it go between +V and the BJT's base, via another RC circuit?

I don't understand what you have in mind.  I don't see a way to do that.
I made a schematic, but when I was nearly done, I realised your schematic contains a confusing error, so I had to stop.

Look at the reed switch. There's a note next to it which says, "Magnetic Reed Switch Normally Closed if no magnet". You then have NC written next to the the contact drawn as normally open, which is contradictory. Switch contacts should always be drawn in the non-energised state, which would be without a magnet, in the case of a reed switch.
 

Online PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: us
Re: Polarized capacitor could be charged either way
« Reply #16 on: January 09, 2025, 09:50:53 pm »
I don't think it's an error.  The magnet and the switch are mounted opposite each other, the magnet on the mailbox door, and the switch in the mailbox.  The switch is closed when the door is opened and the magnet is moved away from the switch.  That's what triggers the mosfet.

So I think that means it really is a normally closed switch, meaning that it's closed when no magnet is nearby.  I did ask Google AI what "normally closed" means for a magnetic switch, it not being necessarily obvious to me, and it said what you said.  So I think the schematic is right.  The magnet keeps the switch open.  Otherwise, normally, with no magnet, it's closed.

Maybe I drew it wrong.   I don't know if there's a standard  symbol for a magnetic switch.  I tried to show that the magnet keeps the switch open.

« Last Edit: January 09, 2025, 09:54:43 pm by Peabody »
 

Online PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: us
Re: Polarized capacitor could be charged either way
« Reply #17 on: January 09, 2025, 10:26:53 pm »
Digikey shows nine NC switches, and several dozen SPDT, which can be either NO or NC.

Anyway, I think @Zero999 wants me to draw it as shown below.
 

Offline golden_labels

  • Super Contributor
  • ***
  • Posts: 1511
  • Country: pl
Re: Polarized capacitor could be charged either way
« Reply #18 on: January 10, 2025, 04:04:37 pm »
I focused on the capacitor problem at first, without digging into what’s your goal. Looking at your problem now and assuming I understand it correctly, it may be decomposed into two parts:
  • Triggering the P-channel MOSFET to enable a microcontroller,
  • Letting the microcontroller shut down itself.

Did you consider using a pair of 555s to solve both?

In part I your trouble come from the latching circuit being level-triggered, while you want it to be edge-triggered. If an edge is detected, the MOSFET should be driven low for long enough for the microcontroller to take over the job. And after that it does nothing, until the switch returns to its original position and may produce another edge.

This is the standard 555 in monostable configuration. With high-pass filter on the input, so an edge is the trigger, not a level. And a transistor on the output to pull down the switching MOSFET, since 555 itself produces high level.

In part II you need a delay and something to hold signal long enough for the controller to be powered down. Doing that directly from controller’s I/O pin is usually unreliable. Again, another 555 in the same configuration may be used.


People imagine AI as T1000. What we got so far is glorified T9.
 

Online PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: us
Re: Polarized capacitor could be charged either way
« Reply #19 on: January 10, 2025, 06:57:09 pm »
My circuit draws zero current except during the 20 seconds it is powered up twice a day.  It seems that the 555s would have to be powered up all the time, or at least one of them.  Is that right?  If not, perhaps you could post a drawing of how they would be configured.

Edit:  I should also say that I think powering down from the GPIO is reliable here.  D2 will switch from output high to output low.  Then at some point the ESP8266 will shut down, and the active low output will cease.  But there's no way for it to go active high again.  It will go tristate, but there's still no current source to turn on the NPN, so it will stay off.  It actually did work that way for over a year, and I did not experience any problems.  But the original circuit just connected the switch directly to the gate, so if the door was left open, the power stayed on.  That's what I'm trying to correct by inserting the capacitor in that line.

« Last Edit: January 10, 2025, 07:08:03 pm by Peabody »
 

Offline golden_labels

  • Super Contributor
  • ***
  • Posts: 1511
  • Country: pl
Re: Polarized capacitor could be charged either way
« Reply #20 on: January 10, 2025, 08:24:31 pm »
My circuit draws zero current except during the 20 seconds it is powered up twice a day.  It seems that the 555s would have to be powered up all the time, or at least one of them.  Is that right?  If not, perhaps you could post a drawing of how they would be configured.
Depends on the model. ST’s TS555 and TI’s LMC555 advertise 100–200 µA.(1) That’s some orders of magnitude less than your circuit draws while active. Does current draw so low matter in your scenario?

Edit:  I should also say that I think powering down from the GPIO is reliable here.  D2 will switch from output high to output low.  Then at some point the ESP8266 will shut down, and the active low output will cease.  But there's no way for it to go active high again.  It will go tristate, but there's still no current source to turn on the NPN, so it will stay off.  It actually did work that way for over a year, and I did not experience any problems.  But the original circuit just connected the switch directly to the gate, so if the door was left open, the power stayed on.  That's what I'm trying to correct by inserting the capacitor in that line.
If you tested it and that level of reliability suffices your needs, I can’t argue against it. One circuit section less.


(1) https://www.st.com/resource/en/datasheet/ts555.pdf, https://www.ti.com/lit/ds/symlink/tlc555.pdf
People imagine AI as T1000. What we got so far is glorified T9.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 20533
  • Country: gb
  • 0999
Re: Polarized capacitor could be charged either way
« Reply #21 on: January 10, 2025, 10:44:03 pm »
I don't think it's an error.  The magnet and the switch are mounted opposite each other, the magnet on the mailbox door, and the switch in the mailbox.  The switch is closed when the door is opened and the magnet is moved away from the switch.  That's what triggers the mosfet.

So I think that means it really is a normally closed switch, meaning that it's closed when no magnet is nearby.  I did ask Google AI what "normally closed" means for a magnetic switch, it not being necessarily obvious to me, and it said what you said.  So I think the schematic is right.  The magnet keeps the switch open.  Otherwise, normally, with no magnet, it's closed.

Maybe I drew it wrong.   I don't know if there's a standard  symbol for a magnetic switch.  I tried to show that the magnet keeps the switch open.
I see what you mean now. The drawing is correct, given the magnet is normally next to the contacts, which effectively become normally open.

Here's my idea. The capacitor will be exposed to reverse bias, but it's clamped to <0.6V by the transistor, so it's no longer an issue.
 

Online PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: us
Re: Polarized capacitor could be charged either way
« Reply #22 on: January 10, 2025, 10:47:49 pm »
Since this project may be powered by three Utimate Lithium primary AAs, which are expensive, I just don't want to draw any current during the 23 hours, 59 minutes and 20 seconds per day when nothing is going on if I don't have to, not counting Sundays and holidays when even the 40 seconds doesn't happen.  Even 100-200uA.  And if I were willing to accept that, it would be easier to just leave the power on all the time and put the ESP8266 into deep sleep instead, and do away with most of the circuit.  It varies by version, but my D1 Mini v3.0.1 sleeps at about 70uA, so that would be a better option than the 555.  But mainly it's just the principle of the thing that this kind of project shouldn't draw power when it's idle.

I'm still wondering about the value of the pullup resistor on the P-channel mosfet.  Everything I read says 100K is already at the high end of the acceptable range.  But certainly a higher value would let me use a smaller capacitor, so there's that.
 

Online PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: us
Re: Polarized capacitor could be charged either way
« Reply #23 on: January 10, 2025, 11:12:11 pm »
Thanks very much for the new circuit.  I'm gonna have to work through it, and breadboard it over the weekend to see how it works.  But I'm perplexed by the use of the 1Meg resistors.  If I can get away with them there, maybe I can get away with a 1Meg pulldown on the mosfet, and then I could use a normal non-polarized bypass capacitor.  But I guess the difference is that the mosfet gate is very high impedance, and the NPN base is not.

I also need to consider whether the protection diode on D2 affects any of this.

Anyway, thanks again for the suggestion.
 

Offline golden_labels

  • Super Contributor
  • ***
  • Posts: 1511
  • Country: pl
Re: Polarized capacitor could be charged either way
« Reply #24 on: January 11, 2025, 01:19:34 am »
Just to put that to numbers: if 100 µA is drawn for an entire day, that is 0.1 mA · 24 h = 2.4 mAh. I would still reconsider the position.

But ok, I’ll assume this is a hard, undebatable constraint. Let’s also skip the most obvious solution: adding another MOSFET controlling power to the 555.

Using as much as possible from your original idea, perhaps the circuit below will do? Not tested (only simulated in spice).



  • C1/R2 form a high-pass filter, for signal from the switch being closed. The delay time is determined by how long it takes to charge C1 through R2.
  • R1 provides a discharge path for C1, when the switch is opened. When the switch is closed, some current goes through it uselessly. mA range.
  • Q1 is an amplifier that separates the filter from R3 and Q2. This way there is no issue with both parts affecting each other. The transition is also quick.
  • When the switch is opened, a short spike is produced on Q1 base, going above the supply voltage. Given R3 limits current and the B-C junction should withstand much more than that, this shouldn’t cause trouble. But, if you feel better about that: a diode in parallel with R2, in reverse polarity, will take care of the spike.
  • Microcontroller and associated components not included in the schematic. In particular remember D2 output, if it’s actively driven, requires a series resistor.

If it happens that Q1 is not enough to pull gate of Q2 or the transition is too slow, perhaps a bit more complicated amplifier:



Note that in this circuit R5 must be at least an order of magnitude bigger than R2. Otherwise C1 will charge through it.


To be pedantic, you must accept some current draw. Real components have leakage. This is not an exception with the idea presented above.
« Last Edit: January 11, 2025, 01:29:39 am by golden_labels »
People imagine AI as T1000. What we got so far is glorified T9.
 

Online PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: us
Re: Polarized capacitor could be charged either way
« Reply #25 on: January 12, 2025, 10:55:52 pm »
@Zero999, I've tested your suggested circuit in post #21, and it works fine. So I'll be going with that circuit.  Using the parts I have onhand, it actually works using a 100nF cap, but it doesn't work at 80nF.  So given parts variability, I'm going to spec it as 220nF.  But that's still readily available as ceramic or film, so not polarized.  So the reverse polarity issue becomes moot.

I also tested the circuit with the NPN transistor replaced by an N-channel mosfet - the BS170.  That worked too, but really no better than the bipolar transistor, and with battery voltage possibly getting down into the 3V+ range, I would be concerned about encountering threshold voltage issues at some point.  So I think the bipolar version is the best option.

The other change I've made tentatively is to remove the 1000uF cap on the 3.3V pin of the D1 Mini.  My original thinking was that there would be current spikes during transmission which could cause short-term voltage drops, and that smoothing those out might prevent the brownout detector from triggering, thus extending battery life.  But testing with my scope, I'm unable to detect any such voltage drops.  I'm testing very near my router, and I guess it's possible it would consume more power when communicating from the mailbox.  So I need to test that.  But if I still can't detect any problems, I'll eliminate that big cap.

@golden_labels, thanks for your suggested circuit, but the Zero999 circuit is just much simpler, and seems to work perfectly in my tests.  So I'm going to stick with that one.

Thanks for everybody's help on this.
« Last Edit: January 12, 2025, 10:59:36 pm by Peabody »
 

Offline golden_labels

  • Super Contributor
  • ***
  • Posts: 1511
  • Country: pl
Re: Polarized capacitor could be charged either way
« Reply #26 on: January 12, 2025, 11:44:25 pm »
thanks for your suggested circuit, but the Zero999 circuit is just much simpler, and seems to work perfectly in my tests.  So I'm going to stick with that one.
Not arguing against Zero999’s circuit or promoting my solution: use whichever works for you.

But his is certainly not “much simpler.”  Both add 2 resistors and one capacitor. Mine also requires adding a transistor as an amplifier, while Zero999 may reuse the existing NPN because the input signal is flipped upside down. :)

There is a reason for neither being really simpler. Both are essentially the same idea. Which you should take as a good sign. It means two minds came to the same conclusion independently.


edit
Here’s how they are similar, and how they differ.

Re-arranging things a bit in Zero999’s version,(1) for the sake of of argument, here are the filter parts:



… and here are the amplifier parts. In my case it’s a voltage follower, in Zero999’s it’s a switch. But in this context the distinction is negligible: with so high impedances on the outputs they both just pull MOSFET’s gate to ground:



Now, the important difference. In Zero999’s circuit, R2 goes not directly to the power line, but to the base of Q1. During charging that changes little. The voltage is reduced by VBE and Q1 is controlled by capacitor current, not voltage. However, things go differently during discharging. In Zero999’s version the only discharge path is through the parasitics: whatever leaks from the reverse polarized junctions of Q1 and controller’s D2 pin. Since we’re already in sub 500 nA range to start with (2 MΩ from resistors), this is still likely to work. Just the discharge times may be harder to predict.


(1) Most notably connecting R2 to ground, not the base of the transistor.
« Last Edit: January 13, 2025, 05:30:39 am by golden_labels »
People imagine AI as T1000. What we got so far is glorified T9.
 

Online PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: us
Re: Polarized capacitor could be charged either way
« Reply #27 on: January 13, 2025, 10:17:13 pm »
Quote
However, things go differently during discharging. In Zero999’s version the only discharge path is through the parasitics: whatever leaks from the reverse polarized junctions of Q1 and controller’s D2 pin. Since we’re already in sub 500 nA range to start with (2 MΩ from resistors), this is still likely to work. Just the discharge times may be harder to predict.

It's not just leaks.  Power down results from D2 going low.  That's active low, not just tristate.  So things happen fairly fast.  I'm attaching scope pictures of the power-on, and of power-off with the switch still closed and with the switch open.  In all cases, the lower yellow trace is the mosfet gate and the upper orange trace is D2.  The probes are in 10X mode, so the vertical divisions are actually 2V.  And the horizontal divisions are 100ms.  The circuit is powered by an 18650 at a little over 3.9V.

 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 20533
  • Country: gb
  • 0999
Re: Polarized capacitor could be charged either way
« Reply #28 on: January 14, 2025, 11:14:02 am »
In Zero999’s version the only discharge path is through the parasitics: whatever leaks from the reverse polarized junctions of Q1 and controller’s D2 pin. Since we’re already in sub 500 nA range to start with (2 MΩ from resistors), this is still likely to work. Just the discharge times may be harder to predict.
Yes, that's true. I forgot that when U1 is powered down, all of its output transistors will turn of, leaving only the ESD protection diodes connected to its power rails. Adding a pull-down, say 100K between D2 on U1 will  help to provide a discharge path, when it's off.
 

Offline golden_labels

  • Super Contributor
  • ***
  • Posts: 1511
  • Country: pl
Re: Polarized capacitor could be charged either way
« Reply #29 on: January 14, 2025, 12:15:44 pm »
It's not just leaks.  Power down results from D2 going low.  That's active low, not just tristate. So things happen fairly fast.  I'm attaching scope pictures of the power-on, and of power-off with the switch still closed and with the switch open.(…)
Did you test it with the scenario, where the switch remains closed? As I understood it, the goal of this modification is to not let the circuit be re-powered until the switch opens.

People imagine AI as T1000. What we got so far is glorified T9.
 

Online PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: us
Re: Polarized capacitor could be charged either way
« Reply #30 on: January 14, 2025, 03:06:32 pm »
In Zero999’s version the only discharge path is through the parasitics: whatever leaks from the reverse polarized junctions of Q1 and controller’s D2 pin. Since we’re already in sub 500 nA range to start with (2 MΩ from resistors), this is still likely to work. Just the discharge times may be harder to predict.
Yes, that's true. I forgot that when U1 is powered down, all of its output transistors will turn of, leaving only the ESD protection diodes connected to its power rails. Adding a pull-down, say 100K between D2 on U1 will  help to provide a discharge path, when it's off.

And yet, it works as is.  It seems to me that it works because after the D2 output transistor shuts down and no longer sinks current, even in tristate it still doesn't provide any current into the NPN base.  And the NPN needs base current to stay on.  There's no current from the capacitor even if the switch is still closed because the 5V side went to 5V long ago and it can't go any higher, or if the switch is open then that side is now grounded through the 1M resistor.

It might be an interesting experiment to see what happens if instead of switching D2 to LOW, I switch it to INPUT.  I assume it would take a lot longer to shut down, but the question is whether it would stay on, or reboot at some point.  My bet is it would just slowly fade into the sunset.  I'll try to test that today.  Edit:  No, it should shut down immediately when base current stops flowing.

But what I haven't tested yet is putting the switch at the end of a pair of wires over three feet long.  The switch is going to be at the mailbox door, but the circuit board will be at the far back of the box.  And I'd like the cable length to be twice that distance so I can pull the board out to change batteries without disturbing the front-to-back length, which I would secure with hot glue so it won't be in the way.  It's very little current, but, you know, reflections and all that.  So I'll test that too.

« Last Edit: January 14, 2025, 03:11:45 pm by Peabody »
 

Online PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: us
Re: Polarized capacitor could be charged either way
« Reply #31 on: January 14, 2025, 03:27:45 pm »
It's not just leaks.  Power down results from D2 going low.  That's active low, not just tristate. So things happen fairly fast.  I'm attaching scope pictures of the power-on, and of power-off with the switch still closed and with the switch open.(…)
Did you test it with the scenario, where the switch remains closed?

As shown in the scope traces I posted, I did test it both ways, and it always shuts down when D2 goes low regardless of the switch position.  And then if the switch is opened after shutdown, it doesn't power up again.  So it appears to be working properly.

Quote
As I understood it, the goal of this modification is to not let the circuit be re-powered until the switch opens.

Well, the goal is to prevent the circuit from staying on if the switch remains closed after D2 goes low.  But indeed, the capacitor can't transmit another positive pulse until after the switch opens and it has discharged and the switch is then closed again.

 

Online PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: us
Re: Polarized capacitor could be charged either way
« Reply #32 on: January 14, 2025, 11:38:57 pm »
I finished today's tests.  First, I changed the state of D2 used to shut down power from OUTPUT LOW to INPUT.  It worked just fine, with rapid shutdown, and on the scope it looked the same.  So I think my theory about base current is right.  No pulldown needed on D2.

I also tested with the long cable length, and that made no difference.  And finally, I tried it at 3.1V, which I think is borderline for the ESP8266, but at least the power triggering part still worked.

So as far as I'm concerned, this circuit works exactly how I want it to.

 

Online PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: us
Re: Polarized capacitor could be charged either way
« Reply #33 on: January 15, 2025, 11:06:56 pm »
For future reference, here's my Github update on this project - the new software replacing IFTTT with Pushover, the new schematic discussed in this thread, and a Readme update.

https://github.com/gbhug5a/Mailbox-Notifier/tree/master/Update-2025

Thanks for everyone's help.
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3376
  • Country: us
Re: Polarized capacitor could be charged either way
« Reply #34 on: January 17, 2025, 01:43:31 am »
Edit: I see that you want to ensure that the MCU can turn off power even if the sensor is stuck in the closed position.

Have you considered this idea?

Latch Circuit - Wake up + 0 Power Consumption (useful circuit) -- Electronoobs
https://youtu.be/Er8fSoeaZD0

Blog post:

https://electronoobs.com/eng_circuitos_tut61.php

Schematic:

2484031-0

Here's a Falstad sim with the schematic laid out a little better:

(Falstad simulation)
« Last Edit: January 17, 2025, 02:46:52 am by ledtester »
 

Online PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2302
  • Country: us
Re: Polarized capacitor could be charged either way
« Reply #35 on: January 17, 2025, 02:59:58 am »
Well, as your edit suggests, it looks to me that his circuit will oscillate between power-on and power-off if the switch stays closed.  If the processor succeeds in powering down the circuit, once its GPIO output shuts down, the switch will power it up again.  Plus it has one more transistor.  :-)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf