diff options
| author | Selene ToyKeeper | 2020-03-13 18:06:27 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2020-03-13 18:06:27 -0600 |
| commit | 7110fdbae15c6303eb405705bf0b319fc1381a4f (patch) | |
| tree | d87c6088fdb7dc5d1b36a4bf15657938387c973c /spaghetti-monster | |
| parent | went back to slower clk/128 ADC timing (diff) | |
| download | anduril-7110fdbae15c6303eb405705bf0b319fc1381a4f.tar.gz anduril-7110fdbae15c6303eb405705bf0b319fc1381a4f.tar.bz2 anduril-7110fdbae15c6303eb405705bf0b319fc1381a4f.zip | |
tried to make thermal code a bit less twitchy...
it regulates really fast on D4, but once it's stable, the adjustments are too large
Diffstat (limited to 'spaghetti-monster')
| -rw-r--r-- | spaghetti-monster/anduril/anduril.c | 13 | ||||
| -rw-r--r-- | spaghetti-monster/fsm-adc.c | 17 | ||||
| -rw-r--r-- | spaghetti-monster/fsm-wdt.c | 2 |
3 files changed, 19 insertions, 13 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c index 69dd118..469d0d8 100644 --- a/spaghetti-monster/anduril/anduril.c +++ b/spaghetti-monster/anduril/anduril.c @@ -963,7 +963,7 @@ uint8_t steady_state(Event event, uint16_t arg) { if (diff) { uint16_t ticks_per_adjust = 256; if (diff < 0) { - diff = -diff; + //diff = -diff; if (actual_level > THERM_FASTER_LEVEL) { #ifdef THERM_HARD_TURBO_DROP ticks_per_adjust >>= 2; @@ -976,7 +976,8 @@ uint8_t steady_state(Event event, uint16_t arg) { } while (diff) { ticks_per_adjust >>= 1; - diff >>= 1; + //diff >>= 1; + diff /= 2; // because shifting produces weird behavior } if (ticks_since_adjust > ticks_per_adjust) { @@ -1040,9 +1041,11 @@ uint8_t steady_state(Event event, uint16_t arg) { // temperature is within target window // (so stop trying to adjust output) else if (event == EV_temperature_okay) { - // if we're still adjusting output... stop - gradual_target = actual_level; - //set_level_gradually(actual_level); + // if we're still adjusting output... stop after the current step + if (gradual_target > actual_level) + gradual_target = actual_level + 1; + else if (gradual_target < actual_level) + gradual_target = actual_level - 1; return MISCHIEF_MANAGED; } #endif // ifdef USE_SET_LEVEL_GRADUALLY diff --git a/spaghetti-monster/fsm-adc.c b/spaghetti-monster/fsm-adc.c index 59d4e5c..358ff26 100644 --- a/spaghetti-monster/fsm-adc.c +++ b/spaghetti-monster/fsm-adc.c @@ -288,6 +288,9 @@ static inline void ADC_temperature_handler() { // acceptable temperature window size in C #define THERM_WINDOW_SIZE 3 + // TODO: make this configurable per build target? + // (shorter time for hosts with a lower power-to-mass ratio) + // (because then it'll have smaller responses) #define NUM_TEMP_HISTORY_STEPS 8 // don't change; it'll break stuff static uint8_t history_step = 0; static uint16_t temperature_history[NUM_TEMP_HISTORY_STEPS]; @@ -365,21 +368,21 @@ static inline void ADC_temperature_handler() { } else { // it has been long enough since the last warning // Too hot? - // (if it's too hot and not getting colder...) - if ((offset > 0) && (diff > (-1))) { + // (if it's too hot and still getting warmer...) + if ((offset > 0) && (diff > 0)) { // reset counters temperature_timer = TEMPERATURE_TIMER_START; // how far above the ceiling? //int16_t howmuch = (offset >> 6) * THERM_RESPONSE_MAGNITUDE / 128; - int16_t howmuch = (offset >> 1); + //int16_t howmuch = (offset >> 1); + int16_t howmuch = offset; // send a warning emit(EV_temperature_high, howmuch); } // Too cold? - // (if it's too cold and not getting warmer...) - else if ((offset < -(THERM_WINDOW_SIZE << 1)) - && (diff < (1))) { + // (if it's too cold and still getting colder...) + else if ((offset < -(THERM_WINDOW_SIZE << 1)) && (diff < 0)) { // reset counters temperature_timer = TEMPERATURE_TIMER_START; // how far below the floor? @@ -387,7 +390,7 @@ static inline void ADC_temperature_handler() { int16_t howmuch = ((-offset) - (THERM_WINDOW_SIZE<<1)) >> 1; // send a notification (unless voltage is low) // (LVP and underheat warnings fight each other) - if (voltage > VOLTAGE_LOW) + if (voltage > (VOLTAGE_LOW + 1)) emit(EV_temperature_low, howmuch); } diff --git a/spaghetti-monster/fsm-wdt.c b/spaghetti-monster/fsm-wdt.c index 12aab7b..1d630a4 100644 --- a/spaghetti-monster/fsm-wdt.c +++ b/spaghetti-monster/fsm-wdt.c @@ -178,7 +178,7 @@ void WDT_inner() { #endif #if defined(USE_LVP) || defined(USE_THERMAL_REGULATION) - // start a new ADC measurement every 16 ticks + // enable the deferred ADC handler every 32 ticks adc_trigger ++; if (0 == (adc_trigger & 31)) { // in case we're in standby mode and the ADC is turned off |
