Hey guys,
I just finished putting Andúril 2.0 on a Convoy M3 and wanted to share the process with you (even if not greatly detailed, if you have any questions feel free to ask).
But first, here's a video:
www.youtube.com/embed/FFsRmGndQpk
Andúril really lifts this ~$30 light to a whole new level!
The boost driver in it looks like this:
I did some reverse engineering on the driver and all I had at hand was an ATtiny85, so I went with that. Without going into great detail, the drawback of this decision was, that the ATtiny85 only supports 8 bit PWM in hardware, which means 256 brightness levels. Sounds like enough, but really isn't, because we humans don't perceive light linearly but kinda logarithmic, which means especially in the lowest brightness settings there will be large, distinguishable steps in the otherwise beautiful smooth ramp. No good. Other flashlights like the Noctigon K1 solve this by simply using a larger MCU (ATtiny 1634, which also conveniently has enough pins for RGB aux LEDs!) which has a 16 bit timer/counter on board.
But I wanted to stick with the ATtiny85. So with a little food for thought from ToyKeeper herself, I got to work on modifying Andúril in a way to "fake" 10 bit PWM on an 8 bit capable MCU. Basically jumping back and forth between adjacent PWM values allows us to e.g. add two more bits of resolution by going through four "iterations" and jumping to the next higher PWM value between zero (0b00) and three (0b11) times out of the four iterations.So, for example if we wanted a brightness step right between value 130 and 131, we'd set the PWM value to 130 for two PWM cycles, then to 131 for two cycles, rinse, repeat. This is relatively easy to do with an interrupt that gets triggered every PWM cycle.
I actually put together a quick'n'dirty prototype with a button and LED to test my code on:
Unfortunately, the pinout of the ATtiny85 didn't match the existing MCU so I had to become a bit creative on the hardware side, bending the poor ATtiny's pins either down or up depending on whether the function of the pin matched the existing pad or not. For the those pins bent upwards I used enameled copper wire, which I also used to temporarily attach a pin header in order to flash the MCU (I also added longer wires to the LED and an external switch for convenience):
Apart from some flavor tweaks I did in Andúril, I mostly had to make sure to invert one of the enable outputs since it was going to a p-channel MOSFET, which is "active low" and calculate calibration values for the battery voltage readout (also had to change a resistor in the voltage divider used for this).
The boost driver also is slow, it wasn't able to switch fast enough for the party strobe to be effective (didn't turn on at all with reasonable on-times). I suppose I could've changed something about that if I tried hard enough, but it wasn't really worth it, so I just threw party strobe out of the rotation.
The remaining tactical strobe works fine up to a certain frequency. I'm quite annoyed I didn't catch this before re-assembling the light, but the output basically just vanishes if the strobe frequency is too high. If I ever decide to re-flash this MCU I'll make sure to limit the strobing frequency to reasonable values, too.
I hope this was somewhat interesting for at least one or two people on here, who disliked the simple UI of the M3 (especially the lack of soft-lockout and voltage readout) just as much as I did.
Take care!
Simon