We can probably change the "static uint8_t ticks = 0;" to be "static unit16_t ticks = 0;" so that you can extend the timer to be much longer along with changing the WDT like RMM suggested. The main downside is that we use the watchdog timer to do the counts, and the timing can be pretty far off. If you do a 5 minute timer, it might kick in at 4:30 or 5:30 depending, or even worse.
Or you could just disable turbo entirely and make it never step down.
If necessary though, you could use a limit higher than 255. Just change the declaration to be a 16-bit integer instead of the usual 8-bit one. No need to muck with WDT timings.
Edit: D’oh, JonnyC posted the same idea while I was writing this.
My driver was modified to temperature monitoring instead of voltage monitoring. Would you please educate me to modify the code to ramp down and to shut off when the voltage of the ADC is higher than the threshold.
I did as you suggested and changed to “static uint16_t ticks = 0” then changed the turbo timeout to 600. Let the light run for 9 minutes and did not see any step down.
You don’t want to do both voltage and temperature monitoring?
If you want to do only temperature I assume you don’t want a “critical” value which turns the light off, only a step-down temperature. In that case I’d do something like this:
Replace:
#define ADC_LOW 130
#define ADC_CRIT 120
with
#define ADC_LOW 130
#define ADC_CRIT 0
also replace
if (ADCH < voltage_val) {
with
if (ADCH > voltage_val) {
That’s a pretty dirty way to hack the code. It should work I think, but I don’t like it. For my own use I’d want a separate check done for temperature.
Sure. Remember that I did not try it, but I think it will work fine. Will you post a thread about your temperature monitoring? I would like to do that myself.
It seems it works as I modify: #define ADC_LOW 130 (130=56C) #define ADC_CRIT 140 (140=60C)
Change
if (ADCH < voltage_val) {
if (++lowbatt_cnt > 8)
to
if (ADCH > voltage_val) {
if (—lowbatt_cnt > 8)
In fact, the 140 shut off the light will not happen because the power to LED already has been ramped down when the temperature reach 130.
If you're using MODE_HIGH as your single mode, and not turbo, you also need to comment out #define TURBO_TIMEOUT.
Are you also disabling low voltage monitoring? (if so, why?) When you comment out settings at the top, you have to go hunt for other stuff farther down that refers to the things you disabled. If you re-enable #define VOLTAGE_MON those two errors will go away and it builds correctly.
Cool. Good point, I guess a sudden jump from 55c to 60c would be a huge thermal shock: never going to happen unless you drop it in a volcano. I hadn’t thought of that.
I think for step-down to work some extra stuff has to be done. STAR steps down by lowering the mode index (it changes the mode to a lower one). If you only have one mode defined then the stock STAR ontime or offtime firmware can’t step down. Momentary might be different, I don’t remember.
I think RMM has a post about that subject around here somewhere. I don’t recall how he was working around it.
zeremefico, “MODE_TURBO” (255) mode includes a timed step-down to “MODE_HIGH_W_TURBO” (110). This is independent from the low-voltage-protection step-down. “MODE_HIGH” (255) uses the same brightness but does not include a timed step-down. You do want Turbo?