Computing stuff tied to the physical world

Charging a supercap

In Hardware on Oct 24, 2011 at 00:01

This is a quick experiment to see how this very low-power direct AC mains supply behaves:

JC s Doodles page 20

Note that I’ve built the 200 kΩ value from two resistors in series. This reduces the voltage over each one, and offers a slight security if one of them shorts out. The max 1 mA or so of current these resistors will let through is not considered lethal – but keep in mind that the other side is a direct connection, so if that happens to be the live wire then it’s still extremely dangerous to touch it!

One idea would be to add a “fusible” 100 Ω @ 0.5 W resistor in series with the 200 kΩ. These are metal-film resistors which will disconnect if they overheat, without releasing gases or causing flames. I can’t insert it in the other wire due to the voltage issue, so I’m not really sure it actually would make things any safer.

Here’s my first test setup of this circuit, built into a full-plastic enclosure:

DSC 2687

It took 20 minutes to reach 1.8V, the absolute minimum for operating an ATtiny. This is not a practical operating voltage, because whenever the circuit draws 1 mA or more, that voltage will drop below the minimum again.

The RFM12B wireless module will need over 2.2V to operate, and draw another 25 mA in transmit mode. The only way to make this work will be to keep the transmit times limited to the absolute minimum.

Still, I’m hoping this crude power supply will be sufficient. The idea is to run on the internal 8 MHz RC oscillator with a startup divider of 8, i.e. @ 1 MHz. The brown-out detector will be set to 1.8V, and the main task right after startup will be to monitor the battery voltage until it is considered high enough to do more meaningful work.

With 3.5V power, an ATtiny draws ≈ 600 µA @ 1 MHz in active mode and 175 µA in idle mode, so in principle it can continue running at this rate indefinitely on this power supply. But for “fast” (heh) startup, it’ll be better to use sleep mode, or at least take the system clock down well below 1 MHz.

This might be a nightmare to debug, I don’t know. Then again, I don’t have to use the AC mains coupled supply to test this. A normal low-voltage DC source plus supercap would be fine with appropriately adjusted resistors.

After 35 minutes, the voltage has risen to 2.7V – sure, take your time, hey, don’t rush because of me!

Another 5 minutes pass – we’re at a whopping 3.0V now!

Time for a cup of coffee…

After 45 minutes the charge on the 0.47F supercap has reached 3.3V – yeay! I suspect that this will be enough to operate the unit as current sensor and send out one short packet. We’ll see – it’ll all depend on the code.

After 1 hour: 3.75V, which is about as high as it will go, given the 5.1V zener and the 2x 0.6V voltage drop over the 1N4148 diodes. Update: my test setup tops out at 3.93V – good, that means it won’t need a voltage regulator.

Apparently, supercaps can have a fairly high leakage current (over 100 µA), but this decreases substantially when the supercap is kept charged. In an earlier test, I was indeed able to measure over 2.7V on a supercap after 24 hours, once it had been left charged for a day or so. In this current design the supply will be on all the time, so hopefully the supercap will work optimally here.

Not that it matters for power consumption: a transformerless supply such as this draws a fixed amount of current, regardless of the load. Here’s the final test, hooked up to live mains without the isolation transformer:

DSC 2688

Of this energy, over 95% is dissipated and wasted by the resistors. The rest goes into either the load or the zener.

  1. JC, an additional diode halves the waste – just insert –!>|– between the 100K’s and the top of the zener. That eliminates the wasted negative going half cycle flowing through forward biased zener. This introduces a tiny DC component on the mains, but saves 0.13w Of course, replacing the 100K’s by a 22nF X2 is even better, shifting the “dropper” loss towards the imaginary – and imaginary is free ! (At least for domestic customers) Bulkier of course, but with less waste, you can push up the constant current trickle without qualms. For safety, the X2 should be bridged by 470K so there is no “tickle” left on the exposed mains plug pins after disconnecting for the wall socket. BTW, a neat way to implement this is use an old style NE2 neon indicator – they come with integral resistor of the correct voltage rating and an red glow as an additional reminder that the circuit is live. Free – not bad for very old technology…

    • Ah, now I see why the extra diode before the zener is useful!

      I wanted to avoid the cap because of the residual voltage after disconnect, but understand that it’d be more efficient.

      The neon light over the cap, right? Hey, that’s neat.

    • Would a 630V or even 1kV ceramic cap of type X7R or Z5U be ok? I’m having a hard time finding low cost X2 caps. With a 47 kΩ resistor in series, the inrush current could be kept under 5 mA, for example. Or even easier, since I already have this test setup: just add the cap over one of the 100 kΩ’s.

    • I find that future electronics has the cheapest x2 capacitors. You can also get them from digikey or mouser. The smaller the capacitance, the cheaper the price. You can get anything below 1uf for less than a dollar. Beyond that the price grows nonlinearly :)

  2. This is a similiar solution with the above post: Google ‘transformerless power supply’ and you will find plenty of sites explaining using an X2 class capacitor to implement a low-current power supply. It basically uses the reactance of capacitor to limit current. This is more efficient than using resistors because theoretically capacitors do not dissipate power.

    • Yes, I know about the cap option and why it’s preferable. Wanted to avoid the extra components – i.e. cap + discharge resistor (although in hindsight it could be a small cap, not really that bulky).

      I’ll probably try it out one of these days, if only to compare power consumption.

      I vaguely remember seeing an ATtiny-based supply too, not sure whether it was mains or step-up. My hunch is that the startup issues (under all load conditions) might be tricky.

  3. So why don’t you put one 100k resistor (or, even better, two 47k ones) on each mains line? That way, accidentally touching your digital ground won’t hurt.

    I once saw a design for a switching power supply where the AVR attiny/atmega did its own voltage measurement and switching, but I can’t for the life of me find that web page any more. :-/

    • I think this is the article you’re looking for: http://spritesmods.com/?art=ucboost

    • That links to a (sketch for a) step-up regulator. I want step-down (from mains).

      There’s a 3-pin IC solution for it (just add capacitors), but it only delivers 10 mA, which isn’t nearly enough – and I’m not sure that it tolerates hooking up three in parallel.

  4. Matthias, the breadboard shows that 0.1ohm in the supply lead ready for current sensing, so the derived supply needs its common terminal at the same potential to give the ADC a chance.

    With the component values & times given, the charging current looks like 0.48mA equivalent (plus/minus due to the capacitor tolerance and leakage), which compares closely with the theoretical 0.52mA equivalent (√2Vrms/πR). Seems a bit low for the mix of 600μA, 175μA and 30mA bursts. Interesting that nothing is wasted in the zener until around 50mins elapsed when it first starts clamping.

  5. Isn’t the supercap polarised? What if you drop the two diodes after adding martynj’s suggestion? And then have a higher resistor value and (a lower zener value or a voltage regulator)? A voltage regulator only wastes energy when the processor is running, the diodes waste energy all the time. Of course, one could ‘prime’ this power supply with a battery when installing; once you know the general characteristics of the circuit there is little ‘need’ for the slow charging upon first use. Or is there a catch I overlooked?

    • Yes, it’s polarized, I forgot to draw the “+”. I used components I had lying around. In hindsight, I’d use a 1N400x diode before the zener, and make the zener 3.6 or 3.9V, to stay below the supercap and the RFM12B limit.

      As for priming the supercap with a charge: yes, that’s what I’ve been doing, by plugging the unit into FTDI for sketch upload (while disconnected from mains, of course). Later on, a “cold start” test will be needed to make sure that the very slow voltage ramp-up still properly resets the ATtiny on startup.

  6. Nice, again a topic I have to deal with sooner or later. Thank you for exploring it for us!

    Did you consider adding some extra parts for a fast charging feature to prime the supercap? Im thinking of a push button to temporarly increases the current or even something (transistor based?) that induces the fast charging automstically. -blub

    • Interesting idea. There are high voltages involved, and it has to be high-side due to the current sensor for measurements. Perhaps diode -> resistor -> capacitor -> zener etc, with a transistor or mosfet to short out the cap. Then again, it may not be needed – I’m also exploring using a much smaller cap at a higher voltage, perhaps 4700 µF @ 9V. Maybe there is just enough juice in that to work, in which case startup would be a matter of seconds. Anything under a minute would be acceptable for “normal” impatient use, IMO.

  7. X2’s are here. RS is never the cheapest, but handy for small quantities. Yes, other ratings can work at a pinch, but the size & price of X2’s is because of the construction and validation for direct mains connection, predominate failure mode is open circuit. With the 22nf suggested and a single 4.7K dropper, the worst case surge is ~70mA (well within the X2’s capability) and you will get ~90% of the benefit of a “pure” capacitive dropper. Using a 1/2W metal fusible (250v rating) improves the safety as you mentioned, and the charging current is modestly higher.

    • Great – I’ll try that, thanks!

    • One more Q comes to mind: if I use a diode in series to only power on half of the AC cycles, do I still need an X2 cap? My thinking is that it would in effect be a DC setup, perhaps less stressful? IOW, 4.7 kΩ fusible, diode, and 0.022 µF cap (with 470 kΩ in parallel for discharge), feeding a zener + reservoir cap.

  8. What about a FET between the resistors and the zener, switched by the ATTiny. If the cap has sufficient charge the ATTiny can disconnect the mains, and NO power will be used anymore.

    • It’s a thought, but probably not trivial: the FET will need to withstand 300V peak while off (there’s 0V over the resistor when no current is flowing), the startup process could be tricky, i.e. before the ATtiny has power it can’t keep the FET conducting, and with an N-MOSFET you need to create a voltage above the zener level to drive the FET because its drain will be at VCC level. Might all be solvable with a few extra components.

  9. You could also simulate your circuit with LTSpice (Free). I’m actually playing with the MSPNode and CR2303 battery power and simulating to predict the performance before measuring. It could be safe to simulate your AC setup before implementing it. Her’s a screenshot: http://www.flickr.com/photos/robomotic/6276598608/in/photostream :-p

  10. JC, responding to your X2 substitution question. Unfortunately, with a capacitive dropper, the topology changes to allow the capacitor to charge and discharge, else there is no reactive effect (cf: AN954A)

    A worst case failure check shows that zener open or capacitor short is bad (the fusible will eventually blow after the storage cap + downstream is already damaged).

    Why would the capacitor short? It is vunerable to spikes on the mains (e.g. lightening strike nearby) which punches through the electrolyte barrier. X2’s are designed to self-heal and carry on (albiet with a small loss of capacitance). Other constructions, even with a high voltage rating, aren’t and can fail short.

    Protecting the input with a VDR between the rails will work, but I suspect the cost then is similar to using an X2. Time limited experimentation is fine – it’s sitting in a wallbox for several years that is the concern.

    • Thanks (again) for the explanation. Ok, I have some 22 nF X2 C’s and 4.7 kΩ fusible R’s coming in to play with. I’ll use a 4.3V zener and 1N4148 after it to get it down to roughly under the 3.8V limit of the RFM12B module. With a bit of luck, a standard fat electrolytic cap might store enough energy to support a short xmit packet. The ATtiny will continue to work down to 1.8V.

      I’ll switch to simulation / calculation and charge consumption at some point, but for the time being this hands-on trial-and-error stuff suits me fine.

  11. Matthias, I’m not familiar with that IC – could you provide a reference please?

    Thanks

Comments are closed.