gchart
(gchart)
2
UI / MCU Mod
While the original UI isn’t terrible, it could be so much better. So… I tore down the headlamp (desolder LED wires from MCPCB and unscrew the button-end of the lamp, then push out the internals from the battery side) to prepare it for a brain transplant.
The driver itself is completely separate from the charging circuit, thankfully. Unfortunately though, the MCU wasn’t labelled and was probably PIC or something else I’m unfamiliar with (due to the pin layout with VDD and GND on opposing pins). Thankfully, that’s the same layout as the new attiny412 chips! But that brings it’s own set of difficulties: no firmware and scarce documentation on programming them.
Firmware: I started writing my own e-switch firmware mostly from scratch, but then I realized that what I was creating was almost identical to TomE and TK’s RampingIOS (found in the Emisar lights). So… I modified RampingIOS to accept compile-time switches for Attiny85 / 412 / 416 / 817 / etc. I also added compile-time switches for single channel vs dual-channel. All of this fit nicely onto the 4KB program space of the 412, which fit nicely onto the footprint of the old MCU. It’s running flawlessly… with the exception that I still need to dial in the temperature calibration. The AS-IS firmware can be found here.
Programming: the new AVR chips use UPDI (universal programming and debugging interface) instead of our old standby SPI interface (the 6 wire VDD/GND/RESET/SCK/MISO/MOSI). UPDI uses only 3 wires (VDD/GND/RESET), but the options for programming is a bit sparse. El Tangas has come up with a nice solution that I need to try. But for now, I bought a Attiny416 Xplained Nano development board and disconnected the onboard MCU. This allows it to be used as a programmer for other MCUs. AVRDUDE now has support for this, but you have to build it from scratch (it’s currently not in the pre-compiled versions). I installed Window (yuck) on an old laptop I had sitting around and installed Atmel Studio 7, which has great UPDI support and allows for in-system debugging (which has been extremely helpful).
Now the D25 runs RampingIOS, and I’ll say… it’s pretty great. Very intuitive interface. Well done, TomE and ToyKeeper!
Here’s the pin-out, and with the attiny412 in place. Note the hole drilled under the UPDI pad so that I can program the 412 while the headlamp is assembled.

1 Thank