aboutsummaryrefslogtreecommitdiff
path: root/Detector_Building_v2/Detector_Building_v2.ino
diff options
context:
space:
mode:
Diffstat (limited to 'Detector_Building_v2/Detector_Building_v2.ino')
-rw-r--r--Detector_Building_v2/Detector_Building_v2.ino30
1 files changed, 17 insertions, 13 deletions
diff --git a/Detector_Building_v2/Detector_Building_v2.ino b/Detector_Building_v2/Detector_Building_v2.ino
index 05f148b..b63f792 100644
--- a/Detector_Building_v2/Detector_Building_v2.ino
+++ b/Detector_Building_v2/Detector_Building_v2.ino
@@ -15,14 +15,13 @@
const bool CALIB = false; // Calibration mode
const int n = 17; // Number of data points
const int m = 1; // Number of segments
-const int deg = 2; // Regression degree
-ld V[n] = { // Voltage measurements
- 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
-};
-ld T[n] = { // Temperature measurements
- 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
+const int deg = 3; // Regression degree
+ld data[2 * n] = {
+// V T
+ 2.70, 24.0
+
};
-ld coeff[m][deg + 1];
+ld coeff[m][deg + 1], V[n], T[n];
void setup() {
@@ -31,23 +30,28 @@ void setup() {
pinMode(LED_G, OUTPUT);
pinMode(LED_B, OUTPUT);
+ for (int i = 0; i < n; i++) {
+ V[i] = data[2 * i];
+ T[i] = data[2 * i + 1];
+ }
+
sort(V, n);
sort(T, n);
ld x[n], y[n];
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("(");
+ /*for (int i = 0; i < n; i++) {
+ Serial.print("{");
Serial.print((double)x[i], 12);
Serial.print(", ");
Serial.print((double)y[i], 12);
- Serial.print(")");
+ 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 +60,7 @@ void setup() {
Serial.print((double)coeff[i][j], 12);
Serial.println();
}
- }
+ }*/
}
}