Attiny25/45/85 FW Development Thread

I thought I read somewhere that you should use caps with at least double the rated voltage that the voltage you’d expect them to see.

A good rule to follow if you have plenty of space for the larger caps but the rating is there for a reason, cap will be fine up until that voltage. A safety margin is good, we should have about a 2.5v safty window from what we expect them to see in our case which is a 50% safety margin. More then enough IMO.

4V caps are pushing it for sure, although they would technically work they would have no margin for error.

Now AC caps play by different rules and with those I think you do need caps with twice the voltage rating to account for 2 or 3 phases of power.

Aight, thanks for the explanation. I still have to learn a lot about all this stuff. From now on, I think I’ll shut up for some time and let the experts do the talking. :slight_smile: Will follow with interest though.

Everyone has to learn somewhere.

When trying to cram things into as small of a space as possible some of the “ideal rules of thumb” have to be put aside in the interest of space. Particularly when cheap is an important factor as well.

Integrated the lighted tailcap parts in my OTC-less design: 1k bleeder and a 2.2k resistor in series with LED (low resistance since I only have outdated 5mm LEDs which need more current).
With the bleeder I was able to remove the 10k resistor (which sat at the same place).

Works flawless.

You may even try it with just the 10k you had and no additional bleeder. The bleeder was necessary to allow the OTC to drain. With no OTC, it might not be needed.

Tried it right now - doesn’t work with 10k and the chosen tailcap parts. Might be different when using larger series resistor and up-to-date-LED.

shows how much I know :zipper_mouth_face:

Actually ceramic caps get derated for DC voltage. The spec sheets all publish a curve for derating V vs applied dc voltage. But I don't think tantalum caps have that issue. They do get some thermal derating eventually as I described. They also like to explode when they aren't happy, but where's the fun without a litttle danger. Yeah, 6.3V probably isn't an ideal design margin, but it likely works. I'm still a bit confused on the tailcap. Will have to think about it later.

I missed that. may need some tuning/thought to keep battery monitoring (non-otc type) and and tailcap working. I guess the tailcap light Vf is creating voltage drop. Maybe have to tune things right, maybe much lower divider resitors for a lighted tailcap build.

Looking at the whole picture:

A bunch of things connect and overlap and something like this seems the right time to look at that. I am going to re-raise some things here that I just brought up in the TA thread and some is just recap of above.

First R5. Aparently DEL did lots of testing and R5 prevents ringing of C1 or elsewhere, reportedly because of LC. The resistor seems to tame it and that's a great result, the type of thing re-designs are in danger of missing However if significant current passes toward the mcu then current bypasses the voltage divider and creates a large drop across R5. I think for 4.7ohm R5 that's fine, but in the zener case you explicitly must/will have whatever drop the zener and schottky don't take, and so a bigger resistor is needed to take that load. Then R1/R2 is wired across two voltage-fixed diodes and doesn't seem to be measuring battery voltage at all. It seems to me the solution is maybe to use a tantalum C1 cap which doesn't have piezo effects and does have a couple of ohms of series resistance anyway. For the zener case if not others, series resitance can be added to the mcu path by moving R5 can be moved just left of (I'd prefer right of actually because of other ideas I have) of D1, and then R1 and the cap connect directly to batt+. This noise stuff can't really be predicted though. This change can't be verified without someone like DEL scoping it.

Next the voltage divider. This has traditionally been kept at the values it's at apparently to make OTC work, and even higher resistance for e-switch lights without a lighted tailcap, to conserve battery. It's traditionally been read off with the 1.1V ADC because 2.56V doesn't work for 1S lights when Vcc falls below 3V. Both those reasons are dissappearing. We now know how to read voltage of a 1S non-zener non-ldo setup from Vcc directly and only need to use the divider to read 2+S where Vcc doesn't represent the batt voltage. And the resistor values are no longer constrained by OTC, and we would now like to keep the sense voltage high, above whatever the digital threshold is (1.2V maybe, or 1/2 Vcc? I don't know, but it will be important actually).

This means a) we can/should use 2.56 targetted voltage dividing. b) the overall resistance doesn't need to be very high in non-e-switch lights. Why does the second part matter?

Now we get to the bleeder. For a tailcap, the tailcap led has a voltage drop accross it, Vf of the tailcap LED. Without a tail cap light the voltage from battery to case (basically C1 except in zener case before my mods) will collapse to zero. With a tailcap light it will drop to Vbatt-Vf_tailcap, because the case connects back to -Vbatt through the led. Then there is a still a big voltage change, across the divider at shutdown, but not as big as for a full shutdown. It can be tweaked some, but there are probably limits (using two tailcap led's in series would tweak it a bunch). So this may require some tuning, and hopefully can still be made to work. Ok, so I think I got my head around how that works now. But coming back to the other bits. In the past a bleeder resistor was added to give a relatively high current path from battery to the tailcap light. But maybe we removed the restriction now on R1+R2 being high resistance. Those are also a current path from battery to ground. So who needs a bleeder resistor? Just make those appropriately low. On the other hand, the bleeder resistor is not hurting, and there may be other restrictions on R1+r2, like how much current it feeds to the mcu pin in certain pin modes, so this is a final polishing not something to mess with at first probably.

So what I see at the moment is (and some of this wasn't my idea):

a) make C1 tantalum or add a resistor only in series with it (like between it and ground).

b) "Move" R5 it to right of D1, connecting R1 and C1 directly to batt+ allowing LVP to work for a zener setup.

d) use 2.56V reference for 2S+

e) fight with balancing different voltage demands of Voltage sense, digital threshold, and different voltage drops in lit tailcap and non-lit tailcap shuttoff conditions.

Can all of these be reconciled on one pin for any battery configuration only by changing divider values? The bleeder issue seems harder to deal with in 2+S as the Vf on the tail led becomes a smaller fraction. I have another idea involving getting a diode or two inline with the divider to drop some of the voltage instead of dividing it.

f) Use internal Vcc measure for 1S.

g) possibly remove the bleeder and lower R1 and R2 to bleeder-like values instead. Even if not going this low, going somewhat low should discharge C1 fast when/if there's no parallel bleeder resistor.

Part b is a circuit change unfortunately, but I don't see how the present circuit senses battery voltage for zener setups. This isn't really much related to the OTC. Part e it seems is the big issue and made more difficult I think by the tailcap lights.

R5 should not need to be moved. R5 IS the component that drops voltage for zener mods. The zener itself is only there for backup spikes during different operating modes. As I learned, if you just install the zener without the 200 ohm resistor it will simply burn due to having to drop all the voltage itself.

I understand that, but it doesn't need to be in series with the voltage sense too. Then the voltage sense is just sensing the zener and schottky voltage, not the battery voltage. LVP won't work with zener as it's setup now. R5 should be in series with the diodes, but not above the R1 attachment. Specifically, it should be next to D1 (either side).

The zener and schottky do keep a fixed voltage drop about 4.7V together probably. Of course the rest of the voltage is presented across R5. And (Vbatt-4.7)/R5 fixes the total current through the mcu and zener. But the divider (R1+R2) presently just spans 4.7V always in zener mode, regardless of battery charge. Once you get the first one working, you'll find that LVP doesn't work.

But R5 also serves to damp ringing. For that, a second resistance might be needed next to or built into the cap. That might not be needed either.

I am not understanding, or maybe you are not understanding how it is setup.

R5 > LVP > Didoe > zener > C2 > MCU

So R5 does drop the voltage as it should before all the components, in my tests a 200ohm resistor drops the voltage basically exactly in half to 1S voltages as seen by the LVP and MCU.

So the LVP sees the same voltage it is used to with a 1S setup (well technically it was ~.1v higher.) and with a little tweaking it should not even need to be recalibrated from the 1S LVP.

The diode blocks and effects from the zener from effecting the LVP, it also drops the MCU voltage to what it normally expects as well.

The zener was actually not even “activating” at all in my test, max voltage @ 8.4V as seen by the MCU was 4.275V. The zener is 4.3v.

You could technically leave the zener off altogether and it would work fine.

Hmm.. I see well if the zener isn't activating, the the mcu voltage isn't regulated. It wavers with its own current draw, and yeah, with the voltage of the battery too. Ok, I didn't see that, because it seems weird.

I would think even when mcu is drawing max current, you'd want at least a little current through the zener. Then you have voltage regulation. Yes, I wasn't understanding that it's running unregulated.

Yeah, that seems still bad for voltage sensing. Instead of having a constant voltage under R5, now you have a voltage that's waivering under the current draw of the mcu. Sure that will on average reduce as V batt reduces if it's not in regulation, but how stable is it. Does the mcu draw very steady current?

Well shoot, if this is really the case, I mean R1 is basically sensing the same thing as Vcc just plus the D1 Vf. So if Vcc is really considered to be a good enough measure of Vbatt, then you don't need to do LVP in R1 and R2 for zener setups either. Can still use Vcc. I'm not saying I love it, but might as well take advantage of it. Then the only time R1 is needed for LVP / battery monitor is in LDO builds.

The MCU doesn’t care if it is regulated or not, as long as the voltage doesn’t go above ~6v it will be fine. The zener is just there in case that tried to happen.

You do have a point that the LVP would follow the current draw, the classic way of doing it is to replace the diode with the 200ohm resistor but I wanted to keep the diode in place if possible. Easy enough to swap where the 200ohm resistor goes though.

Well, if 1S lights can work fine without a zener to regulate voltage, then what’s the problem here? I don’t know much about circuit design. But it seems that if you use a resistor to get the voltage down to the range that the MCU can use, instead of a zener, then you could get more useful readings for LVP and battcheck functions.

Yeah, ok, I get it. I just really had no idea the zener wasn't a regulator. So yeah, my confusion. You could also just check batt from a voltage divider off the actually battery though, which is what you'd have if you just move R5, but if the mcu draw is stable enough for battery monitoring, then ok.

But then we can just as well use the Vcc pin for LVP and battery monitoring and forget about the divider altogether. That certainly makes setting up OTC triggers easier.