aboutsummaryrefslogtreecommitdiff
path: root/Detector_Building_v2/Detector_Building_v2.ino
diff options
context:
space:
mode:
authorTa180m2020-02-22 12:01:26 -0600
committerTa180m2020-02-22 12:01:26 -0600
commit9969ee83cf4618609eaa61bd614a8da1f62e197a (patch)
tree79d2502a492a97f28b4649cc2f8456394bfee1cd /Detector_Building_v2/Detector_Building_v2.ino
parentcb17e030e5c1ca047637af04234c827e5da08c2b (diff)
Fixed some numbers
Diffstat (limited to 'Detector_Building_v2/Detector_Building_v2.ino')
-rw-r--r--Detector_Building_v2/Detector_Building_v2.ino24
1 files changed, 12 insertions, 12 deletions
diff --git a/Detector_Building_v2/Detector_Building_v2.ino b/Detector_Building_v2/Detector_Building_v2.ino
index e28c92b..df54c24 100644
--- a/Detector_Building_v2/Detector_Building_v2.ino
+++ b/Detector_Building_v2/Detector_Building_v2.ino
@@ -13,14 +13,14 @@
#include <detectorBuilding.h>
const bool CALIB = false; // Calibration mode
-const int n = 4; // Number of data points
+const int n = 17; // Number of data points
const int m = 1; // Number of segments
const int deg = 2; // Regression degree
double V[n] = { // Voltage measurements
- 2.12, 3.26, 3.96, 4.1
+ 2.70, 3.39, 2.40, 2.31, 2.19, 1.94, 4.09, 4.11, 3.98, 3.92, 3.77, 3.53, 3.18, 3.07, 2.30, 2.53, 2.49
};
double T[n] = { // Temperature measurements
- 22.0, 39.15, 60, 72
+ 24.0, 44.4, 18.4, 13.9, 11.2, 8.6, 60.8, 62.0, 58.3, 53.9, 49.3, 44.9, 41.0, 37.3, 13.4, 19.1, 18.2
};
double coeff[m][deg + 1];
@@ -35,19 +35,19 @@ void setup() {
sort(T, n);
double x[n], y[n];
- for (int i = 0; i < n; i++) x[i] = log(v2r(V[i])) - 5;
- for (int i = 0; i < n; i++) y[i] = 1 / c2k(T[i]);
- /*for (int i = 0; i < n; i++) {
+ for (int i = 0; i < n; i++) x[i] = log(v2r(V[i])) - 7;
+ for (int i = 0; i < n; i++) y[i] = 1000 / c2k(T[i]);
+ for (int i = 0; i < n; i++) {
Serial.print("(");
Serial.print(x[i], 12);
Serial.print(", ");
Serial.print(y[i], 12);
Serial.print(")");
Serial.println();
- }*/
+ }
for (int i = 0; i < m; i++) {
int ret = fitCurve(deg, n / m, x + i * n / m, y + i * n / m, deg + 1, coeff[i]);
- /*if (ret == 0){ //Returned value is 0 if no error
+ if (ret == 0){ //Returned value is 0 if no error
char c = 'A';
Serial.println("Coefficients are:");
for (int j = 0; j <= deg; j++){
@@ -56,7 +56,7 @@ void setup() {
Serial.print(coeff[i][j], 12);
Serial.println();
}
- }*/
+ }
}
}
@@ -78,19 +78,19 @@ void loop() {
int s = 0;
while (s + 1 < m && V_out < (V[s * n / m - 1] + V[s * n / m]) / 2) s++; // Find correct segment
- double logR = log(v2r(V_out)) - 5;
+ double logR = log(v2r(V_out)) - 7;
double sum = 0, prod = 1;
for (int i = 0; i <= deg; i++) {
sum += coeff[s][deg - i] * prod;
prod *= logR;
}
- double K = 1 / sum;
+ double K = 1000 / sum;
double C = k2c(K);
double F = c2f(C);
// LED stuff
- if (C <= 25) { // Cold
+ if (C <= 30) { // Cold
digitalWrite(LED_R, LOW);
digitalWrite(LED_G, LOW);
digitalWrite(LED_B, HIGH);