LED drivers and Accessories you want, but don’t exist

Just look at the PM, I sent you a picture. If it’s too small, open in new tab. LVP should be 3V or 2.9V.

Just simpler to ask. Ok. So that's a bit of trouble.

No time to explain right now, probably it will require LVP set at 3.1V, or high enough for tolerance to stay above the LDO. I'll explain later. OTSM has constraints on LVP and this doesn't fit the usual solutions very ideally.

So a little more detail. The issue is that to use the divider for LVP, the divider voltage must be kept above about 1.8V, (brushing over the details) to prevent off-click detection. To do that you need a high voltage reference to compare the voltage pin to. A 5.0V LDO on Vcc works well for that. 3.0V doesn't work as , more on that in a bit.

So for 1S builds, instead HD reads voltage from Vcc. But in that mode it's actually reading the battery voltage from Vcc, not some regulated LDO voltage. There are only two pins where the battery voltage can be read as a higher value than the internal reference used, those are Vcc and PB0 (only Vcc presently implemented in software). So that works for 1S with no LDO.

Now back to your thing. You can use the first method, but the problem is the voltage reading stops working once the battery hits the LDO level, or possibly slightly higher (some dropout in the LDO, not sure how much). Once the battery starts dropping below the LDO the sense voltage on pin7 and the reference voltage on Vcc start to drop at the same speed and the ratio doesn't change, so you peg the bottom of the scale there.

a) So this could work, but you'll lose sensitivity somewhere above the LDO voltage and must set LVP above that. You will also probably need different resistor values for the divider.

b) One suggestion would be to instead provide battery voltage to Vcc. You only need the LDO for the voltage filter not for Vcc. However, I'm guessing the reason you aren't doing that is that you don't want to use a separate protection diode. Speaking of which, you better use an LDO with low reverse leakage. I think the ones used on the small TA boards have worked.

c) Another possibility is to find an LDO that will work at 2.5V, but there's another problem you're running up against. OTSM doesn't have as much extra headroom at low Vcc. 2.5V may not work well at all, and/or may require more attention to good hardware selection as far as the cap and the leakage of the LDO. It could work though. My specs are a bit overstated, and exactly so that things like that might just work.

d) Yet another possibility is to make a hybrid voltage readout. So that it uses both Vcc read and Vcc referenced divider read. Vcc read will remain constant until hitting the LDO voltage, then it will drop and you can get extra range from that. From a software perspective though that could be tricky, because the way bistro polls the ADC, changing references requires delays, and there's already a switch back and forth from voltage to temperature and some difficulty orchestrating the timing for that. That's not my favorite solution.

e) Yet another option is to use a separate pin with a separate voltage divider, but I'm pretty sure you have no space for that.

Thanks a ton Schoki!
Lexel, I know it’s too early for a definitive answer, but what do you think about making a run? :slight_smile:

Ooh, just had another option come to mind.

f) Send battery voltage direct to PB0. I don't think anyone has ever used this trick, but the "internal" or "inverted" read method can be used on PB0. This does cost an extra trace but doesn't cost a diode. Why? Because it's a high impedance pin, unlike Vcc. It shouldn't need reverse voltage protection. Still not a free solution solution though. We were already out of room for a second PWM trace as it was.

No, this is great! That should work. There’s enough space for that. It’s just around the MP3431, where’s nearly no room for anything more. But how does this work then?
Use the PB0 as voltage reference for the voltage divider? Is that possible, even if the PB0 voltage is higher than the Vcc voltage?

Ok, I better really double check my facts then. I'll post back. 90% sure right now.

Well shoot, kind of remembered I can't see how any pin can take more than Vcc, and... it can't. You can use a reference there, but it can't be higher than Vcc.

Ok, so what about sending, OTSM pin over to PB0, so divider voltage connects to both the OTSM pin and PB0? Or maybe it only needs to use PB0? Oh.. yes, I think that's true. Can do OTSM on PB0 and inverted reads at the same time on it! These little chips have so many tricks up their sleeves.

It’s just a few changes for me, so if you can do it, that would be awesome. But how does this work? How can it distinguish a low battery from a turn-off?

And how can I cancel an Oshpark order I already paid for?

Now that I can use 4 layers, maybe I can move some traces to the inner layers and have a little more space for other stuff. I won’t move that much though, vias need a lot of space as well, maybe even more than some 6mil traces.

Probably can't cancel. But you can build the board as-is and just set LVP kind of high for first testing. It will still work.

So I use LVP and OTSM on same pin normally for LDO lights, but that's 5.0V LDO with 2S batteries. The LDO never drops out then. Still the LDO is just the reference. The LVP is still on the OTSM pin. That's ok, so long as you can keep the voltage on the pin above 0.6*Vcc. Normally to run the ADC in the range from 0.6V Vcc to Vcc you need the reference to be high and constant, so a 5.0V LDO on Vcc works.

This plan is different. This is the one case where we can use a lower internal reference. The inverted read trick actually "reads" the reference voltage with the pin voltage (Vcc or Pb0) as the "reference". Then you divide the result. So that's another way the batt voltage can be left high on the OTSM pin and still be able to read it. The difference doing it on Vcc vs PB0 is on Vcc you can't use the OTSM reduced batt voltage for a couple of reasons (breaks the whole voltage separation and pin detection of OTSM) but on PB0 in this case you must use the OTSM voltage, and it's perfect.

Yes, all these voltage read restrictions and possibilities in general and especially for OTSM are dizzying.

So what you want to do with your voltage divider is aim for about 4Kohm total, and for a full battery, 4.2V to come down to exactly the LDO voltage.

By the way, I did notice a statement in the manual that says if the PB0 reference voltage is above Vcc-1.0, the ADC will get less accurate. So... not sure how bad that is. Might require more research. However it is specced up to Vcc. We don't need 10 bit precision.

GRR… drat drat drat. Still one more caveat I missed on that

:person_facepalming:

The external reference must be above 2.0V. Sigh. That still only gets you a dynamic range from 4.2V to 2.7V if your resistors are pretty perfect, assuming 3.0V max read (Vcc). I wonder what exactly happens at 1.9V?

Now I got 2.8V LDOs (TPS706), and with a good resistor combination, pretty much 3V is the minimum (if I understand it correctly). The combination would be 1330Ω and 2670Ω.

And, do I understand it correctly?

Hmm, well 2.8V LDO's are looking worse for option f, but they help option a.

Yeah, with a 2.8V LDO option F leaves you at about 3.0V LVP, you understand that right, assuming the 2.0V AREF floor is hard. But option (a) gives you 2.8V LVP or close.

Now I like option a) again. 2.9 V LVP isn't bad. I was worried it might push up to 3.1 or 3.2. 2.9 is ok.

OK, now from all the different options I’m a little confused. What do I need to do for option a) again?

Umm, don’t count on that. The whole substrate can be treated as a (reverse-biased) diode, and hitting one pin with reverse voltage can essentially apply the whole battery voltage through that one pin and out one/both power pins.

Same danger with applying an input voltage to a pin higher than Vcc.

I think that's true if it's not tri stated. My experience with these little buggers is they are tough as nails. I don't in principle yeah giving negative 3V to a tristated pin is probably beyond spec, but I'd guess it survives it. I'm pretty sure I've done just about every bad thing it's possible to do to things with 4.2V several times, and not managed to harm one yet. Although most of that was brief contacts.

nothing. And I probably confused you, I meant a) and I think g) (not f) the last one we were talking about, that probably never got a letter. Anyway, a is the leave it alone option.

The concern with a) and a low LDO is OTSM performance being poor at that low of a voltage. But you're just running up against all the limits. If the LDO is higher, like 3.0V and you use option G to get LVP lower, the boost still won't control quite right at 2.7V, although, that's probably pretty minor. It will still control, just start dimming a bit.

I think you should give option a shot and see how it works out. You've already got the boards coming anyway. I'll package an OTSM debug hex for you so you can test OTSM timing on it. Oh yeah, reflashing isn't exactly easy, well that's the price of the qfn.

Getting info from avr freaks on the 2.0V AREF limit. Looks like there's a little cushion beyond that in practice, but it does eventually quit working, in the right direction though.

Update: So by spec the absolute minimum on any pin is -0.5V. Indeed reversing the battery would be out of spec on any pin. Actual damage is still up for question. Well, I may as well just test it. I figure if it stays under 40mA it should be ok, so I'll crank it down slowly and see what happens. Lightbringer's point make sense though. It's like if the pcb board becomes conductive, the resistors don't matter. Bigger problem is I guess I should desolder 7135's first. You squint the wrong way and those things go belly up, at least mine do.