Oh as for rude.. the button is right next to reply. I suspect that's the main cause. The op amp sounds good. It's the middle modes that are hard to get well with anything, and those are the modes I like.
In the grand scheme of things, spending $25 on a very advanced driver isn’t bad at all. Ok, so it’s not cheap, but what is these days and still holds value? So if we’re building a nice big light, it’s an essential qualifier for ultimate success. I don’t mind paying it, not every light would get a driver like this so it would remain a special build and would show the effort.
That’s one thing I’ve not understood fully… When the MCU is shut down, the OTC get’s discharged through the voltage divider? That means that the two separate pins are internally connected when the MCU is off?
I don’t understand it either but I have seen the effects first hand. Normal OTC calibration settings are in the high 100’s with the 19.1k but with the 22k resistor I had to bump it up to right at the limit of ~240 or so and it proved to be not as consistent in my testing. So I went back to 19.1k myself.
22k works fine, just more of a hassle to calibrate.
I’ve seen many report it so I don’t doubt it it all. I’d just like to understand why. Once I get home I’ll measure resistance over the pins on a MCU that isn’t connected to anything.
Sometimes when you think you understand something is when you haven't thought about it enough (referring to myself). I had missed a couple of details here at least.
Update: yeah, I was definitely confused. The rest of this is just silly, well except for the bit about the zener voltage sensing:
The zener situation is probably quite a bit different than the LDO situation. In either case though when ground is disconnected the mcu should continue to run powered by the cap(edit: I really was thinking about C1 here confusing it with OTC). The current draw on it is I guess 10x higher than the divider current so it runs fast until it reaches shutdown voltage in zener case or the ldo reaches its dropout limit in the ldo case. But this is fast compared to the divider RC anyway so doesn't contribute a significant lag. Obviously it impacts the t=0 cap voltage.
In the zener case I hadn't appreciated that the cap ) stays only at zener voltage (plus or minus the input diode vf) according to this diagram anyway:
In the LDO case it stays higher and for voltage monitoring while on that matters, but when turned off it still should drain down to a pretty similar level, but the voltage of the LDO should have a big impact on OTC timing I think, because it determines what voltage the cap is left at when it drops out. It seems this has to be higher for LDO than for zener so maybe there's some confusion comparing OTC when there's two different situations.
I assume the LDO and mcu shutdown with high resistance between vin/vcc and ground, but maybe that's different for the two cases also.
Now what I really don't get is the turn on. In either case if the mcu/ldo has enough voltage to turn back on, the cap must have already charged back up no? And always to the same level. So what's left to measure? It seems to me almost like a resistor is missing between the R5/R1 juncion and the cap (or between the cap and ground). Shouldn't the cap charging lag behind Vcc if the cap level is to be detectable? Maybe that would help with some of these "stability" issues? Obviously it works, and I'm still missing something. Still maybe it works for reasons that aren't well controlled? Or more likely it's just me.
As for price, yeah. we're talking $22 PLUS the board. What do these board run? $20 for three? Which is still $20 if you only need one. Still, yeah, the big brand lights are expensive too. Maybe folks will find ways to shave a few $. The first folks to try it better know they're taking a gamble though and just be in it "for science". I certainly make no guarantees on my part. You're lucky if this thing doesn't burn your house down.
Here goes. Hopefully I didn't mess anything up. Your risk, not mine. Only buy and build what YOU want. I have nothing to do with it. :)
Parts list for 16.8V input, 12V nominal output, driving 4p xhp-35 at 2.5A per LED, 576 khz, 10A total (can go higher, but it’s an experimental driver)
The Parts
(see shopping list below if impatient)
MCU: Attiny85 the normal one, attiny85-20SUR I believe is usually fine. V version is also fine I think. (However if driving with 4.2V an attiny85V should probably be used because this driver presently requires an LDO for the mcu even for 1S batteries and the LDO will need to operate below the lowest battery level, needs more thought though and wil require some resistor value changes)
LDO: MIC5235 3.0V (other voltages CAN work, but require some resistor value changes)
Buck IC: LM3409 10-MSOP-PowerPad (or EP)
Inductor, must be 17.15*17.15mm or very close. 10uH absolute minimum inductance. 30mohm max resistance.
Vishay IHLP6767GZER150M11 is a good choice since resistance matters most. It's very expensive though, $6!!, but other alternatives are about the same.
Diode, "8PowerTDFN" (might be compatible with similarly named footprints?) STPS30M60DJF-TR has a low 0.5V Vf and low leakage current when hot.
Mosfet:
Powerflat 5x6 p-channel FET (PFET), Infineon BSC084P03NS3 G Balances low Rdson with low gate capacitance. Gate charge divided by voltage should be less than ~12nF at worst. Half that is better. Rds on should probably be less than 20mOhm at worst. Low Rdson is good for high power. Low gate charge is good for low-current efficiency. It's usually some tradeoff.
Caps:
C2 10.uF 0805, Vcc bypass 4V minimum, 6.3V or more highly preferred, 10%
Cf 1uF 0603, Gate drive bypass, 16V 10%
C1 10uF 1206 , LDO input bypass, 35V 10%
Cf2 10uF 1206, Iadj voltage filter, 4V minimum (6.3 preferred). 10%, x7r preferred but 125C rated should do. Alternative: 220uF for soft mode transitions. Tantalum and high ESR (ohms even) are OK here.
Cin 10uF 1206 or 1210, Input cap, 35V 10%, two minimum, 3 x 1206’s should fit. 4 might fit and is even better. <20% dissipation factor at 1Mhz, 10% prefered.
Co 10uF 1206 or 1210, Output cap, 35V 10% One is enough but two is insurance. <10% dissipation factor (5 is better), with good performance up to 1Mhz.
Just buy ten of 1206 10 uF caps and you’re set. Cin and Co should be high quality caps.
Coff 470pf 0603 35V Buck off-time cap.
All caps should be ceramic unless stated, X7R or better strongly preferred (125C or higher rated) .
Resistors:
R1 220k 0603 for e-switch 22k for clicky maybe. (with OTC mods now under development, the clicky issue will dissappear)
R2 12k 0603 for e-switch, 1.2k for clicky maybe.
R5 4.7 ohm 0603 1/8 to 1/4 watt might be wise here, but 1/10 should be ok I think.
BR This has no purpose on this light. You can use the pads to get voltage for wiring something.
Rf2 3.9K 0603
Rf3 2.7K 0603 (Could use 4.7k and 3.3k also for a little softer mode transitions with the 220uF cap)
Roff 4.7k 0603 with the 470pf Cf, this will give very roughly 580 khz, which seems ok.
Rsense, 2512, current sense resistors, X 3. 0.074 ohm each, 2W rated, adjusted for max current, see below.
Ruv2, any value, 0-ohm is even ok. 4.7k is also fine for example
Ruv1, leave off.
All resistors should be 1% tolerance, rated for high temperature, 155C preferred, 1/10 W or more unless specified
Jumpers
You will need to jumper the battery pad to 4S for this setup. That requires 1 jumper. To my surprise most SMD jumpers are specced only at <50ohm. Vishay has some in 1218 and 2010 rated to < 4 or 5 mohms and 12 to 20 A for about $0.50 cents each. Personally, I'd just use some solid copper wire.
Adjustments
RSense
Max current occurs at 0.248V drop across Rsense.
So Rsense_total=0.248/Imax.
But there are three resistors, so if they are the same, they should each be:
Rses1=3*0.248/Imax. Err on the high side of resistance values to be safe.
But no software adjustment can ever make the current higher than the max value set here.
Ex: 2.5A for xph35*4= 10A total.
Rses= 3*0.248/10=0.074 , closest match, 0.075 ok.
Soft mode transitions:
To achieve slow (~0.33 s RC) you can use a Cf2 of 220uF and adjust speed by increasing or decreasing Rf2 and Rf3. Some options are:
Rf2: 3.9K, Rf3: 2.7K (flintrock's favorite) ~0.35s RC time
Rf2 4.7K, Rf3 3.3K ~.43s RC time requires one less new value. Much larger and the current control circuit gets an offset, but it should be < 0.7% offset with these values still. Twice as high could still be ok but I think these RC values should feel nice. PWM will be used to get lowest modes anyway so a small control offset is ok.
These are chosen to prioritize standard resistor values, but either matches the max control voltage to better than 1.2% after bias current correction. For best precision you can use a 1.02K and a 715ohm, but won’t get very soft mode transitions and probably won’t notice the precision improvement. If you’re using a 10uF cap anyway, then you can as well use these lower resistor values.
Expert tuning:
Roff:
In brief, increasing Roff decreases buck frequency, nearly proportionally, and of course decreasing Roff increases frequency. You can vary it by about twice in either direction. Higher frequency uses more switching power which is important for low power modes, however lower frequency has more ripple current which also impacts low power modes. For middle modes, low frequency is best. For lowest modes, it's not clear yet (maybe never will be).
The frequency of the buck is determined by the offtime and the duty cycle. The duty cycle is approximately Vo/Vin. The off time is given by equation 4 in the manual:
or approximated by equation 6 (might as well use 4).
The frequency is (1-Vo/Vin)/t_off. As Vin gets very close to Vo this approaches 0 frequency, so as you near direct drive for low batteries or high current, the buck just stays on. For 16.8V in and 12 to 13V out, a good frequency target is probably around 500khz.
Iadj:
Rf2, Rf3, Cf2, LDO voltage, and a pwm duty cycle all determine the current set point. This set point is controlled by a voltage intput to the IC and you can read about how that's achieved here:
Only duty cycle should really need to be adjusted though (through software modes) for current control. Max current is adjusted with the sense resistor, not with this. Of course software could limit the duty cycle, but that’s not the safest approach to limiting current.
LM3409 low voltage shutoff
Ruv1, Ruv2 are the voltage divider for buck IC shutoff. This is redundant with MCU shutoff. You can leave off Ruv1 entirely and use pretty much any value at all for Ruv2 then. This will disable this feature.
If you want to use this feature, there are two concerns, the cuttoff value and the hysteresis. If the IC cuts off at 2.7V but the unloaded battery voltage recovers to 3.1V and the hysteresis is only 0.1V, it will immediately turn back on because the IC is still powered. There is no mechanism to interface this with software to lock out or lower the mode, so it will probably flicker on and off. Best is probably to have very large hysteresis. Presumably a power cycle will reset the hysteresis and mode programming that starts in low modes could allow the light to be turned back on at lower power, so the best solution is probably to use a large hysteresis. Hysteresisis in volts per cell h is:
h=.000011*V*Ruv2
Then
Ruv1=1.24*Ruv2/(Voff-1.24)
So a 110k Ruv2 would give 1.2V/cell hysteresis, should be enough, and pairs well with a 33k Ruv1 for a 2.7V cuttoff, 36k for 2.5V, or 30k for 2.9V. These are not included in the default shopping list. The default shopping list leaves this feature disabled.
Shopping list
Digikey carts will apparently expire and they only work on digikey.
This is better:
References
Quantity
digikey
Description
U1
1
ATTINY85-20SURCT-ND
IC MCU 8BIT 8KB FLASH 8SOIC
LDO
1
576-2783-1-ND
IC REG LDO 3V 0.15A SOT23-5
U2
1
LM3409MY/NOPBCT-ND
IC LED DRIVER CTRLR DIM 10MSOP
L1
1
541-1287-1-ND
FIXED IND 15UH 14A 14.4 MOHM SMD
D1
1
497-12421-1-ND
DIODE SCHOTTKY 60V 30A POWERFLAT
Q1
1
BSC084P03NS3 GCT-ND
MOSFET P-CH 30V 14.9A TDSON-8
C2
10
1276-2872-1-ND
CAP CER 10UF 16V X7R 0805
Cf
1
311-1446-1-ND
CAP CER 1UF 16V X7R 0603
Cf2,Cin,Co,C1
10
1276-6767-1-ND
CAP CER 10UF 50V X7R 1206
Cf2 alternate
1
490-13970-1-ND
CAP CER 220UF 6.3V X5R 1206
Coff
10
1276-1094-1-ND
CAP CER 470PF 50V X7R 0603
R1
10
311-220KHRCT-ND
RES SMD 220K OHM 1% 1/10W 0603
R2
10
311-12.0KHRCT-ND
RES SMD 12K OHM 1% 1/10W 0603
Roff, Ruv1
10
311-4.70KHRCT-ND
RES SMD 4.7K OHM 1% 1/10W 0603
R5
10
RNCP0603FTD4R70CT-ND
RES SMD 4.7 OHM 1% 1/8W 060
Rf2
10
311-3.90KHRCT-ND
RES SMD 3.9K OHM 1% 1/10W 0603
Rf3
10
311-2.70KHRCT-ND
RES SMD 2.7K OHM 1% 1/10W 0603
Rsns
3
696-1670-1-ND
RES SMD 0.075 OHM 1% 2W 2512
See section above about the battery contact jumper, not listed in this table.
The 10 uf 1206 Ci Co caps keep going on backorder. That's because they are cheap and seem to be really nice caps.
These are an alternative, at twice the price, and slightly worse ESR, but still good and maybe available much faster: 1276-3103-1-ND, or 1276-3102-1-ND
And cut the table above and hit paste in the browser tool, and "complete" (hit complete several times actually, waiting for it to update between each, seems to help) to get shopping carts at all digikey, mouser, Newark, Farnell, (no arrow :() .. Click the add to cart icon on each to automatically create a shopping cart on any of them. Click "copy" and you get a table with part numbers from all of them. It's pretty nice actually. Of course a few parts are missing at mouser etc because these were chosen at digikey.
Updates, changed C2 to 10uf and now 0805, as needed for LDO. Chanted R1 and R2 to work with 1.1V reference as now standard in bistro.
-Removed JMP from cart, added Jumper section for battery jumper explanation.
-Updated description of BR in line with this board.
Most of those resistors are chosen as the cheapest, not the best. You can get lower temperature coefficients for a price. TA says many of the big parts are also maybe cheaper on Mouser. I think that was arrow. Anyway, mouser is actually a few cents more.
Like buying a Corvette and going to Discount tire for the 4 for $99 special when you need tires… Why are those the cheapest resistors? I plan to build this driver, I don’t want the cheapest, I want the best or it isn’t worth the time y’all have spent sorting all this out.
Nah, it's more like getting it with stock tires actually. These are all 100ppm/C which is quite good actually. For 100C delta (so up to 125C absolute) that means 1% change, so at most you're at 2% total off the nominal value then. Yes for 2 resistors that could be read as 4% total, but it's not since the thermal coefficient isn't random, and both heat up the same way.
In fact though having two in every divider means it's almost no effect at all since they both change in the same direction. This won't hurt performance. The worst it will do is mean your max mode 0.5% different than what you think, as if it will really be that close even if we did use 0.1% resistors. Of course you can order what you want, but I think these are actually the most sensible. Anything more is probably like probably like buying gold plated fuses for the AC input to your audio amp.
I suppose I might not have been careful to match brands for dividers. I probably could do that at least. I'll give it a look when I get a chance.
I measured resistance from PBx pins to both VCC and GND on an unconnected MCU. I got varying results but the lowest was in the 4 to 5 mega ohms range. Things are probably different when it’s mounted on a driver.
I didn’t think about the zener case either. In any case I’d guess that a driver with the LDO solution would provide more stable readings than one with the zener solution, or at least differently. The zener does what it does, it’s passive, but the output pin of the LDO probably behaves differently when there is no input voltage.
The off time cap is measured before it gets any voltage. The cap doesn’t get charged until the pin it sits on is set to output high in the firmware, at least this is the normal method in “standard” driver designs if things haven’t changed lately.
Updated cart above. To give an idea how powerful that browser tool I linked is.. it generated this for me from my table above, and populated my shopping carts for all of them:
(NOTE THIS IS NOW DEMONSTRATION ONLY, NOT CORRECT COMPONENTS)
References
Qty
Description
Manufacturer
MPN
Manufacturer
MPN
Digikey
Mouser
RS
Newark
Farnell
U1
1
IC MCU 8BIT 8KB FLASH 8SOIC
Atmel
ATTINY85-20SUR
ATTINY85-20SURCT-ND
556ATTINY8520SUR
68T3811
LDO
1
IC REG LDO 3V 0.15A SOT23-5
Microchip
MIC5235-3.0YM5-TR
576-2783-1-ND
998MIC52353.0YM5TR
71Y1742
U2
1
IC LED DRIVER CTRLR DIM 10MSOP
Texas Instruments
LM3409MY/NOPB
LM3409MY/NOPBCT-ND
926LM3409MY/NOPB
7615678
14R4586
1735797
L1
1
FIXED IND 15UH 14A 14.4 MOHM SMD
Vishay Dale
IHLP6767GZER150M11
541-1287-1-ND
70IHLP6767GZER150M1
7487615
13T1269
1845594
D1
1
DIODE SCHOTTKY 60V 30A POWERFLAT
STMicroelectronics
STPS30M60DJF-TR
497-12421-1-ND
511STPS30M60DJFTR
8290456
97W2993
2325863
Q1
1
MOSFET P-CH 30V 14.9A TDSON-8
Infineon
BSC084P03NS3GATMA1
Infineon
BSC084P03NS3GATMA1
BSC084P03NS3 GCT-ND
726BSC084P03NS3EG
C1
1
CAP CER 10UF 25V X7S 0805
Murata
GRM21BC71E106KE11L
490-10496-1-ND
81GRM21BC71E106KE1L
8851764
96Y9268
2611935
C2
10
CAP CER 0.1UF 16V X7R 0603
Yageo
CC0603KRX7R7BB104
311-1088-1-ND
603CC603KRX7R7BB104
6698763
68R4769
432210
Cf
1
CAP CER 1UF 16V X7R 0603
Yageo
CC0603KRX7R7BB105
311-1446-1-ND
603CC603KRX7R7BB105
68R4770
1458900
Cf2,Cin,Co
10
CAP CER 10UF 50V X7R 1206
Kemet
C1206C104M5RACTU
Kemet
C1206C104M5RACTU
1276-6767-1-ND
603CC206KKX5R8BB106
14N2184
2581103
Cf2 alternate
1
CAP CER 220UF 6.3V X5R 1206
Murata
GRM31CR60J227ME11L
490-13970-1-ND
81GRM31CR60J227ME1L
55Y9932
2494472
Coff
10
CAP CER 470PF 50V X7R 0603
Samsung
CL10B471KB8NNNC
1276-1094-1-ND
7665238
JMP
1
RES SMD 0.0 OHM JUMPER 3/4W 2010
Yageo
RC2010JK-070RL
YAG3380CT-ND
603RC2010JK070RL
98K7919
9235523
R1 eswitch
10
RES SMD 360K OHM 1% 1/10W 0603
Yageo
RC0603FR-0736KL
311-360KHRCT-ND
603RC0603FR073K6L
68R0080
1799338
R1 clickie
10
RES SMD 36K OHM 1% 1/10W 0603
Yageo
RC0603FR-0736KL
311-36.0KHRCT-ND
603RC0603FR073K6L
68R0080
1799338
R2 eswitch
10
RES SMD 47K OHM 1% 1/10W 0603
Yageo
RC0603FR-0747KL
311-47.0KHRCT-ND
603RC0603FR074K7L
5047363
68R0098
2146120
R2clk, Roff
10
RES SMD 4.7K OHM 1% 1/10W 0603
Yageo
RC0603FR-0747KL
311-4.70KHRCT-ND
603RC0603FR074K7L
5047363
68R0098
2146120
R5
10
RES SMD 4.7 OHM 1% 1/8W 060
Vishay
MCT06030C4708FP500
Vishay
MCT06030C4708FP500
RNCP0603FTD4R70CT-ND
594MCT06030C4701FP5
96Y9432
2614446
Rf2
10
RES SMD 3.9K OHM 1% 1/10W 0603
Yageo
RC0603FR-07390KL
311-3.90KHRCT-ND
603RC0603FR0739KL
5046916
68R0081
2143821
Rf3
10
RES SMD 2.7K OHM 1% 1/10W 0603
Yageo
RC0603FR-07270KL
311-2.70KHRCT-ND
603RC0603FR0727KL
68R0067
2136427
Rsns
3
RES SMD 0.075 OHM 1% 2W 2512
International Resistive
LRC-LR2512LF-01-R075-F
International Resistive
LRC-LR2512LF-01-R075-F
696-1670-1-ND
66LR2512LFR075F
7717792
88K2583
1254661
It's also possible to feed it alternate MPN's for each row so that the cart will get filled for all vendors.
Ah.. yes, Now I remember being confused about THAT when I saw it before. I now got C1 and OTC confused... well, because there is no OTC in this driver! Never mind. C1 is I guess only a bypass and maybe useful for the bleeder. Somehow I had that right in my parts description, just a not-so momentary lapse of reason.
Very nice work, I am busy today but I will sit down and check out those items later along with tweaking the driver to see about removing the jumper and squeezing a 1206 cap in there.
Also curious how arrow will compare in the final price outcome. Particularly with free shipping they have now.