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

0 Members and 1 Guest are viewing this topic.

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2300
  • 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: 1507
  • 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.
 

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2300
  • 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: 20524
  • 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: 1507
  • 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.
 

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2300
  • 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 »
 

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2300
  • 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.

 

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2300
  • 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.

 

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2300
  • 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.
 

Online ledtester

  • Super Contributor
  • ***
  • Posts: 3365
  • 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 »
 

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2300
  • 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