diff options
| author | Selene ToyKeeper | 2020-03-16 00:11:02 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2020-03-16 00:11:02 -0600 |
| commit | 79c9e662b98bf4219de9419eb2ccb171f80ef12b (patch) | |
| tree | 39c586fe929a4604df876a39485308626bf2fd17 /spaghetti-monster/fsm-adc.c | |
| parent | the ADC sample count doesn't need to be 16-bit any more, and isn't really a c... (diff) | |
| download | anduril-79c9e662b98bf4219de9419eb2ccb171f80ef12b.tar.gz anduril-79c9e662b98bf4219de9419eb2ccb171f80ef12b.tar.bz2 anduril-79c9e662b98bf4219de9419eb2ccb171f80ef12b.zip | |
reduced regulation jitter by biasing errors toward zero by a constant amount,
which mostly impacts small errors (and reduces jitter during the flat phase of regulation)
while leaving large errors pretty much unaffected...
also, made acceptable thermal window smaller to make up for this new extra tolerance
Diffstat (limited to '')
| -rw-r--r-- | spaghetti-monster/fsm-adc.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/spaghetti-monster/fsm-adc.c b/spaghetti-monster/fsm-adc.c index c382a8a..dd43cb9 100644 --- a/spaghetti-monster/fsm-adc.c +++ b/spaghetti-monster/fsm-adc.c @@ -291,7 +291,7 @@ static inline void ADC_temperature_handler() { #define THERM_RESPONSE_MAGNITUDE 128 #endif // acceptable temperature window size in C - #define THERM_WINDOW_SIZE 3 + #define THERM_WINDOW_SIZE 2 // TODO: make this configurable per build target? // (shorter time for hosts with a lower power-to-mass ratio) @@ -350,6 +350,19 @@ static inline void ADC_temperature_handler() { uint16_t ceil = (therm_ceil + 275 - therm_cal_offset - THERM_CAL_OFFSET) << 1; int16_t offset = pt - ceil; + // bias small errors toward zero, while leaving large errors mostly unaffected + // (a diff of 1 C is 2 ADC units, * 4 for therm lookahead, so it becomes 8) + // (but a diff of 1 C should only send a warning of magnitude 1) + // (this also makes it only respond to small errors at the time the error + // happened, not after the temperature has stabilized) + for(uint8_t foo=0; foo<5; foo++) { + if (offset > 0) { + offset --; + } else if (offset < 0) { + offset ++; + } + } + // Too hot? // (if it's too hot and still getting warmer...) if ((offset > 0) && (diff > 0)) { |
