thefreeman linear HDR drivers with super low moonlight building instructions (deprecated)

Deprecated, next version will use the DAC for lower component count.

LIN14_HDR & LIN18_HDR linear constant current drivers capable of very low moonlight levels


Here are two linear drivers (with super original names) with building instructions, like all the drivers I’m developing they use two current sense resistors to achieve super low moonlight. There is a small one with 14mm clearance and a bigger one with 18mm clearance that can be declined in various final diameters.

I hadn’t planned at first to make linear based drivers but they do have some advantages compared to switching topologies, they require less components, are less costly, can be made more compact and more power dense, easier to build and are guaranteed to be completely silent. Their major downside is the lower efficiency but it is still better than FET direct drive and 7135 PWM drivers.

List of features :

  • 14 and 18mm clearance diameter
  • Li-ion 3.7V 1S to 1S LED, or 2S to 2S LEDs
  • Constant current regulation
  • HDR : 1 000 000:1 max dimming range
  • Reverse polarity protection
  • E-switch Anduril 2
  • Attiny1616 : 3 wires flashing, factory calibrated temperature sensor
  • 3 AUX LEDs (LIN18), 1 AUX LED (LIN14)
  • 10.5mm (LIN18) and 6.5mm (LIN14) spring solder pad
  • 0603 passives, one sided(1) (LIN18), double sided (LIN14)

Oshpark links : https://oshpark.com/profiles/thefreeman

LIN18_HDR_22mm :

LIN14_HDR_17mm

Ask if you need other sizes based of those two.

LIN-FWAA_HDR (based on Sunnysunsun measurements)

BOM

Capacitors : 0603 X7R or X5R, >10V

Resistors except R7 : 0603, 1%

R7 (LIN14) : 0805, 1%, with sufficient wattage

R7 (LIN18) : 1206 (preferred) or 0805, 1%, with sufficient wattage

Mouser cart : https://www.mouser.fr/ProjectManager/ProjectDetail.aspx?AccessID=8d5e6750d8

(Contains both 0805 (LIN14) and 1206(LIN18) for R7, both R8 values for minimum PWM levels of 1/1023 and 2/1023, both LFPAK33 (LIN14) and LFPAK56 (LIN18) NFET, no OTC)

Configured for 5A:5uA max:min

R1/R2 : 100k, or more, Vbatt voltage divider, internal VREF is modified in fsm-adc.c to 2.5V (1.1V default) to allow R1=R2.

(R1/R2 for 2S : 280k/100k)

R3 : 169k, top R of Vsence voltage divider, Vsense = VCC*R4/(R4+R3), VCC = 2.8V, here Vsence = 53.6mV.

R4 : 3.3k, bottom R of Vsense voltage divider, R part of the RC filter for the PWM signal.

R5 : 3.3k, part of the compensator network for the op-amp.

R6 : 1k, part of the compensator network for the op-amp.

R7 : 8mR, part of HI-Rsense : high current (low value) Rsense, other part is Q2 RDS(ON) (≈2mR) and some stray resistance (~0.5mR).

R8 : 10.7R, LI-Rsence : low current (high value) Rsense.

R9 : 100k, HDR FET gate resistor, R part of the RC delay for the HDR FET, if software delay, replace with 47R-1k

R10 : 100R, C6 discharge current limiter to protect the MCU’s pin, if software delay leave unpopulated.

C1/C2 : 1uF, input and output C for the LDO.

C3 : 470nF, C part of the RC filter for the PWM signal.

C4 : 1nF, compensator for the op-amp.

C5 : 100nF, decoupling for the op-amp.

C6 : 100nF, C part of the RC delay for the HDR FET, if software delay leave unpopulated.

OTC : 1uF, OTC for clicky switch, for e-switch (Anduril) leave unpopulated.

U1 : MIC5365-2.8YC5-TR/MIC5366-2.8YC5-TR , 2.8V LDO, SC-70, 5366 has an additional (irrelevant) function and cost slightly more, choose it if 5365 is out of stock.

(U1 for 2S : NCP502SQ28T2G)

U2 : OPA333AIDCK/TLV333IDCK or MCP6V66UT-E/LTY (untested) , Op-Amp, SC-70, TLV333 is identical to OPA333 but cheaper. (DCKR and DCKT refer quantity per reel, choose the cheapest available)

U3 : ATTINY1616-M , MCU, VQFN-20. (MNR and MFR refer to the temperature range, both are suitable)

Q1 (LIN14) : PSMN2R0-25MLDX, linear NFET, LFPAK33 (3.3x3.3mm)

Q1 (LIN18) : PSMN0R925YLC, LFPAK56 (5x6mm)

Q2 : DMN22M5UFG , HDR NFET, PowerDI3333 (3.3x3.3mm)

Q2 alternatives if DMN22M5UFG is out of stock : SISS80DN (≈2.5mR) or DMN1004UFV (≈3.5~4mR), R7 needs to be decreased by 0.5 or 2mR (see how to configure my current section), both are untested.

Q3 : RE1C001ZPTL, reverse polarity protection PFET, SOT-416/SC-75, can fit SC-89, SOT-523, SOT-723.

(Q3 for 2S input must have Vgs < -10V)

D1 : RB501SM-30FHT2R, Schottky diode, SOD-523, fast discharge path for C6, if software delay leave unpopulated.

Edit : changed R6 to 1k (from 10k)

Notes

Components availability is... pretty bad, the three critical components are the Attiny1616, the Op-Amp and the HDR FET.

  • Mouser expects new 1616s in November, Digikey in September and October
  • For the Op-Qmp it’s not better, the OPA333 is out of stock until 2022, Mouser has a small amount of TLV333 in stock which won't last long, a few days probably, with a few more coming in November. Mouser had 2000 MCP6V66 a few days ago but they’re gone...
  • Mouser was supposed to receive new DMN22M5UFG-7s a few days ago, status is ”pending” not sure what that means.

Because there isn’t full Anduril support for the dual sense resistor circuit, I added components to delay the HDR FET, this delay is needed to prevent a flash when ramping up at the transition of the low and high current ranges. This flash can be hidden by the mid ramp blink but since it blinks only in smooth ramping that doesn’t work for the stepped ramp.

(1)LIN18_HDR is one sided… sort of, only when there is full Anduril support and the back components can be omitted.

LIN14_HDR doesn't have these components so until full Anduril support it is only usable in smooth ramping with the blink.

I haven’t tested 2S operation.

The board I tested was a previous version, 18-22m with a LFPAK33 FET for Q1, with 4 LEDs, high input voltage and in open air (pretty bad conditions), the FET was quite hot so I decided to use a bigger package for the LIN18 version, which should have better thermal transfer to the PCB.

I added a PFET for reverse polarity protection and that’s pretty much it for the differences.

How to configure the maximum current

(hardware, the current can always be lowered in software afterwards)

The max current is configured with a combination of Vsense and HI-Rsense (high current Rsense) :

I = Vsense/HI-Rsense

Vsense is set by the R3/R4 voltage divider, R4 is tied to C3 for smoothing the PWM signal into an analog voltage so it is preferable to adjust R3.

R3 = R4*(VCC-Vsense)/Vsense

With VCC = 2.8V (LDO output voltage)

HI-Rsense = R7 + Q2RDS(ON) + stray resistance

Q2RDS(ON) ≈ 2mR, stray resistance ≈ 0.5mR (traces resistance ≈ 0.2mR, sense resistors measuring a little higher than rated, at least the 0805 ones I have ≈ +0.3mR, hopefully will be lower with 1206 sense resistors)

In general 50mV Vsense is a good value to use

For HI-Rsense I recommend staying above 6mR, this is because Q2RdsON is not as consistent as a resistor, there is some variation between parts and it increases more with temperature.

Example for 6A :

Starting with Vsense = 50mV

HI-Rsense = 50/6 = 8.33mR, let’s chose R7 = 6mR, giving HI-Rsense ≈ 6+2+0.5 ≈ 8.5mR

Now Vsense = 8.5*6 = 51mV

R3 = 3.3k*(2.8-0.051)/0.051 = 177.9k , closest E96 value under that : 174k.

Max power in R7 : 6*6^2 = 216mW

Alternatively we can keep the R7 proposed value for 5A (8mR) and bump the Vsense voltage to (8+2+0.5)*6 = 63mV by using R3 = 140k (Vsense = 64.5mV)



Example for 12A :

R7 = 4mR, HI-Rsense ≈ 4+2+0.5 ≈ 6.5mR

Vsense = 12A * 6.5mR = 78mV

R3 = 3.3k*(2.8-0.078)/0.078=115.2k , closest E96 value under that : 115k

Max power in R7 : 4*12^2= 576mW, use a 1W 1206 resistor.




How to calculate R8 (low current Rsense)

R8 is tied to HI-Rsense and the lowest PWM value used in the HI-range, R8 must be so that the top of the LI-range and the bottom of the HI-range have the same current.

If we use the 1/1023 PWM level, then R8 = HI-Rsense * 1023/1

If we use 2/1023 as the min PWM level, R8 = HI-Rsense * 1023/2… etc.

The reason to not use the lowest PWM level is that in some cases, with a 50mV full scale Vsense, the 1/1023 PWM level can slightly flicker, from the drivers I’ve built it’s not common but I have seen it a couple of times.

So, if the maximum dimming range of 1 000 000 : 1 is preferred, use the lowest PWM level (1/1023), at worst if it is unstable, the bottom of the LI-range PWM level can be configured to 2/1023, while the bottom of the HI-Range stays at 1/1023, giving 500 000 : 1.

If 250 000 : 1 is enough then set the minimum at 2/1023 on both ranges, with R8 = HI-Rsense * 1023/2.

How much current ?

The power dissipated in Q1 is heavily dependent on the Vf of the LED(s) (more LEDs = lower Vf) and input voltage.

The LFPAK56 version should handle any current with 4 LEDs, LFPAK33 any current with one LED, further tests needed to confirm with 4 LEDs.

Assuming a total resistance minus Q1 of 50mΩ (25m cell, 10m springs, 10m HI-Rsense, 5m wires)

Reserved

Reserved

Let’s talk about the Anduril patch you wanted: I can look at it tomorrow if that helps.

Is there really a need for a sense resistor for these low modes? I’m no hardware whiz but what about using a DAC pin to control a simple current amplifier, 1 transistor and 2 resistors back in the old days? I don’t know how it would be done now.

It would sure help yes :smiley:
The other solution as mentionned in the first post is the mid ramp blink (BLINK_AT_RAMP_MIDDLE), but it doesn’t blink in stepped ramp (maybe it does if the step falls exactly on the blink ramp level?), so maybe modifiying the code so that it also blinks in stepped ramp is simpler comparing to adding a delay.
(Edit : although the the blink wouldn’t help in the case of the startup flash in the MP3431, as opposed to a delay)

Low modes can be done with a second channel, with a small NFET and a current limiting resistor, dimmed with PWM.

Pros : it’s simpler, about 50c cheaper.
Cons : output varies with battery voltage (not constant current), PWM.

Anduril doesn’t have DAC support.

Hmm, where does the cost saving come from? The 1616 already has several DACs but I’m sure there are issues I don’t understand. Avoiding PWM is really nice. It is ok if there is a little bit of nonlinearity in the amplifier and that the brightness varies slightly with battery voltage. The user can always adjust to their preference. We might want a logarithmic amplifier to widen dynamic range, since the dacs are just 8 bits. I don’t know how to implement that though.

Ok, I will look at the other thread and see if I can figure out what delay is needed, but I may still have a question or two.

Is there any software obstacle to using the DAC? I can ask ToyKeeper about it but I would have thought it was a fairly straightforward matter to configure the pin and read the voltage. I do remember something about it coming up before though.

Attiny1616 we have these microcontrollers available for purchase. Price $ 1 when buying from 70 pieces.
But I did not see any explanations about the firmware for this driver.

In the case of using a additional FET+resistor channel the HDR FET can be omitted, so it’s from that.

I don’t really understand how to make a amplifier circuit with just two resistors that will work in this case, but I’m not too knowledgeable about BJTs.

No idea, I know that Mike C used it in his firmware.

I’m not sure what to think of the DAC, it has some advantages but also inconvenients :

  • It doesn’t need to pass through a LPF contrary to the PWM signal, so that’s two passives less (one in the linear driver because it can use a combined voltage divider/LPF)
  • No problem with the flash since again : no LFP. The transition between the low and high current range can be mostly invisible since there is no need of a delay or blink.
  • It uses the internal reference so no need to supply the MCU with a fixed voltage. Although in the case of a dual sense resistor circuit, the HDR FET need to be driven at a fixed voltage to get a (relatively) constant RDSON, or it can be taken out of the equation by using a mux, but in the end might as well use a LDO instead.
  • Can lower the sytem clock speed to save power.

Cons

  • It’s limited to 8 bits, that makes the smooth ramp more coarse at the bottom of the high current range, as well a decreases the dimming ratio. Although Mike C, before using the dual sense resistor circuit, achieved more than 10bits by switching between the 0.55 Vref and 2.5 Vref (but I think he said that there were some issues with this ). Another solution is to use 3 senses resistors to compensate the lower resolution but I don’t really like this as it takes up more board area and it’s another signal trace to fit in.
  • There is only one output pin, even on the xx17s, although that’s okay with multiple sense resistor topology, it becomes a problem if there is multiple power channels like in a tint adjustable light.

I doubt people will buy 70 1616 for 1$ each to build a couple of drivers when they can wait a couple of weeks and buy them from digikey at 80c per quantity of one.

Firmware is Anduril2.

Now is the semiconductor crisis.
There is no guarantee that 1616 will appear anytime soon. And you can forget about the price of $ 0.8.

The transistor circuit would be an emitter follower aka common collector amplifier: Common collector - Wikipedia

The principle is that the base-to-emitter junction voltage is a standard diode drop (0.7v for silicon), and the transistor amplifies current: the collector to emitter current is a “constant” times the base-to-emitter current. The constant is called “beta” and it’s a parameter in the transistor data sheet. I put it in quotes because it’s not perfectly constant, but it’s close enough for our purposes. A small signal transistor might have beta of 50 or 100 or whatever. To get higher gain you’d use multiple stages, a so-called Darlington configuration. Anyway, I expect we’d use 1 transistor and 2 resistors (voltage divider) like in the diagram in the wiki article.

I’ve been chatting with TK about this, and she has some ideas for smoothing out the PWM, and I’ve also asked about the idea of using a programmable potentiometer (DS3502 or DS1841), I like that idea because it would allow putting the processor to sleep after setting the potentiometer, though the potentiometer itself consumes a little bit of power, 0.35mA in the DS1841 case apparently. That seems like a lot for a sublumen light that would send less power than that to the led, but it’s ok in the bigger scheme of things.

I found out about these pots from Adafruit, which has breakout boards for them: Adafruit DS3502 I2C Digital 10K Potentiometer Breakout [STEMMA QT / Qwiic] : ID 4286 : $4.95 : Adafruit Industries, Unique & fun DIY electronics and kits (linear) and Adafruit DS1841 I2C Digital 10K Potentiometer Breakout [STEMMA QT / Qwiic] : ID 4570 : $5.95 : Adafruit Industries, Unique & fun DIY electronics and kits (logarithmic). They look cool.

I know how to make a simple constant current sink but not sure how to make a voltage controled one (filtered PWM or DAC). Can you post a schematic ?

Those have a pretty large footprint, and expensive, although maybe there are smaller and cheaper ones.

The attiny1616 consumes <1.1mA at 2.5MHz with 2.8V VCC so that’s actually quite reasonable. A better power saving solution would need to be significantly better than that to be worth it.

I can try to post a schematic later today, will have to draw it and figure out how to upload it, etc. The circuit is pretty simple though. Imagine a PNP transistor. The emitter is connected to Vcc (the + power supply), the base is connected to one end of a resistor R, and the collector is connected to the LED. The other end of the resistor R goes to the DAC output.

Notice that the voltage at the transistor base is fixed, it is Vcc - (1 diode drop). The voltage at the other end of the resistor is also fixed, to whatever the DAC output is. So you know the voltage at both ends of the resistor, which means you can find the current through Ohm’s law. This current, multiplied by the transistor gain (beta), is the current going through the led. The value of beta is specific to the transistor and you would find it in the data sheet. Now that IC’s have made transistors “free”, I guess this stuff is now done with op amps, that are closer to ideal amplifiers without the weird nonlinearities and weird parameters. But I’ve mostly dealt with older stuff.

Does this make sense? It’s possible I’m somehow confused or missing something. There might also be some small filter caps needed to keep things from oscillating or whatever. I’m absolutely not expert at this stuff at all. I fooled around with these circuits as a kid but never studied EE or anything like that.

That’s a current source though, a current sink is needed since the anode of the LED is directly connected to the battery positive in this driver (or any NFET linear or direct drive driver).

Oh I didn’t understand that. You mean the led cathode is not grounded? Ok, do a similar circuit on the other side of the led, except use an NPN transistor so the emitter is grounded.

Is this the light main led? I think for a moon mode it is ok to use a small aux led, maybe a little SMT led. Then you can choose what it is connected to.

I do worry about the 0.6v PN drop of a silicon transistor, if VCC gets as low as 3.2 volts from a single lithium ion cell. There might not be enough left to light the led, whose Vf might be 3 volts or so. I don’t know if it’s sane to use a germanium transistor for this (0.3v drop instead of 0.6v). Maybe the whole idea fails because of this, and it’s better to use FETs somehow. This is an analog engineering problem though: maybe there are some experts around? Is Tom C here?

Yes, making a driver with grounded LED cathode is more complicated (although I have done it with boost topology) and in the case of a linear driver the FET would have to be a P-channel, I doubt they can handle this sort of load.

Yes I think that’s going to be a problem.

Anyhow I like the dual sense resistor solution because it gives precise current control, you know exactly what current a certain ramp level gives. In terms of components counts it’s only 2 resistors and a low resistance NFET (to have minimal influence on the total Rsense), and the gate resistor could possibly be omitted, normally we’re supposed to have one to limit the switching current in the MCU’s pin, but it is sometimes omitted (Zebralight don’t use any), plus here there is no repetitive switching (PWM).
In the future, for say 3~4A max drivers the 3333 footprint HDR FET could be replaced with a 2020 one, that one when it will be available (it was supposed to be available soon but the expected date was pushed back to 2022, not surprising with the ongoing shortages). Current 2020 NFET have a RDSON a little bit too high to use them to switch between the high and low current Rsense, that is when using a low Vsense value (Zebralight uses 2020 FETs and uses a higher Vsense to compensate, which has an efficiency cost). It’s also cheaper.

Here is yet another possibility: ditch the low current stuff altogether, and instead use a digitally controlled LED: DotStar Micro LEDs (APA102–2020) - Smart SMD RGB LED - 10 pack : ID 3341 : $5.95 : Adafruit Industries, Unique & fun DIY electronics and kits

They are very easy to program, you basically send an address and a 24(?_ bit RGB value to the led by SPI. You can do that with two gpio pins and software, or maybe the chip has hardware for it. It is a tiny part (2x2mm), it has the nice bonus of being RGB, and you can connect as many as you want to the same two SPI pins and control them independently of each other.

What I don’t know is whether their lowest setting is dim enough to satisfy the moon mode fans here. I don’t have any of the 2020 ones but I have a 5050 one that I can try it with.

By the way I found some interesting data about the brightness of glow markers, which tells us something about the desired brightness of a super low moon mode. Here is a pic that ToyKeeper took of a 1mm wide tritium marker vs a Jetbeam RRT-01 turned up a few notches from its minimum level (the trit marker is much brighter):

Then at Light Source | BETA Light it describes that the brightness of glow tubes is measured in microlamberts. I couldn’t find a brightness spec for those tiny marker tubes, but Betalight Torch | BETA Light mentions that their map-reading torch has 1000 microlamberts.

I was unfamiliar with this way of measuring brightness so feel free to check my math. But, from what I can tell, lamberts and microlamberts measure surface brightness: 1 lambert = 1 candela per cm*2. For the 1mm*3mm tube you’re effectively seeing a surface area of 0.03 cm*2, so at 1000 microlambert the light coming out is 3e-2*1e-3 = 3e-5 candela. If that is focused into 1 steradian facing the camera, it would mean a green trit tube that size produces 3e-5 lumens. According to one of the charts (the little clickable image) on mixglo, blue phosphor is about 15% as bright as green, so we’re looking at 4.5e-6 lumens. If the led Vf is 3 volts and its brightness is 100 lumens per watt (333 lumens per amp), we want about 4.5e-6/333 = 1.35e-8 amps=.0135 microamps to the led, to equal the trit tube.

Does that sound even slightly plausible? It means connecting the led to a 5v USB brick with a series resistor (2 volt drop across the resistor), the resistor would be 2/1.35e-8 = 148 megohms. I don’t know if normal resistors that high even exist, or if my DMM reaches such a scale. Potentiometers on digikey only go up to 5 megohms. I guess it is possible to use 5M or 10M and further dim by PWM but wow. So I have to wonder what is going on with that Jetbeam light.

That sounds too low to me, I mean I don’t have any tritium tubes to compare directly, but from what I remember when I saw a watch with tritium hands, it wasn’t too different from what I get at 5uA, I could very well remember wrong though. (Edit : I probably do)

Anyhow 5uA is already too low for me, I’ll probably use 50~100uA, the goal was the moonlight level of Zebralight H/SC600 mkII which is 100uA (with 3V LED), so that is achieved. (With the main LED, because most hosts don’t have room for aux LEDs, so while the digitally controlled LED you linked sounds interesting, it’s doesn’t satisfy my specs).

Aside from that I modified the value for R6, at first I tried with 1k, which worked down to 1/1023, but since there was less ringing during transients in simulations with 10k(same as KR4 driver) I changed it to that, without enough testing after that… and it doesn’t works properly, on the 1st and 2nd PWM the LED doesn’t even lit up, on the 3rd the current is about 5uA (should be 15), and with a slow start, similar to the KR4 driver. I changed it back to 1k and get 5uA at 1/1023 (well 6uA in reality but close enough :stuck_out_tongue: ) , 10, 15uA…etc on next levels, as expected.

Ringing if it happens (haven’t checked yet) would be only during transients and for a very short time, as in 1ms, nothing visible, steady state is stable. Increasing C4 to 4.7~10n would probably help, though I’m not sure that’s really necessary.

I just wanted to make a comment about how great it is that you were able to create and share this design. I hope some others are able to put it to use.

I’ve never tried building a driver, and I’m not sure if there is a good way to manage the components on the backside without a hot air station. However, since I have an original D4 would benefit from an upgrade, if I had the time to try, this seems like a good candidate.

The flash you mentioned, is that a behavior related to not knowing the proper initial control value when moving between channels? Does it flash low or high, or does it depend on the direction being ramped?