Developing a customizable driver

Orsm work sidehack. Reckon you may have a few members here excited as well. :beer:

It’s interesting seeing a new family of drivers being developed from scratch. Thanks for sharing your progress sidehack.

3A driver circuit works. Had some trouble at first with residual flux throwing off the divider ratio for the PWM output but I just needed to wash the board better. I have this guy wired up to test the temp sensor which is mounted right by the LED. The LED board is a two-layer 1oz copper 1mm PCB with about 100 vias, including 24 on the LED’s belly pad. I lapped off the underside soldermask, spread a drop of Arctic Silver white, and used a 5-minute epoxy along the top edges to hold it down in the pill.

With the three leads pictured, I can verify the drive current and the absolute and as-measured temp sensor output. I don’t have any topped-off cells so I could only briefly test at 100% output but the temp sensor only ran up to 55C for steady-state. When I kicked it back to 10% it dropped 11C in about ten seconds.

55C is pretty good, I think, for right next to the LED. I might have to wait for a more powerful driver (maybe that 5A buck-boost) before coding a temp-throttling routine. I think I’ll also put a temp sensor on the driver PCB, if I have room, instead of relying on the microcontroller’s internal temperature indicator, since to be anywhere near accurate it’d require a per-chip calibration routine that means more handling time, more computationally intensive measurements, or both. A twenty-cent SC70 pre-calibrated linear analog sensor would be awful handy.

Also since the move in November (I packed up my entire business and moved into a new shop across the state that my dad and I built last fall) I haven’t been able to find my good 18650 charger. Fortunately I’d picked up this battery tester a couple years ago and it didn’t take long to throw together a cell holder. Should be able to do better testing with full cells before long.

Got some efficiency numbers off the 3A buck driver. I didn’t have measured LED currents so I had to settle with expected. Everything looked pretty good (90+) from 10% to 80% but at 90% my input voltage had some pretty bad ringing on it and the input current jumped by roughly twice the expected step (580mA vs expected ~320mA). Gonna have to figure that part out. Could be an issue with inductor saturation but if we’re hitting 3A on a 3.5A rated inductor, and ripple should only be swinging it about 200mA where I have 1200mA of saturation headroom, I can’t see that as being the case. I’m hoping it was some kind of bad interaction with the input power supply so I’ll probably put a buffer cap on the input to get rid of lead inductance issues.

Might start messing with the penlight and buck-boost circuits soon. I’ve gotten about ten cells charged and tested too. Everything I’ve got are pulls from old laptop batteries so I categorized them by brand. I’m measuring capacity with a 7W costant-power discharge (should be about right for a 2A output buck-boost), starting with Panasonic CRG18650 cells. Some have tested out between 1500 and 2200 mAh, and some were like 100-500 so those are getting tossed. The 2147mA cell is pretty encouraging, with something like 63 minutes of runtime before hitting 2.70V and cutting out. Not bad for decade-old freebies. I’ve got a pile of Samsung- and LG-branded cells, half a dozen Sanyo and three I don’t know what they are still to be tested.

:beer:

Dropped a 1000uF can across the inputs of the driver to rule out any harmonic/inductive issues with the PSU and wires (16AWG about 12 inches with an inline toggle switch), and the line voltage was super flat even at 100% draw so I reckon that was the problem with the previous test.

For some reason I was seeing about a 59KHz ringing everywhere though, which is weird as that’s an order of magnitude lower than the switching speed anywhere inside the light and a little over twice my PWM pulserate. Might have been noise coming off the PSU?

I didn’t measure LED currents, sticking to calculated values, so my efficiency numbers are technically useless, but I’m seeing upwards of 90% peaking around 96% at 50% duty cycle and dropping to 88% at the full 3A output. Not bad for an SC70 regulator and, admittedly, not a great inductor (29mOhm DCR). Note that the output includes a 25mOhm sampling resistor, so if we include the power loss from this part the total conversion efficiency is going to be a bit lower (at 3A, the resistor eats 2% of input power). I will be replacing the 25mOhm sampling resistor with a 16mOhm so I can use the same 50mV PWM signal on 2A and 3A builds, and this will also reduce resistor power loss by about 36% (or 0.7% of input power at max draw). I may not even bother continuing the 2A design since 3A costs basically the same and is more capable, but 3A will need temperature limiting.

At 3A, by the time the temperature reached steady state, the light was too hot to hang onto for more than five to eight seconds.

Thought of a different UI I want to try out sometime also. It might require a hardware change if the microcontroller isn’t responsive enough, but I want to test out ramping. My off-time for mode switching is set to about 0.5 seconds right now. I figure if I can tap on for 0.5 seconds, off for 0.5 seconds, and then hold on, the light would ramp from 0-100% and back in 5-10 second cycles. When the button is released, the micro would lock in that intensity for next time the light is turned on. I need to test if the battery sense circuit will drain fast enough to trigger an interupt causing the micro to write levels to EEPROM fairly reliably before the 2.5V LDO and output bypass cap drain low enough to turn it off. Else it’ll require a hardware change (at minimum, a bigger output cap on the LDO; possibly a shottky to prevent stray drainage) to make this work. Datasheet says max 5mS to do a full write operation.

Oh also I need to do a bit more research but I figure I’ll make the ISP pads dimensionally compatible with HQ’s pogo key. The PIC needs a minimum of five pins and, if I’m seeing right, that one’s got a generic header so it should be able to cable to any ISP device including my PICKit3.

June’s going to be a busy month at work so I may not have a lot of flashlight time inbetween regular maintenance, manufacturing and something like three other design projects, but I want to at least get a final hardware design on the 3A driver (including driver-level temp sensor), code in a thermal-throttling routine and see about getting my buck-boost concept tested. Maybe add a single-AAA light to the project, nothing fancy, maybe 300mA peak output. Also I need to buy a good thermal-conductive adhesive.

The new ATtiny 0-1 series has something I will be looking into, and that is a VLM or voltage level monitor, it can be set for like 5% of the BOD level, and trigger an interrupt. And I am wondering if that is enough time to write to the eeprom? Or maybe that is what you meant?

I think you were using a TI part, so I would post up the ringing or other problems on their forum, and you would probably get an informed answer in 24hrs or less.

EDIT: 1. Why are you using a LDO regulator? 2. There is an 8 bit DAC available with an onboard buffer output, as opposed to PWM with extra parts?

My PIC can be set up for interrupt-on-change, either a low-high or high-low transition, and it’s quite responsive. I’ve used it for cycle-by-cycle current limiting in a PWM motor driver, figured to do the same thing here. I’m already measuring input voltage for low-volt shutdown on a pin, so during the ramp cycle I can switch that from an analog read to IOC and when it bottoms out the interrupt would trigger the EEPROM write.

I’m using an LDO to provide a constant 2.5V to my micro, and then dividing my 10-bit PWM down for current-sense comparison. That’s not an uncommon configuration. My PIC has only a 5-bit DAC and no buffer, plus I like PWM. Even with a DAC I’d still need extra parts for a comparison, either dividing the reference or multiplying the sense read.

Didn’t see the ringing when I was initially testing off a battery so I’m pretty sure it’s noise from the cheap-o bench power supply. I was also seeing some good 120Hz noise on my not-exactly-ground-referenced LED temp sensor as well, which wasn’t present before. My better one is a very clean linear supply but it’s only got an analog current meter so hard to do efficiency calculations with any accuracy, and only goes to 3A (which is plenty for now, but not for most of my other designs).

Maybe I should pull out one of my 12V SLA bricks and build a high-current fully linear supply. Calibrating the voltage and current measurements would be fun, but it could be quite useful. Be a fun weekend project.

Before you ask, I’ve no interest in switching to an ATTiny. I’m using a PIC16F18313 and I’ve been programming with that family (313-344) for probably five years so I know it inside and out, which is good because I’m also writing in assembler.

My apologies, I had confused your project with another one that was using a driver chip. I didn’t realize when posting you were doing the control loop with the micro.

I’ve usually calculated the battery voltage internally based off measuring the internal Vref, and that definitely saves a voltage divider. I guess I’ve become a little less stringent on the precision required, (as in 6-7 bits resolution is enough for me).

Hey I’m all for PICs, have used loads of them for hobby oriented projects. Like for instance, a 16f1503 for a RGBW pwm driver, and a 18f4331 for a rotary encoder hue adjustment, also on a RGBW driver. The 12f1822 has an ECCP module which has a comparator input, and PWM auto shutdown and restart capability, an INT in hardware so to speak.

No sweat. If my chip had a better DAC (at least 8 bit, and buffered) I’d probably be using it instead of PWM. I looked into that at the start. Actually my first design had the entire control loop inside the micro, where it started at a low value, sampled the current and output a filtered PWM value to directly adjust the buck’s output using current injection without an external error amplifier. The hardware was simple but it wasn’t as robust as I wanted, so I opted for doing it the other way with an op-amp sampling current and making adjustments based off a filtered-PWM reference value.

I bumped into talk of measuring battery voltage internally while I was researching the internal temperature indicator, but since I’m using an LDO for fixed VDD it wouldn’t work here anyway. I’ve got a resistor divider with a small bypass cap giving me a direct measurement, which is also what could allow being able to sense battery cutoff before the micro powered down.

My PIC has comparators that can throw interrupts but I’m pretty sure they’re based on ADC reads and I need that for a couple other things so I don’t want it tied up. If I can set the logic levels accordingly I think I can get sufficient responsiveness out of the interrupt-on-change detecting a high-low transition. It’s worth testing, if I want to try and make a ramping UI work.

Everything else around here looks to use Atmel chips so I expect pressure to change, but I like doing things my own way and I already have the internal knowledge, prototyping hardware and in-place toolchain for PICs so that’s what I’m doing. The friend I started this business with was the AVR guy (and admittedly the better programmer, despite my degrees in computer science and computer engineering), but he’s building rockets in Texas now so whatever.

What’s the other project you’re looking at?

Looking at a 1.8V/2.5-3A Boost only driver, but is a private project at least for now. I can say that a TI boost driver and current sense amplifier being used along with the attiny416. The main attraction for the attinyX1X, is the wide (i.e. low) voltage performance, buffered 8 bit DAC for dimming, and possibly using the VLM module for something useful. Could use a low voltage PIC as well, with say a dual opa to accomplish same thing, so many permutations.

Self learnt on PICs to begin with, so no one will confuse me with a rocket scientist :slight_smile: I use GCBasic which can compile PICs and AVRs, with most of the code portable between the two.

I’m a hardware guy at heart, so when I learned microcontroller programming (8051) we started with assembler and I never left. I’d much rather swim around in direct register access than all the abstraction layers required for c-code, but nothing I’ve ever worked on cared about portability. Or required floating-point math that couldn’t be approximated with constants and bit-logic operations.

Part of this project has become establishing a reusable control package that I can attach to a variety of current driver circuits so a single basic framework can then operate on anything from a single-AAA keychain light to, well the biggest thing I have in mind right now is an 8A-capable 6V booster. At some point I want to see if I can make a buck-boost that’s flexible enough to push up to 5A through any 3V and 6V LEDs from any 1S and 2S source without any changes.

Right now with my 80-cent PIC16F18313 and a couple accessory parts I have costant-current adjustment with 10bit resolution, battery monitoring with low-batt lockout, last-mode memory with up to 128 modes, and with a bit more work we’ll have temperature monitoring of both LED and driver PCB. Technically the hardware will support strobe modes but heck if I’ll write the code for it. I’ve been working with a regular F-chip but will need the 1.8V-rated LF for AA/AAA-powered stuff so I’ll probably just stock those for assembly on everything.

I’ve got some 4mm QFN PIC16F18323 with 12xGPIO I’ll be using for a wholly unrelated project (flashlights are not my industry, not yet) that I can design around if something needs more IO for some reason, but 6 should be enough for now. And some 16F18324/18344 if I need a lot of IO and multiple PWM generators, but now we’re getting a bit crazy.

What’s your power source that yields 1.8V?

Don’t really use assembly much, but like the ability to use it when needed. Also subscribe to setting registers, or bits, as opposed some bloated libraries, it all depends on necessity, clarity, or just plain laziness to tip the balance one way or the other.

Your 8A booster sounds like a real challenge. Thanks for sharing your driver experiences.

1.8V is the worst case scenario, so like 2x alky or nimh.

Ah. One thing on my list is intended to run off 2xAA so down to 1.8V also, but I’m starting with a buck-boost and building it for around 300-400mA peak. 3A booster? Nice. That light’s gonna be nuts.

The 8A booster is a fairly low priority. I may never build a light that would use it, but it’ll be interesting to see what’s possible. I’d like eventually to manufacture for general sales but there are very few people I would trust to not destroy everything ever with a pocket-sized 50W boosted light. My 10W tester right now gets hot enough.

Today I’m testing a 5A 6V booster that, if it works well, will definitely get temperature monitoring and then stuffed into a zoomie with a XHP50.2 LED. Should be fun. I need to get some better batteries. Mine are all decade-old salvages.

Also, I run the company and don’t get paid by the hour - when I get paid at all - so I can pretty much work on whatever I want. Which is nice. Hence all this.

When first powering up something new, I usually take bets between Work, Smoke or Fail. I never put money on Work.

But good news! The boost driver worked straightaway. I used a 0.1ohm sense resistor instead of 0.01 so the max current should be 500mA through the LED. At 100% output I was seeing 3.2V 1.1A on the input, which would be just about right for a 6V LED at 0.5A output considering losses and big resistor. I’ll up the current sometime and give it a full-range test when I can put it to a better PSU and better wiring but I’m very encouraged. The only other circuit I’m as excited to test is the big 4-switch buck/boost and I don’t have all the parts for it yet.

Been testing more scrounge cells. The other day while digging for something else, I randomly turned up an orange-label LG cell that had been scavenged from some old laptop battery sometime in probably 2016. It turned out to be a beast, measuring 2414mAh and clocking 71 minutes at a 7W draw. I only found one other cell over 2000mAh and it’s about 2140.

I also found a bunch from an old Dell battery that I had some trouble charging. After a while at 4.2V the current started going back up and making a lot of heat, so I charged them all at 4.1V and they leveled off. So far they’re running 1000-1100mAh, so pretty lousy but good for quick tests and stuff. I just thought it was weird they were going nuts with a 4.2V charge voltage. Anyone else seen that behavior?

Also. I know y’all are going to hate me but I like the 504b host. It’s a P60 host, so thermally limited without substantial modification. I really like the simple design, good sized head, no sharp edges, but I’m worried about putting any kind of high-spec driver in one. I wonder how possible it would be to build a batch where, instead of the brass pill tapering to fit into the tube, the thread was continued all the way down and receiving threads were cut into the tube to match. Instead of a drop-in, it’d be a screw-in, which should give much more contact for heat transfer. Might require extending the pill somewhat to get rid of the big spring, but that would have a side effect of deepening the pocket which could allow room for better parts on a driver. I assume someone’s already worked on something like that.

June’s going to be a big manufacturing month so I don’t know what R&D time I’ll have, but I need to get a full range test of that boost driver someday and especially see how it performs at low voltage, high output. Might have to mount my LED on a heatsink and fan since “high output” for it will be around 30 watts. I need to get a final design of the 3A buck driver PCB, integrating a temperature sensor on the driver and laying out ISP pins compatible with HQ’s pogo key. Should be able to do a layout for the boost driver at the same time and get some of both PCBs made.

I think if I can put together a buck-boost that will output from 2.7 to 6.5 volts, and input from 2.8 to 8.4 volts, will be really fun. It’d be pretty universal, able to run 3V and 6V LEDs from 1S or 2S configuration, without modification. Slap a good current rating on it and it’d do almost everything.

I’ve enjoyed working on the controls systems for flashlight drivers. I’ve got several other design projects going on at the same time, and it’s fun to learn a new concept for one thing and see how it can be added to another project as an improvement. I’ll be using the temp sensors I found for these lights on another thing, and the improved voltage adjustment methods; a lot of the PWM, ADC and RAM/EEPROM access routines in the flashlight’s micro were borrowed from that project. I should juggle complex jobs more often.

Thinking I might drop the 3A buck in favor of a 3A buck-boost for the entry-level driver if I can keep the cost reasonable. I would really like to be able to give someone constant brightness independent of battery voltage.

Still haven’t had time to code temperature throttling, or do full-scale load testing on the boost driver prototype. Might get to it this week, but probably not. Did get some time to work on a driver PCB layout for the boost driver, so progress was made. Course that progress may be moot if the circuit doesn’t hold up to full power testing.

Side note, I’m using my experience refurbishing LCDs and newfound LED knowledge to build an HD LCD movie projector out of an old overhead projector from university surplus, so family in the neighborhood can do drive-in movie and BBQ nights. Testing with an XHP50.2 today but it’s getting too hot (6V; starts turning blue above 5A) so I’ve got some DTP boards on order. Got a lot of light spill and overall low transmission efficiency so I may have to cook up a reflector; may just hijack a spare off a P60 dropin or something, at least to test with and see if it helps. The lensing on my zoomie housing also makes a really even spot so that’s possible too. I need to cover about a 10-inch diameter area to light up the LCD.
Regulating 12VDC down to ~6V will be a nice change of pace and more what I’m used to; before this flashlight project I’d never worked on boost and buck-boost circuits.

Finally got around to full-load-testing the hefty 6V boost driver. With a 50mV sample range and 0.011ohm sense resistor it should peak around 4.5A into the LED.

With current limiting set where it is, I was able to get 100% output into an XHP50.2 LED from a 4V input. Thresholds for 90% at 3.6V, 80% at 3.2V and 70% at 2.9V

By the datasheet calculations the input current limiting shouldn’t have kicked in that early so I’ll have to adjust it experimentally (while watching driver IC temperatures). Be pretty cool to be able to get the full 100% output from about a 2.8V input. Can’t go much lower before the driver IC UVLO kicks in.

Once that’s ironed out, the next thing to test is the buck-boost. I found a different four-switch driver that isn’t as featureful but can be had for 1/3 the price so I need to draw up a new test board based around it, but I already have all the parts for the big one so I might as well play with it in the meantime.

Also will be testing with a host that somewhat resembles the 504b but has a screw-in pill instead of a drop-in and it’s built to handle heat much better. Still haven’t coded temperature throttling into the firmware yet. Work’s really picked up, such that June has seen more orders than March, April and May combined, and I’m still down a guy.

Hey guys. Haven’t been around for a while; manufacturing picked up pretty hard but we’re on track to catch up in the short term now so I have more time to play around with R&D.

I’ve cooked up an improved board for the 3A buck driver to test out temp sensor thermal limiting. I also, I know it won’t affect most people but I really like not having the light taper down in brightness at the bottom end of charge so I’m working on a 3A buck-boost that should be fairly economical and if it works as expected it’ll replace the 3A buck driver as a baseline model.

I also have a 17mm driver board drawn up for the 4.5A 6V booster so once PCBs arrive I can test it in a heavier-duty host with better heat transfer than the P60 host and zoomie I’ve been playing with so far. The host will require some customization, some cosmetic and some not (higher current tailswitch, etc), if the thermal properties are up to par.

I’m using ISP pads which are intended to be compatible with HQ’s programming key, which since it’s just got a pin header for tool connection should be just fine as a go-between for PICs. If it works reliably I may use a similar setup for ISP on another compact microcontroller-based thing I’m working on.

Haven’t looked at the big four-switch buck-boost yet. Haven’t done any programming in a while. I should have some good results by the end of the month though, since if I don’t get too distracted by other projects I should have the whole weekend for design and send off for PCBs next week.

So I went to bed like three hours ago but it’s one of those nights where the brain won’t shut off.

Today I laid out what should be a pretty good multi-mode buck/boost driver with a practical cap around 400mA, with low-batt cutoff and ISP pads, on a 12mm driver for use in a 2xAAA penlight. There’s still room for a temp sensor, especially if I switch to an SC70 LDO instead of using a SOT23 part I already stock. Gonna be proud of it if it works.

Haven’t calculated any component values yet but I’ve got some pretty good notes from the last hour or so of sleeplessness covering a basic USB-powered (adjustable up to 3A) CC/CV 18650 charger. Since it’s running USB I may drop in a RS232 chip and have the micro push charge data (including integrated charge capacity) to a terminal, since it’s already going to be monitoring both voltage and current. Be kinda cool to be able to chart that from a simple charger, and the extra parts to be able to do that are like a dollar. Reinventing the wheel a bit, sure, but I’m a hardware manufacturer not a rebadger.