My G-20 (generic 20mm) driver with the ATtiny85 and dual switch support is getting close to completion, so it is finally time to stick it into a light. The host (light with defect driver) was kindly given to me after I posted I was looking for dual switch hosts. As it was given to me I am using it for my #1000 post giveaway light (easy come, easy go) when I’ve tested the driver and firmware enough. CheapThrills won the draw, so this is what he won…
Here is the driver. It’s not the final version though, because when building this one I found a few small things I wanted to change. I haven’t ordered the new version yet as I’m still evaluating if I want to make more changes, but so far so good. I had made a 23 mm version of the driver simply by increasing the diameter of the ground ring, which I called G-23. It’s a bit messy as I’ve used it for testing a few things with the design.
23mm was just a little too small for this light so the driver was a little loose inside when when the battery tube was screwed on so I put in a washer, and then i filed down another thinner washer until it was only a little too big so it would bend in place and keep the driver in place when the tube is off. Screwing on the tube tight flattened it. Not very pretty but it works. It’s a bit of a bummer getting it out again, but that’s why I designed this driver with the MCU instead of a spring on the battery side. The copper wires cross over the MCU without touching it, and it doesn’t bend without a fair amount of pressure. Now I can update the firmware without ripping the whole thing apart.
The LED I put in is a new unused XM-L2 U3 1A from RMM / Mountain Electronics. I’m personally more fond of warmer tints so that’s why this one is in the giveaway
I isolated the end of the reflector with kepton tape and screwed on the head. Centering the LED wasn’t easy, so I gave up after a few tries. This was the best I got. As this light is a development light I’m not too picky about it… and besides, I’m going to give it away anyway, CheapThrills can mess with it if he wants to
The original E-switch on this light was fastened to the driver, side mounted and sticking out the side with a deep plastic button to reach it. That’s not how I want to build dual switch lights so I used a little PCB I’d designed for this purpose. It was bare copper in the four corners to make soldering on the switch easy, and vias underneath for easy soldering of the wires. The PCB is a little too small for this light, so I will glue it in once the development is completed. I’ll also have to stick on a rubber switch cap as the original plastic switch is unusable now.
So the light is up and running. It’s a pretty good thrower, at least for a someone who isn’t a throwaholic. I’ve just got to finalize testing and fix up a few things, and it will be ready to go.
Details of the driver:
16 x 350mA AMC7135s on 5 separate channels (1,2,4,8 and a dedicated 7135 for PWM). By doing it like this I have 16 constant current steps from 0.35A up to 5.6A, and a dedicated 7135 for PWM for levels between the 0.35A steps.
That only leaves one pin left… I’ve put the E-switch, off time cap and voltage monitoring on the same pin. This was initially an experiment but after extensive testing in a few driver designs I’ve found it very reliable, but it requires a whole different approach to the firmware.
Firmware details:
- Four different UIs I like for different situations (normal use, climbing, caving, photography etc etc).
UI1: “Traditional” UI. Four modes including boost. Mode change by either E-switch or off switch, short for mode up, long for mode down.
UI2: Three modes controlled by off switch. E-switch engages boost. Hold E-switch for longer than 2 seconds and boost “sticks” until timeout.
UI3: Single “ramp” mode. E-switch engages boost like UI2. Short off press enables adjusting ramp mode. Increase by pressing E-switch and hold, decrease by double press and hold. After timeout (notified by blink), E-switch goes back to engaging boost.
UI4: As UI3, but no boost. E-switch adjusts ramp mode output.
The adjusting ramp mode in UI3 and 4 goes through the entire range of moonlight up to full blast with 0.35 constant current steps and an algorithm for PWM between, giving the effect of seamless output increasing/decreasing.
Functions induced by holding E-switch on startup and releasing on blink count:
- Safety lock.
- Readout: Added presses to select what to read out: Pre-defined 5 stage voltage levels, real voltage level, and temperature readout.
- UI selection and also UI1/2 mode programming. All modes can be reprogrammed using same method as ramp adjusting in UI3 and 4.
- UI1 and 2 mode memory selection: Include boost, exclude boost, or no mode memory.
- Set number of modes for UI1 and 2. Max 4 including boost. Usually use more? Then UI3 or 4 is for you!
- Set boost timeout, 15 second steps each E-switch press, or long press to disable.
- Set temperature limit for overheat protection. Let it burn as hot as you want (temp constantly saved), then turn off (thanks ToyKeeper).
- Set voltage levels for low voltage step down and critical shutdown/emergency mode.
- Enable/disable voltage monitoring.
- Enable/disable temperature monitoring and overheat protection.
- Critical volt/temp action: Shut down or limited to very low output (emergency lighting).
- Voltage calibration. Insert a cell and “tell” the MCU what the voltage is. One time thing, once set it shouldn’t need to be changed.
- Reset everything back to default.
That’s what I’ve done so far. And now I’ve put it in a real light so I can start testing everything properly. I’ve spent 7808 bytes, so not much room for more functionality left. Might do a hidden blinky of some sort, don’t know yet, but first I need to extensively test for bugs so there is a little wiggle room to fix them… and then it’s off to CheapThrills!