aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
authorSelene ToyKeeper2020-03-16 00:11:02 -0600
committerSelene ToyKeeper2020-03-16 00:11:02 -0600
commit79c9e662b98bf4219de9419eb2ccb171f80ef12b (patch)
tree39c586fe929a4604df876a39485308626bf2fd17 /spaghetti-monster
parentthe ADC sample count doesn't need to be 16-bit any more, and isn't really a c... (diff)
downloadanduril-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 'spaghetti-monster')
-rw-r--r--spaghetti-monster/fsm-adc.c15
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)) {
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.