Compare commits
4 Commits
90ea67cf08
...
55d0548ea8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55d0548ea8 | ||
|
|
3538225a91 | ||
|
|
7bd0b44871 | ||
|
|
53e3d47a04 |
@ -9,13 +9,20 @@ PROJ=barista
|
||||
BUILD=build/$(subst :,.,$(FQBN))
|
||||
HEX=$(BUILD)/$(PROJ).ino.hex
|
||||
|
||||
SRC=barista.ino \
|
||||
ntc.c \
|
||||
ntc.h \
|
||||
pinout.h \
|
||||
overheat.c \
|
||||
overheat.h
|
||||
|
||||
# For host test programs
|
||||
CPPFLAGS=-I.
|
||||
LIBS=-lm
|
||||
|
||||
all: $(HEX)
|
||||
|
||||
$(HEX): barista.ino ntc.c ntc.h pinout.h
|
||||
$(HEX): $(SRC)
|
||||
arduino-cli compile $(OPTS) -e --fqbn $(FQBN)
|
||||
|
||||
upload: $(HEX)
|
||||
@ -24,11 +31,14 @@ upload: $(HEX)
|
||||
serial:
|
||||
picocom -b 9600 --lower-rts --lower-dtr /dev/ttyUSB0 --imap lfcrlf
|
||||
|
||||
test: test_ntc
|
||||
test: test_ntc test_overheat
|
||||
|
||||
test_ntc: test/test_ntc.o ntc.o
|
||||
gcc $^ -o $@ $(LIBS)
|
||||
|
||||
test_overheat: test/test_overheat.o overheat.o
|
||||
gcc $^ -o $@ $(LIBS)
|
||||
|
||||
clean:
|
||||
rm -f test/test_ntc.o ntc.o
|
||||
|
||||
|
||||
@ -2,7 +2,9 @@
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
|
||||
#include "ntc.h"
|
||||
#include "overheat.h"
|
||||
#include "pinout.h"
|
||||
#include <avr/wdt.h>
|
||||
|
||||
enum logic {
|
||||
ON = 1,
|
||||
@ -22,6 +24,7 @@ enum machine_state {
|
||||
HOT,
|
||||
BREWING,
|
||||
COOLING,
|
||||
PANIC_OVERHEAT,
|
||||
};
|
||||
|
||||
//int state = SLEEPING;
|
||||
@ -74,6 +77,7 @@ struct state {
|
||||
unsigned long hot_t0;
|
||||
|
||||
int ntc_i; /* Next available place */
|
||||
int ntc_n; /* Samples in array */
|
||||
float ntc_R;
|
||||
float ntc_last_T;
|
||||
float ntc_array_T[MAX_SAMPLES];
|
||||
@ -82,6 +86,9 @@ struct state {
|
||||
struct btn btn[MAX_BTN];
|
||||
enum buzz_state buzz_state;
|
||||
unsigned long buzz_t0;
|
||||
|
||||
struct overheat overheat;
|
||||
unsigned long overheat_t0;
|
||||
} g_st;
|
||||
|
||||
int read_input(int pin)
|
||||
@ -126,12 +133,16 @@ void proc_ntc(struct state *state, const struct input *input)
|
||||
state->ntc_array_T[state->ntc_i++] = state->ntc_last_T;
|
||||
if (state->ntc_i >= MAX_SAMPLES)
|
||||
state->ntc_i = 0;
|
||||
if (state->ntc_n < MAX_SAMPLES)
|
||||
state->ntc_n++;
|
||||
|
||||
float avg = 0;
|
||||
for (int i = 0; i < MAX_SAMPLES; i++)
|
||||
for (int i = 0; i < state->ntc_n; i++)
|
||||
avg += state->ntc_array_T[i];
|
||||
|
||||
state->ntc_T = avg / MAX_SAMPLES;
|
||||
state->ntc_T = avg / state->ntc_n;
|
||||
|
||||
overheat_input(&state->overheat, millis(), state->ntc_T);
|
||||
}
|
||||
|
||||
void proc_buttons(struct state *state, const struct input *input)
|
||||
@ -168,10 +179,16 @@ void proc_buttons(struct state *state, const struct input *input)
|
||||
}
|
||||
}
|
||||
|
||||
/* In PANIC_OVERHEAT state wait at least TIME_OVERHEAT_COOL and until the
|
||||
* temperature goes below TIME_OVERHEAT_TEMP before doing anything. */
|
||||
#define TIME_OVERHEAT_COOL 10000 /* ms */
|
||||
#define TIME_OVERHEAT_TEMP 40.0 /* °C */
|
||||
|
||||
int red_min = 50;
|
||||
int red_state = red_min;
|
||||
unsigned long brewing_time = 3000UL; /* 3 seconds */
|
||||
unsigned long cooling_time = 3000UL; /* 3 seconds */
|
||||
unsigned long brewing_time = 3000UL; /* 3 seconds */
|
||||
unsigned long cooling_time = 3000UL; /* 3 seconds */
|
||||
unsigned long overheat_time = 10000UL; /* 10 seconds */
|
||||
unsigned long max_heating_time = 60000UL; /* 60 seconds */
|
||||
unsigned long max_idle_time = 10000UL; /* 10 seconds */
|
||||
|
||||
@ -191,6 +208,13 @@ void proc_machine(struct state *st)
|
||||
Serial.print(temp);
|
||||
Serial.println(" C");
|
||||
|
||||
/* If the machine is overheating */
|
||||
if (overheat_panic(&st->overheat)) {
|
||||
st->mstate = PANIC_OVERHEAT;
|
||||
st->overheat_t0 = millis();
|
||||
Serial.println("PANIC OVERHEATING");
|
||||
}
|
||||
|
||||
/* Pressing ON cancels any operation */
|
||||
if (st->mstate != SLEEPING && on) {
|
||||
st->mstate = SLEEPING;
|
||||
@ -237,6 +261,13 @@ void proc_machine(struct state *st)
|
||||
st->heating_t0 = millis();
|
||||
Serial.println("heating");
|
||||
}
|
||||
} else if (st->mstate == PANIC_OVERHEAT) {
|
||||
/* Wait until it cools down and enough time has passed */
|
||||
if (st->ntc_T < TIME_OVERHEAT_TEMP &&
|
||||
millis() - st->overheat_t0 > TIME_OVERHEAT_COOL) {
|
||||
st->mstate = SLEEPING;
|
||||
Serial.println("sleeping");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -277,18 +308,21 @@ output_leds(const struct state *st)
|
||||
if (r >= 255)
|
||||
r = 0;
|
||||
else
|
||||
r += 3;
|
||||
r += 5;
|
||||
} else if (st->mstate == HOT) {
|
||||
setled(PIN_LED_RED, 0);
|
||||
setled(PIN_LED_GREEN, 1);
|
||||
r = 0;
|
||||
} else if (st->mstate == PANIC_OVERHEAT) {
|
||||
setled(PIN_LED_RED, 1);
|
||||
setled(PIN_LED_GREEN, 0);
|
||||
} else if (st->mstate == BREWING) {
|
||||
setled(PIN_LED_RED, 0);
|
||||
analogWrite(PIN_LED_GREEN, g);
|
||||
if (g >= 255)
|
||||
g = 0;
|
||||
else
|
||||
g += 3;
|
||||
g += 5;
|
||||
} else {
|
||||
setled(PIN_LED_RED, 0);
|
||||
setled(PIN_LED_GREEN, 0);
|
||||
@ -326,6 +360,7 @@ void do_output(const struct state *st)
|
||||
|
||||
void setup()
|
||||
{
|
||||
wdt_disable();
|
||||
Serial.begin(9600);
|
||||
Serial.println("Booting");
|
||||
|
||||
@ -341,7 +376,10 @@ void setup()
|
||||
relay(PIN_HEAT, OFF);
|
||||
relay(PIN_PUMP, OFF);
|
||||
|
||||
overheat_init(&g_st.overheat);
|
||||
|
||||
Serial.println("Ready");
|
||||
wdt_enable(WDTO_250MS);
|
||||
}
|
||||
|
||||
void loop()
|
||||
@ -351,4 +389,5 @@ void loop()
|
||||
do_output(&g_st);
|
||||
|
||||
delay(5);
|
||||
wdt_reset();
|
||||
}
|
||||
|
||||
1886
barista/data/dry-heat-50-C.csv
Normal file
1886
barista/data/dry-heat-50-C.csv
Normal file
File diff suppressed because it is too large
Load Diff
959
barista/data/overheat-cutoff.csv
Normal file
959
barista/data/overheat-cutoff.csv
Normal file
@ -0,0 +1,959 @@
|
||||
t_s st temp_C
|
||||
68.167 0 28.12
|
||||
68.204 0 28.15
|
||||
68.241 0 28.16
|
||||
68.278 0 28.18
|
||||
68.313 0 28.19
|
||||
68.349 0 28.22
|
||||
68.386 0 28.22
|
||||
68.423 0 28.21
|
||||
68.458 0 28.19
|
||||
68.495 0 28.19
|
||||
68.532 0 28.21
|
||||
68.569 0 28.22
|
||||
68.605 0 28.24
|
||||
68.640 0 28.22
|
||||
68.677 0 28.21
|
||||
68.714 0 28.22
|
||||
68.751 0 28.24
|
||||
68.786 0 28.26
|
||||
68.823 0 28.26
|
||||
68.859 0 28.24
|
||||
68.896 0 28.22
|
||||
68.933 0 28.21
|
||||
68.968 0 28.22
|
||||
69.005 0 28.13
|
||||
69.042 0 28.10
|
||||
69.079 0 28.08
|
||||
69.113 0 28.07
|
||||
69.150 0 28.05
|
||||
69.187 0 28.05
|
||||
69.224 0 28.07
|
||||
69.259 0 28.05
|
||||
69.296 0 28.04
|
||||
69.332 0 28.02
|
||||
69.369 0 28.01
|
||||
69.406 0 28.01
|
||||
69.441 0 28.02
|
||||
69.478 0 28.04
|
||||
69.515 0 28.04
|
||||
69.552 0 28.04
|
||||
69.586 0 28.07
|
||||
69.623 0 28.12
|
||||
69.660 0 28.13
|
||||
69.697 0 28.15
|
||||
69.734 0 28.15
|
||||
69.769 0 28.13
|
||||
69.806 0 28.12
|
||||
69.842 0 28.13
|
||||
69.879 0 28.15
|
||||
69.914 0 28.12
|
||||
69.951 0 28.12
|
||||
69.988 0 28.10
|
||||
70.025 0 28.08
|
||||
70.060 0 28.08
|
||||
70.096 0 28.10
|
||||
70.133 0 28.10
|
||||
70.170 0 28.16
|
||||
70.207 0 28.13
|
||||
70.242 0 28.12
|
||||
70.279 0 28.10
|
||||
70.316 0 28.12
|
||||
70.352 0 28.13
|
||||
70.387 0 28.15
|
||||
70.424 0 28.12
|
||||
70.461 0 28.10
|
||||
70.498 0 28.13
|
||||
70.535 0 28.15
|
||||
70.569 0 28.18
|
||||
70.606 0 28.12
|
||||
70.643 0 28.08
|
||||
70.680 0 28.07
|
||||
70.715 0 28.05
|
||||
70.752 0 28.07
|
||||
70.789 0 28.08
|
||||
70.825 0 28.10
|
||||
70.860 0 28.10
|
||||
70.897 0 28.08
|
||||
70.934 0 28.07
|
||||
70.971 0 28.07
|
||||
71.008 0 28.12
|
||||
71.043 0 28.08
|
||||
71.079 0 28.08
|
||||
71.116 0 28.07
|
||||
71.153 0 28.05
|
||||
71.188 0 28.12
|
||||
71.225 0 28.13
|
||||
71.262 0 28.15
|
||||
71.299 0 28.16
|
||||
71.335 0 28.15
|
||||
71.370 0 28.15
|
||||
71.407 0 28.15
|
||||
71.444 0 28.16
|
||||
71.481 0 28.18
|
||||
71.516 0 28.18
|
||||
71.553 0 28.15
|
||||
71.589 0 28.13
|
||||
71.626 0 28.18
|
||||
71.663 0 28.18
|
||||
71.698 0 28.19
|
||||
71.735 0 28.24
|
||||
71.772 0 28.24
|
||||
71.809 0 28.24
|
||||
71.843 0 28.22
|
||||
71.880 0 28.21
|
||||
71.917 0 28.21
|
||||
71.954 0 28.21
|
||||
71.989 0 28.21
|
||||
72.026 0 28.21
|
||||
72.062 0 28.19
|
||||
72.099 0 28.15
|
||||
72.136 0 28.07
|
||||
72.171 0 28.00
|
||||
72.208 0 28.00
|
||||
72.245 0 28.02
|
||||
72.282 0 28.00
|
||||
72.316 0 27.94
|
||||
72.353 0 27.90
|
||||
72.390 0 27.90
|
||||
72.427 0 27.91
|
||||
72.464 0 27.93
|
||||
72.499 0 28.03
|
||||
72.536 0 28.03
|
||||
72.572 0 27.91
|
||||
72.609 0 27.86
|
||||
72.644 0 27.88
|
||||
72.681 0 27.95
|
||||
72.718 0 28.02
|
||||
72.755 0 28.06
|
||||
72.790 0 28.03
|
||||
72.826 0 28.00
|
||||
72.863 0 28.02
|
||||
72.900 0 28.05
|
||||
72.937 0 28.13
|
||||
72.972 0 28.13
|
||||
73.009 0 28.09
|
||||
73.046 0 28.02
|
||||
73.082 0 27.70
|
||||
73.117 0 27.72
|
||||
73.154 0 27.84
|
||||
73.191 0 27.89
|
||||
73.228 0 27.83
|
||||
73.265 0 27.76
|
||||
73.299 0 27.81
|
||||
73.336 0 27.90
|
||||
73.373 0 28.01
|
||||
73.410 0 27.98
|
||||
73.445 0 27.95
|
||||
73.482 0 27.90
|
||||
73.519 0 27.87
|
||||
73.555 0 27.88
|
||||
73.592 0 28.09
|
||||
73.627 0 28.15
|
||||
73.664 0 28.32
|
||||
73.701 0 28.29
|
||||
73.738 0 28.27
|
||||
73.773 0 28.27
|
||||
73.809 0 28.33
|
||||
73.846 0 28.38
|
||||
73.883 0 28.41
|
||||
73.918 0 28.37
|
||||
73.955 0 28.26
|
||||
73.992 0 28.32
|
||||
74.029 0 28.35
|
||||
74.065 0 28.40
|
||||
74.100 0 28.46
|
||||
74.137 0 28.43
|
||||
74.174 0 28.24
|
||||
74.211 0 28.25
|
||||
74.246 0 28.33
|
||||
74.283 0 28.36
|
||||
74.319 0 28.35
|
||||
74.356 0 28.35
|
||||
74.393 0 28.24
|
||||
74.428 0 28.24
|
||||
74.465 0 28.22
|
||||
74.502 0 28.22
|
||||
74.539 0 28.28
|
||||
74.573 0 28.22
|
||||
74.610 0 28.19
|
||||
74.647 0 28.19
|
||||
74.684 0 28.14
|
||||
74.719 0 28.19
|
||||
74.756 0 28.19
|
||||
74.792 0 28.13
|
||||
74.829 0 28.08
|
||||
74.866 0 28.26
|
||||
74.901 0 28.29
|
||||
74.938 0 28.29
|
||||
74.975 0 28.46
|
||||
75.012 0 28.40
|
||||
75.046 0 28.35
|
||||
75.083 0 28.26
|
||||
75.120 0 28.24
|
||||
75.157 0 28.30
|
||||
75.194 0 28.34
|
||||
75.229 0 28.27
|
||||
75.266 0 28.21
|
||||
75.302 0 28.16
|
||||
75.339 0 28.18
|
||||
75.374 0 28.26
|
||||
75.411 0 28.30
|
||||
75.448 0 28.03
|
||||
75.485 0 28.00
|
||||
75.520 0 27.96
|
||||
75.556 0 27.90
|
||||
75.593 0 28.00
|
||||
75.630 0 28.08
|
||||
75.667 0 28.16
|
||||
75.702 0 28.00
|
||||
75.739 0 28.00
|
||||
75.776 0 28.00
|
||||
75.812 0 28.06
|
||||
75.847 0 28.12
|
||||
75.884 0 28.19
|
||||
75.921 0 28.15
|
||||
75.958 0 28.12
|
||||
75.995 0 28.11
|
||||
76.029 0 28.22
|
||||
76.066 0 28.25
|
||||
76.103 0 28.28
|
||||
76.140 0 28.22
|
||||
76.175 0 28.14
|
||||
76.212 0 28.10
|
||||
76.249 0 28.10
|
||||
76.285 0 28.24
|
||||
76.322 0 28.22
|
||||
76.357 0 28.19
|
||||
76.394 0 28.15
|
||||
76.431 0 28.13
|
||||
76.468 0 28.12
|
||||
76.503 0 28.16
|
||||
76.539 0 28.11
|
||||
76.576 0 28.05
|
||||
76.613 0 27.99
|
||||
76.648 0 28.11
|
||||
76.685 0 28.13
|
||||
76.722 0 28.19
|
||||
76.759 0 28.22
|
||||
76.795 0 28.19
|
||||
76.830 0 28.13
|
||||
76.867 0 28.09
|
||||
76.904 0 28.18
|
||||
76.941 0 28.22
|
||||
76.976 0 28.26
|
||||
77.012 0 28.26
|
||||
77.049 0 28.22
|
||||
77.086 0 28.17
|
||||
77.123 0 28.23
|
||||
77.158 0 28.29
|
||||
77.195 0 28.34
|
||||
77.232 0 28.19
|
||||
77.268 0 28.13
|
||||
77.303 0 28.20
|
||||
77.340 0 28.19
|
||||
77.377 0 28.26
|
||||
77.414 0 28.31
|
||||
77.449 0 28.33
|
||||
77.486 0 28.24
|
||||
77.522 0 28.17
|
||||
77.559 0 28.16
|
||||
77.596 0 28.16
|
||||
77.631 0 28.19
|
||||
77.668 0 28.22
|
||||
77.705 0 28.17
|
||||
77.742 0 28.16
|
||||
77.776 0 28.20
|
||||
77.813 0 28.24
|
||||
77.850 0 28.15
|
||||
77.887 0 28.11
|
||||
77.924 0 28.08
|
||||
77.959 0 27.99
|
||||
77.996 0 27.99
|
||||
78.032 0 28.00
|
||||
78.069 0 28.02
|
||||
78.104 0 28.03
|
||||
78.141 0 28.02
|
||||
78.178 0 27.97
|
||||
78.215 0 27.96
|
||||
78.252 0 27.94
|
||||
78.286 0 27.99
|
||||
78.323 0 28.00
|
||||
78.360 0 27.94
|
||||
78.397 0 27.88
|
||||
78.432 0 27.98
|
||||
78.469 0 27.94
|
||||
78.505 0 28.07
|
||||
78.542 0 28.10
|
||||
78.577 0 28.11
|
||||
78.614 0 28.05
|
||||
78.651 0 28.14
|
||||
78.688 0 28.17
|
||||
78.725 0 28.20
|
||||
78.759 0 28.28
|
||||
78.796 0 28.30
|
||||
78.833 0 28.20
|
||||
78.870 0 28.19
|
||||
78.905 0 28.17
|
||||
78.942 0 28.19
|
||||
78.979 0 28.23
|
||||
79.015 0 28.28
|
||||
79.052 0 28.22
|
||||
79.087 0 28.16
|
||||
79.124 0 28.17
|
||||
79.161 0 28.17
|
||||
79.198 0 28.22
|
||||
79.233 0 28.20
|
||||
79.269 0 28.17
|
||||
79.306 0 28.14
|
||||
79.343 0 28.05
|
||||
79.378 0 28.20
|
||||
79.415 0 28.31
|
||||
79.452 0 28.31
|
||||
79.489 0 28.28
|
||||
79.525 0 28.25
|
||||
79.560 0 28.23
|
||||
79.597 0 28.21
|
||||
79.634 0 28.28
|
||||
79.671 0 28.28
|
||||
79.706 0 28.29
|
||||
79.742 0 28.23
|
||||
79.779 0 28.20
|
||||
79.816 0 28.11
|
||||
79.853 0 28.15
|
||||
79.888 0 28.20
|
||||
79.925 0 28.17
|
||||
79.962 0 27.99
|
||||
79.998 0 27.96
|
||||
80.033 0 27.96
|
||||
80.070 0 28.00
|
||||
80.107 0 28.04
|
||||
80.144 0 28.10
|
||||
80.179 0 27.85
|
||||
80.216 0 27.82
|
||||
80.252 0 27.77
|
||||
80.289 0 27.76
|
||||
80.326 0 27.84
|
||||
80.361 0 27.84
|
||||
80.398 0 27.81
|
||||
80.435 0 27.77
|
||||
80.472 0 27.71
|
||||
80.506 0 27.82
|
||||
80.543 0 27.84
|
||||
80.580 0 27.87
|
||||
80.617 0 27.85
|
||||
80.654 0 27.82
|
||||
80.689 0 27.78
|
||||
80.736 2 27.70
|
||||
80.771 2 27.95
|
||||
80.807 2 28.04
|
||||
80.844 2 28.02
|
||||
80.881 2 28.11
|
||||
80.918 2 27.99
|
||||
80.953 2 28.02
|
||||
80.990 2 28.03
|
||||
81.027 2 27.95
|
||||
81.063 2 27.95
|
||||
81.098 2 27.91
|
||||
81.135 2 27.83
|
||||
81.172 2 27.81
|
||||
81.209 2 27.81
|
||||
81.246 2 27.80
|
||||
81.281 2 27.84
|
||||
81.317 2 27.86
|
||||
81.354 2 27.76
|
||||
81.391 2 27.67
|
||||
81.426 2 27.72
|
||||
81.463 2 27.55
|
||||
81.500 2 27.66
|
||||
81.537 2 27.63
|
||||
81.571 2 27.65
|
||||
81.608 2 27.77
|
||||
81.645 2 27.82
|
||||
81.682 2 27.85
|
||||
81.719 2 27.94
|
||||
81.754 2 27.94
|
||||
81.790 2 27.94
|
||||
81.827 2 27.93
|
||||
81.864 2 27.91
|
||||
81.899 2 27.94
|
||||
81.936 2 28.05
|
||||
81.973 2 28.05
|
||||
82.010 2 28.05
|
||||
82.046 2 28.07
|
||||
82.081 2 28.16
|
||||
82.118 2 28.17
|
||||
82.155 2 28.17
|
||||
82.192 2 28.16
|
||||
82.227 2 28.17
|
||||
82.264 2 28.08
|
||||
82.300 2 28.06
|
||||
82.337 2 28.08
|
||||
82.372 2 28.11
|
||||
82.409 2 28.19
|
||||
82.446 2 28.20
|
||||
82.483 2 28.20
|
||||
82.520 2 28.20
|
||||
82.554 2 28.26
|
||||
82.591 2 28.34
|
||||
82.628 2 28.43
|
||||
82.665 2 28.34
|
||||
82.700 2 28.36
|
||||
82.737 2 28.39
|
||||
82.774 2 28.37
|
||||
82.810 2 28.34
|
||||
82.847 2 28.44
|
||||
82.882 2 28.45
|
||||
82.919 2 28.44
|
||||
82.956 2 28.45
|
||||
82.993 2 28.44
|
||||
83.027 2 28.51
|
||||
83.064 2 28.43
|
||||
83.101 2 28.43
|
||||
83.138 2 28.40
|
||||
83.175 2 28.33
|
||||
83.210 2 28.31
|
||||
83.247 2 28.31
|
||||
83.283 2 28.33
|
||||
83.320 2 28.31
|
||||
83.355 2 28.33
|
||||
83.392 2 28.36
|
||||
83.429 2 28.39
|
||||
83.466 2 28.41
|
||||
83.501 2 28.45
|
||||
83.537 2 28.48
|
||||
83.574 2 28.54
|
||||
83.611 2 28.40
|
||||
83.648 2 28.54
|
||||
83.683 2 28.56
|
||||
83.720 2 28.57
|
||||
83.757 2 28.57
|
||||
83.793 2 28.60
|
||||
83.828 2 28.65
|
||||
83.865 2 28.69
|
||||
83.902 2 28.73
|
||||
83.939 2 28.76
|
||||
83.976 2 28.82
|
||||
84.011 2 28.86
|
||||
84.047 2 28.92
|
||||
84.084 2 28.86
|
||||
84.121 2 28.89
|
||||
84.156 2 28.90
|
||||
84.193 2 29.00
|
||||
84.230 2 29.06
|
||||
84.267 2 29.13
|
||||
84.301 2 29.21
|
||||
84.338 2 29.30
|
||||
84.375 2 29.35
|
||||
84.412 2 29.40
|
||||
84.449 2 29.50
|
||||
84.484 2 29.58
|
||||
84.520 2 29.62
|
||||
84.557 2 29.64
|
||||
84.594 2 29.67
|
||||
84.629 2 29.74
|
||||
84.666 2 29.90
|
||||
84.703 2 29.93
|
||||
84.740 2 30.05
|
||||
84.776 2 30.12
|
||||
84.811 2 30.14
|
||||
84.848 2 30.18
|
||||
84.885 2 30.22
|
||||
84.922 2 30.27
|
||||
84.957 2 30.35
|
||||
84.994 2 30.32
|
||||
85.030 2 30.32
|
||||
85.067 2 30.35
|
||||
85.104 2 30.51
|
||||
85.139 2 30.60
|
||||
85.176 2 30.67
|
||||
85.213 2 30.70
|
||||
85.250 2 30.81
|
||||
85.284 2 30.90
|
||||
85.321 2 30.87
|
||||
85.358 2 30.94
|
||||
85.395 2 31.00
|
||||
85.430 2 31.08
|
||||
85.467 2 31.19
|
||||
85.504 2 31.25
|
||||
85.540 2 31.27
|
||||
85.577 2 31.45
|
||||
85.612 2 31.54
|
||||
85.649 2 31.63
|
||||
85.686 2 31.63
|
||||
85.723 2 31.69
|
||||
85.757 2 31.79
|
||||
85.794 2 31.79
|
||||
85.831 2 31.76
|
||||
85.868 2 31.84
|
||||
85.905 2 31.63
|
||||
85.940 2 31.75
|
||||
85.977 2 31.83
|
||||
86.013 2 31.91
|
||||
86.050 2 31.99
|
||||
86.085 2 32.10
|
||||
86.122 2 32.18
|
||||
86.159 2 32.21
|
||||
86.196 2 32.38
|
||||
86.231 2 32.48
|
||||
86.267 2 32.66
|
||||
86.304 2 32.84
|
||||
86.341 2 32.92
|
||||
86.378 2 33.08
|
||||
86.413 2 33.16
|
||||
86.450 2 33.22
|
||||
86.487 2 33.60
|
||||
86.523 2 33.67
|
||||
86.579 6 33.79
|
||||
86.636 6 33.88
|
||||
86.691 6 33.97
|
||||
86.747 6 34.10
|
||||
86.804 6 34.26
|
||||
86.859 6 34.43
|
||||
86.917 6 34.47
|
||||
86.972 6 34.60
|
||||
87.027 6 34.64
|
||||
87.085 6 34.73
|
||||
87.140 6 34.79
|
||||
87.197 6 34.94
|
||||
87.252 6 35.15
|
||||
87.310 6 35.30
|
||||
87.365 6 35.48
|
||||
87.420 6 35.67
|
||||
87.478 6 35.76
|
||||
87.533 6 35.94
|
||||
87.590 6 36.07
|
||||
87.646 6 36.15
|
||||
87.703 6 36.27
|
||||
87.758 6 36.36
|
||||
87.814 6 36.55
|
||||
87.871 6 36.72
|
||||
87.926 6 36.91
|
||||
87.984 6 37.10
|
||||
88.039 6 37.33
|
||||
88.094 6 37.50
|
||||
88.152 6 37.68
|
||||
88.207 6 37.81
|
||||
88.264 6 37.99
|
||||
88.320 6 38.15
|
||||
88.377 6 38.40
|
||||
88.432 6 38.52
|
||||
88.487 6 38.71
|
||||
88.545 6 38.99
|
||||
88.600 6 39.20
|
||||
88.657 6 39.43
|
||||
88.713 6 39.57
|
||||
88.770 6 39.73
|
||||
88.825 6 39.90
|
||||
88.881 6 40.03
|
||||
88.938 6 40.21
|
||||
88.993 6 40.38
|
||||
89.051 6 40.64
|
||||
89.106 6 40.89
|
||||
89.161 6 41.06
|
||||
89.219 6 41.32
|
||||
89.274 6 41.44
|
||||
89.331 6 41.65
|
||||
89.387 6 41.81
|
||||
89.444 6 41.95
|
||||
89.499 6 42.11
|
||||
89.554 6 42.30
|
||||
89.612 6 42.44
|
||||
89.667 6 42.62
|
||||
89.724 6 42.77
|
||||
89.780 6 42.91
|
||||
89.837 6 43.07
|
||||
89.892 6 43.23
|
||||
89.948 6 43.29
|
||||
90.005 6 43.47
|
||||
90.060 6 43.58
|
||||
90.118 6 43.66
|
||||
90.173 6 43.85
|
||||
90.228 6 43.99
|
||||
90.286 6 44.13
|
||||
90.341 6 44.26
|
||||
90.398 6 44.42
|
||||
90.454 6 44.53
|
||||
90.511 6 44.70
|
||||
90.566 6 44.84
|
||||
90.621 6 44.98
|
||||
90.679 6 45.14
|
||||
90.734 6 45.27
|
||||
90.791 6 45.41
|
||||
90.847 6 45.55
|
||||
90.904 6 45.63
|
||||
90.959 6 45.78
|
||||
91.015 6 45.91
|
||||
91.072 6 46.02
|
||||
91.127 6 46.14
|
||||
91.185 6 46.28
|
||||
91.240 6 46.38
|
||||
91.297 6 46.48
|
||||
91.353 6 46.60
|
||||
91.408 6 46.71
|
||||
91.465 6 46.82
|
||||
91.521 6 46.95
|
||||
91.578 6 47.04
|
||||
91.633 6 47.17
|
||||
91.688 6 47.27
|
||||
91.746 6 47.36
|
||||
91.801 6 47.47
|
||||
91.858 6 47.58
|
||||
91.914 6 47.67
|
||||
91.971 6 47.78
|
||||
92.026 6 47.89
|
||||
92.082 6 47.99
|
||||
92.139 6 48.12
|
||||
92.194 6 48.21
|
||||
92.252 6 48.28
|
||||
92.307 6 48.37
|
||||
92.344 6 48.45
|
||||
92.381 6 48.53
|
||||
92.416 6 48.63
|
||||
92.452 6 48.67
|
||||
92.489 6 48.76
|
||||
92.526 6 48.84
|
||||
92.563 6 48.92
|
||||
92.598 6 48.95
|
||||
92.635 6 49.03
|
||||
92.672 6 49.08
|
||||
92.708 6 49.15
|
||||
92.743 6 49.20
|
||||
92.780 6 49.28
|
||||
92.817 6 49.34
|
||||
92.854 6 49.42
|
||||
92.889 6 49.49
|
||||
92.925 6 49.54
|
||||
92.962 6 49.57
|
||||
92.999 6 49.61
|
||||
93.036 6 49.67
|
||||
93.071 6 49.71
|
||||
93.108 6 49.78
|
||||
93.145 6 49.82
|
||||
93.181 6 49.90
|
||||
93.216 6 49.95
|
||||
93.253 6 50.00
|
||||
93.290 6 50.04
|
||||
93.327 6 50.14
|
||||
93.364 6 50.16
|
||||
93.399 6 50.20
|
||||
93.435 6 50.24
|
||||
93.472 6 50.36
|
||||
93.509 6 50.40
|
||||
93.544 6 50.47
|
||||
93.581 6 50.52
|
||||
93.618 6 50.56
|
||||
93.655 6 50.59
|
||||
93.691 6 50.62
|
||||
93.726 6 50.67
|
||||
93.763 6 50.76
|
||||
93.800 6 50.81
|
||||
93.837 6 50.85
|
||||
93.872 6 50.88
|
||||
93.908 6 50.86
|
||||
93.945 6 50.87
|
||||
93.982 6 50.87
|
||||
94.017 6 50.93
|
||||
94.054 6 50.82
|
||||
94.091 6 50.86
|
||||
94.128 6 50.87
|
||||
94.164 6 50.94
|
||||
94.199 6 50.98
|
||||
94.236 6 51.04
|
||||
94.273 6 51.08
|
||||
94.310 6 51.11
|
||||
94.345 6 51.09
|
||||
94.382 6 51.13
|
||||
94.418 6 51.18
|
||||
94.455 6 51.22
|
||||
94.492 6 51.27
|
||||
94.527 6 51.32
|
||||
94.564 6 51.44
|
||||
94.601 6 51.40
|
||||
94.638 6 51.51
|
||||
94.672 6 51.50
|
||||
94.709 6 51.54
|
||||
94.746 6 51.54
|
||||
94.783 6 51.37
|
||||
94.818 6 51.40
|
||||
94.855 6 51.45
|
||||
94.892 6 51.57
|
||||
94.928 6 51.60
|
||||
94.965 6 51.62
|
||||
95.000 6 51.63
|
||||
95.037 6 51.65
|
||||
95.074 6 51.69
|
||||
95.111 6 51.72
|
||||
95.145 6 51.71
|
||||
95.182 6 51.79
|
||||
95.219 6 51.81
|
||||
95.256 6 51.91
|
||||
95.293 6 51.95
|
||||
95.328 6 52.01
|
||||
95.365 6 52.14
|
||||
95.401 6 52.16
|
||||
95.438 6 52.17
|
||||
95.473 6 52.09
|
||||
95.510 6 52.17
|
||||
95.547 6 52.18
|
||||
95.584 6 52.24
|
||||
95.619 6 52.35
|
||||
95.655 6 52.36
|
||||
95.692 6 52.37
|
||||
95.729 6 52.38
|
||||
95.766 6 52.42
|
||||
95.801 6 52.50
|
||||
95.838 6 52.54
|
||||
95.875 6 52.55
|
||||
95.911 6 52.56
|
||||
95.946 6 52.68
|
||||
95.983 6 52.71
|
||||
96.020 6 52.76
|
||||
96.057 6 52.69
|
||||
96.094 6 52.67
|
||||
96.129 6 52.71
|
||||
96.165 6 52.71
|
||||
96.202 6 52.68
|
||||
96.239 6 52.72
|
||||
96.274 6 52.77
|
||||
96.311 6 52.82
|
||||
96.348 6 52.83
|
||||
96.385 6 52.80
|
||||
96.421 6 52.77
|
||||
96.456 6 52.81
|
||||
96.493 6 52.85
|
||||
96.530 6 52.85
|
||||
96.567 6 52.84
|
||||
96.602 6 52.84
|
||||
96.638 6 52.96
|
||||
96.675 6 53.00
|
||||
96.712 6 53.04
|
||||
96.747 6 53.08
|
||||
96.784 6 53.07
|
||||
96.821 6 53.10
|
||||
96.858 6 53.12
|
||||
96.894 6 53.13
|
||||
96.929 6 53.18
|
||||
96.966 6 53.19
|
||||
97.003 6 53.22
|
||||
97.040 6 53.22
|
||||
97.075 6 53.24
|
||||
97.112 6 53.27
|
||||
97.148 6 53.35
|
||||
97.185 6 53.33
|
||||
97.222 6 53.34
|
||||
97.257 6 53.34
|
||||
97.294 6 53.38
|
||||
97.331 6 53.48
|
||||
97.368 6 53.50
|
||||
97.402 6 53.49
|
||||
97.439 6 53.49
|
||||
97.476 6 53.47
|
||||
97.513 6 53.48
|
||||
97.548 6 53.50
|
||||
97.585 6 53.54
|
||||
97.622 6 53.57
|
||||
97.658 6 53.55
|
||||
97.695 6 53.55
|
||||
97.730 6 53.56
|
||||
97.767 6 53.66
|
||||
97.804 6 53.70
|
||||
97.841 6 53.72
|
||||
97.875 6 53.70
|
||||
97.912 6 53.63
|
||||
97.949 6 53.51
|
||||
97.986 6 53.54
|
||||
98.023 6 53.56
|
||||
98.058 6 53.62
|
||||
98.095 6 53.61
|
||||
98.131 6 53.62
|
||||
98.168 6 53.63
|
||||
98.203 6 53.66
|
||||
98.240 6 53.70
|
||||
98.277 6 53.75
|
||||
98.314 6 53.76
|
||||
98.351 6 53.73
|
||||
98.385 6 53.73
|
||||
98.422 6 53.75
|
||||
98.459 6 53.77
|
||||
98.496 6 53.80
|
||||
98.531 6 53.94
|
||||
98.568 6 53.93
|
||||
98.605 6 53.93
|
||||
98.641 6 53.94
|
||||
98.676 6 53.99
|
||||
98.713 6 54.00
|
||||
98.750 6 54.02
|
||||
98.787 6 54.04
|
||||
98.824 6 54.05
|
||||
98.859 6 54.05
|
||||
98.895 6 54.07
|
||||
98.932 6 54.14
|
||||
98.969 6 54.16
|
||||
99.004 6 54.19
|
||||
99.041 6 54.18
|
||||
99.078 6 54.19
|
||||
99.115 6 54.21
|
||||
99.151 6 54.26
|
||||
99.186 6 54.28
|
||||
99.223 6 54.29
|
||||
99.260 6 54.28
|
||||
99.297 6 54.29
|
||||
99.332 6 54.31
|
||||
99.368 6 54.33
|
||||
99.405 6 54.41
|
||||
99.442 6 54.41
|
||||
99.477 6 54.41
|
||||
99.514 6 54.37
|
||||
99.551 6 54.37
|
||||
99.588 6 54.37
|
||||
99.624 6 54.41
|
||||
99.659 6 54.41
|
||||
99.696 6 54.42
|
||||
99.733 6 54.41
|
||||
99.770 6 54.43
|
||||
99.805 6 54.45
|
||||
99.842 6 54.48
|
||||
99.878 6 54.49
|
||||
99.915 6 54.45
|
||||
99.952 6 54.42
|
||||
99.987 6 54.36
|
||||
100.024 6 54.32
|
||||
100.061 6 54.35
|
||||
100.100 6 54.38
|
||||
100.136 6 54.40
|
||||
100.173 6 54.40
|
||||
100.210 6 54.37
|
||||
100.249 6 54.38
|
||||
100.286 6 54.39
|
||||
100.323 6 54.41
|
||||
100.362 6 54.41
|
||||
100.399 6 54.42
|
||||
100.435 6 54.43
|
||||
100.472 6 54.44
|
||||
100.511 6 54.54
|
||||
100.548 6 54.54
|
||||
100.585 6 54.54
|
||||
100.624 6 54.61
|
||||
100.661 6 54.60
|
||||
100.698 6 54.60
|
||||
100.734 6 54.61
|
||||
100.773 6 54.63
|
||||
100.810 6 54.68
|
||||
100.847 6 54.69
|
||||
100.886 6 54.69
|
||||
100.923 6 54.69
|
||||
100.960 6 54.69
|
||||
100.997 6 54.74
|
||||
101.036 6 54.74
|
||||
101.072 6 54.76
|
||||
101.109 6 54.75
|
||||
101.148 6 54.77
|
||||
101.185 6 54.78
|
||||
101.222 6 54.78
|
||||
101.259 6 54.78
|
||||
101.298 6 54.79
|
||||
101.335 6 54.79
|
||||
101.371 6 54.82
|
||||
101.408 6 54.83
|
||||
101.447 6 54.87
|
||||
101.484 6 54.89
|
||||
101.521 6 54.91
|
||||
101.560 6 54.91
|
||||
101.597 6 54.81
|
||||
101.634 6 54.74
|
||||
101.670 6 54.74
|
||||
101.709 6 54.71
|
||||
101.746 6 54.74
|
||||
101.783 6 54.74
|
||||
101.822 6 54.77
|
||||
101.859 6 54.78
|
||||
101.896 6 54.77
|
||||
101.933 6 54.72
|
||||
101.971 6 54.68
|
||||
102.008 6 54.67
|
||||
102.045 6 54.67
|
||||
102.084 6 54.72
|
||||
102.121 6 54.74
|
||||
102.158 6 54.76
|
||||
102.195 6 54.83
|
||||
102.234 6 54.89
|
||||
102.270 6 54.89
|
||||
102.307 6 54.88
|
||||
102.346 6 54.87
|
||||
102.383 6 54.90
|
||||
102.420 6 54.92
|
||||
102.457 6 54.95
|
||||
102.496 6 54.97
|
||||
102.533 6 55.04
|
||||
102.569 6 55.05
|
||||
102.606 6 55.05
|
||||
102.645 6 55.04
|
||||
102.682 6 55.00
|
||||
102.719 6 55.00
|
||||
102.758 6 55.01
|
||||
102.795 6 55.04
|
||||
102.832 6 55.07
|
||||
102.868 6 55.08
|
||||
102.907 6 55.10
|
||||
102.944 6 55.11
|
||||
102.981 6 55.05
|
||||
103.020 6 55.06
|
||||
103.057 6 55.05
|
||||
103.094 6 55.06
|
||||
103.131 6 55.07
|
||||
103.170 6 55.11
|
||||
103.206 6 55.12
|
||||
103.243 6 55.12
|
||||
103.282 6 55.11
|
||||
103.319 6 55.09
|
||||
103.356 6 55.09
|
||||
103.393 6 55.14
|
||||
103.432 6 55.07
|
||||
103.469 6 55.09
|
||||
103.505 6 55.12
|
||||
103.544 6 55.14
|
||||
103.581 6 55.19
|
||||
103.618 6 55.17
|
||||
103.655 6 54.96
|
||||
103.694 6 54.92
|
||||
103.731 6 54.94
|
||||
103.768 6 54.93
|
||||
103.804 6 54.96
|
||||
103.843 6 54.99
|
||||
103.880 6 55.02
|
||||
103.917 6 55.02
|
||||
103.956 6 54.98
|
||||
103.993 6 54.92
|
||||
104.030 6 54.97
|
||||
104.067 6 55.02
|
||||
104.105 6 55.02
|
||||
104.142 6 55.02
|
||||
104.179 6 55.05
|
||||
104.218 6 55.07
|
||||
104.255 6 55.19
|
||||
104.292 6 55.22
|
||||
104.329 6 55.12
|
||||
104.368 6 55.11
|
||||
104.404 6 55.06
|
||||
104.441 6 55.06
|
||||
104.480 6 55.04
|
||||
104.517 6 55.06
|
||||
104.554 6 55.12
|
||||
104.591 6 55.17
|
||||
104.630 6 55.18
|
||||
104.667 6 55.14
|
||||
104.704 6 55.12
|
||||
104.742 6 55.10
|
||||
104.779 6 55.14
|
||||
104.816 6 55.17
|
||||
104.853 6 55.28
|
||||
104.892 6 55.31
|
||||
104.929 6 55.40
|
||||
104.966 6 55.40
|
||||
105.003 6 55.42
|
||||
105.041 6 55.40
|
||||
105.078 6 55.44
|
||||
105.115 6 55.45
|
||||
105.154 6 55.45
|
||||
105.191 6 55.41
|
||||
|
52
barista/overheat.c
Normal file
52
barista/overheat.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* Copyright (c) 2025 Rodrigo Arias Mallo <rodarima@gmail.com>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
|
||||
#include "overheat.h"
|
||||
#include <string.h>
|
||||
|
||||
void
|
||||
overheat_init(struct overheat *o)
|
||||
{
|
||||
memset(o, 0, sizeof(struct overheat));
|
||||
}
|
||||
|
||||
void
|
||||
overheat_input(struct overheat *o, unsigned long t_ms, float temp)
|
||||
{
|
||||
unsigned long delta = t_ms - o->last_time;
|
||||
|
||||
if (delta < OVH_INTERVAL)
|
||||
return;
|
||||
|
||||
o->temp[o->next++] = temp;
|
||||
if (o->next >= OVH_NSAMPLES)
|
||||
o->next = 0;
|
||||
if (o->n < OVH_NSAMPLES)
|
||||
o->n++;
|
||||
|
||||
/* Recompute state */
|
||||
float tmin = 10000.0, tmax = 0.0;
|
||||
for (int i = 0; i < o->n; i++) {
|
||||
if (o->temp[i] < tmin)
|
||||
tmin = o->temp[i];
|
||||
if (o->temp[i] > tmax)
|
||||
tmax = o->temp[i];
|
||||
}
|
||||
|
||||
o->delta = tmax - tmin;
|
||||
}
|
||||
|
||||
float
|
||||
overheat_delta(struct overheat *o)
|
||||
{
|
||||
return o->delta;
|
||||
}
|
||||
|
||||
int
|
||||
overheat_panic(struct overheat *o)
|
||||
{
|
||||
if (o->delta > OVH_THRESHOLD)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
32
barista/overheat.h
Normal file
32
barista/overheat.h
Normal file
@ -0,0 +1,32 @@
|
||||
/* Copyright (c) 2025 Rodrigo Arias Mallo <rodarima@gmail.com>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
|
||||
#ifndef BARISTA_OVERHEAT_H
|
||||
#define BARISTA_OVERHEAT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define OVH_NSAMPLES 20
|
||||
#define OVH_INTERVAL 200 /* ms */
|
||||
#define OVH_THRESHOLD 2.0 /* °C */
|
||||
|
||||
struct overheat {
|
||||
unsigned long last_time;
|
||||
float temp[OVH_NSAMPLES];
|
||||
int next;
|
||||
int n;
|
||||
float delta;
|
||||
};
|
||||
|
||||
void overheat_init(struct overheat *o);
|
||||
void overheat_input(struct overheat *o, unsigned long t_ms, float temp);
|
||||
float overheat_delta(struct overheat *o);
|
||||
int overheat_panic(struct overheat *o);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BARISTA_OVERHEAT_H */
|
||||
@ -1,3 +1,6 @@
|
||||
/* Copyright (c) 2025 Rodrigo Arias Mallo <rodarima@gmail.com>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "ntc.h"
|
||||
|
||||
|
||||
36
barista/test/test_overheat.c
Normal file
36
barista/test/test_overheat.c
Normal file
@ -0,0 +1,36 @@
|
||||
/* Copyright (c) 2025 Rodrigo Arias Mallo <rodarima@gmail.com>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "overheat.h"
|
||||
|
||||
/* Read a CSV from the stdin in the format
|
||||
* <time_in_seconds> <state> <temp_in_C>
|
||||
* skipping the first row (header).
|
||||
*
|
||||
* Outputs overheat state. */
|
||||
|
||||
#define MAX_LINE 1024
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char buf[MAX_LINE];
|
||||
fgets(buf, MAX_LINE, stdin);
|
||||
|
||||
float t, temp;
|
||||
int st;
|
||||
|
||||
struct overheat ovh;
|
||||
overheat_init(&ovh);
|
||||
|
||||
while (scanf("%f %d %f", &t, &st, &temp) == 3) {
|
||||
|
||||
overheat_input(&ovh, t * 1000.0, temp);
|
||||
float delta = overheat_delta(&ovh);
|
||||
int panic = overheat_panic(&ovh);
|
||||
|
||||
printf("%.3f %d %.2f %.1f %s\n", t, st, temp, delta, panic ? "PANIC" : "OK");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user