I had read that part too, but I had understood it as: if the power supply / battery connected to VBAT (my supercap) cannot support this current injection (it certainly can) it is strongly recommended… so I thought I wouldn’t need the diode.
So, this seems to say, the protection diodes are only suggested if the battery/power supply can’t handle the current. It seems that it is not to protect the Photon, but the battery/cap. Did I read that wrong?
@Jack, it is to protect the battery/cap since it is a reverse flow condition. Drawing too much reverse current on the Vbat pin will also damage it. NO, THIS IS NOT FOR CHARGING THE BATTERY/CAP!!!
This is not really an efficient way to learn this stuff. Can I recommend that you get and read the book “The Art of Electronics” by Horowitz and Hill? This will give you a good understanding of the fundamentals of electronics. It is an expensive book to buy but your local library might have a copy to borrow.
To answer your exact question: Under some circumstances current can exit the VBAT pin through a diode normally used to protect the VBAT input from ESD (static discharge). These diodes are not made to have current go through them for long periods and allowing current to flow in this manner will degrade and could even harm the STM processor chip. These ESD protection diodes try to “spread-out” the effect of a static discharge by returning the current across a wide area of the chip, but this exact feature makes these diodes bad to use for normal current flow since eddy currents are induced in the chip in strange places.
The processor datasheet recommends that you add a diode to prevent this current flow but the diode is only needed in certain circuit configurations, so in the case where 3.3V and VBAT are tied together, for instance, no diode is needed since 3.3V can never be at a higher voltage than VBAT. In other cases the diode is absolutely required. In still other cases, it might be optional. I am not going to get into all the design possibilities here, but if you want to learn about this, I would suggest starting with that one book I mention above.
As an example, we recently had someone here in the forum with a reset problem and the problem turned out to be that they had effectively tied the reset input of the processor via a resistor to +5V instead of +3.3V. This caused the protection diode on the reset input to have current flow through it which made the processor impossible to reset via software even though most other functions worked. These kinds of problems are sometimes very hard to debug.
Sorry if I’m beating a dead horse here, but I’m very intrigued by the idea of using a supercap to keep the RTC powered.
I’d like to avoid the separate 3.3 power supply and was wondering if charging via the VIN line would work. I’ve drawn a little diagram that adds a voltage regulator on VIN to bring it down to 3.3:
It looks mostly like the circuit in the datasheet, so the super-cap diode part is OK. I still don’t like the two diode drops but what can you do with minimal circuitry. The 15 ohm at 1W seems OK but has only about 25% power margin–in practice I think this is OK since you will not be charging the super-cap from zero very often.
The part I do not understand is why you need a separate 3.3V (linear) regulator? This seems redundant to one already on the Photon. Why not just connect to 3.3V from the Photon regulator?
If you are going for a UL/CSA rating, you should think about the safety of the super-cap versus a coin cell. I don’t have any direct experience there but I have seen a super-cap fire! Loud bang, lots of excitement. I have seen coin cells get very hot too but not in the same way. I honestly don’t know which would be safer and I have always had good luck with Panasonic caps.
Edit for one more thought: The choice of super-cap versus coin cell really comes down to replacement when dead. The super-cap has a longer life with less maintenance.
Please excuse my ignorance, but it seemed like the consensus in this discussion was that the Photon's 3.3 line wouldn't provide enough current to charge the supercap. That's why I've tied into VIN in my diagram and need a linear regulator to bring it down to 3.3
Also note that this circuit will NOT work with the Photon's onboard 3.3v regulator since it will not source the 300ma or so you need to charge the supercap. This will mean using an external 3.3v supply.
Am I interpreting the discussion wrong? Do you think this would work with the 3.3 line and I can ditch the additional linear voltage regulator?
It is a lot of current (an extra 220mA with the 15ohm) for the little on-board regulator, but it only draws that current when plugged in after a long discharge. If you hold the processor in reset for longer during this power up my feeling is that it would like be OK. Testing would certainly be required.
A separate regulator would be better in some ways, but not necessarily a linear regulator with the attendant heat produced, depending your power and packaging requirements.
Why not use a higher value charging resistor ? It would increase the charge time, but if your design duty-cycle can bear it, it might be a worthwhile trade-off.
You’re right, of course. Let me put down some numbers, for me and others—I just picked up this project again from where I left it last year!
A choice of R1 = 47Ω would limit the current to max 66mA (assuming D1 drops at least 0.2V, probably more during active charging) and dissipate max 0.20W. I’m not an engineer, but that looks a bit too close to 0.25W, so one would need a 0.5W resistor to be safe. Charging time (5×RC) of a 1.5F cap would be 6 minutes.
A choice of R1 = 100Ω will limit the current to 31mA, max power 0.1W, so a common 1/4W resistor would be fine. Charging time for 1.5F would be 12 minutes.
In the same manner, R1 = 220Ω will give 14mA, 0.04W and a charging time of half an hour.
As a bonus, all of these options are well within the 100mA max load of the 3V3 pin, so one could use the internal regulator to charge the cap (remember to sum all loads connected to the pin!)
I’ll go with 220Ω, because the charging time of half an hour does not bother me at all, and let you know how it performs in practice.
I make proto by this scheme.
I use 1F Panasonic supercap, 1N5817 diods and three 100 Om resistors in parallel.
Full charge take 20-30 min, first 5 min most critical, V max was 3,19 V
After this I turn of usb and monitor V on Vbat
Here my measures of Vbat in time:
And here graph with logarithmic approximation (R2 = 0,9987)
Confirmed- burned out 2 STM32F103’s today due to a backwards diode… When you allow voltage to flow out of VB, it burns out the VB circuit entirely; and welds it to VSS. luckily I caught it before entirely melting the chips, so I can still use them for stupid tests (like overclocking longevity testing)
btw, the vbat capacitor I was using was only a 1000uF; so it does not take much to melt the VB circuit on the chip.
I never took any precise measures, but I can confirm that with the schematic and values we discussed above, the cap charges ok and holds the system clock for hours or even days.
Definitely a better solution than a coin cell battery, if your project only needs to have the clock and RAM survive the occasional blackout.