Thermal regulation update
If you recall, the original thermal protection behavior looked like this. It took way too long and got way too hot and never tried to step back up again:
As a quick check, I tried decreasing its timeout so it could respond faster. It responded faster and didn’t get quite as hot, but it still exceeded what I’d consider a safe temperature, then went down too far and never came back up.
So I decided to go with the original plan and rewrite that part from scratch.
I changed lots of things, but the main thing new method does is try to predict what the temperature is going to be in the future… then react based on that. This helps eliminate the effect of the time it takes for heat to travel from the emitters to the sensor. The correction is proportional to how far the prediction exceeds the thermal ceiling, so it adjusts a lot faster while heat is increasing quickly.
Also, it does regulation instead of protection, meaning it will also try to step back up if the temperature gets too low. But step-up is intentionally slow to avoid oscillations.
So, here’s how the first test went. It was certainly faster, but it over-shot and then took too long to recover.
I slowed it down and tried again, but it slowed down too far. This time it got too hot and took too long to drop to a safe level.
After fixing that, I checked again and behavior was better but it was awfully noisy / bumpy. I also noticed a bug where it could step down then up immediately, or vice-versa. That shouldn’t happen.
After fixing those issues, I tweaked some other things and increased the sensor resolution (ish), and tried again. This time it turned out reasonably well. Not perfect, but not bad. It dropped fast enough to prevent skin burns, then gradually adjusted from there. It didn’t even overshoot.
Some of the dips and bumps here were due to me holding the light and changing hands in an attempt to keep it somewhat heat-sinked, but I think in the future I’ll just point a fan at it.
Note, I didn’t recharge the cell between tests… so by the time I did this last test it was starting at only 3.7V. I’ll have to do that next time. For now though, I think this is a good improvement.
I’m also going to have to be extra-careful when I reflash the driver, because I’ve already managed to break one of the switch wires and pull out the other one. I don’t want to have to repair that again.