0% found this document useful (0 votes)
12 views

New Text Document

This document defines variables and functions to read temperature values from 8 thermistors connected to analog pins, calculate the temperature in Celsius for each thermistor, print the temperatures to the serial monitor, and analyze the temperature data over time to determine stability. It initializes pin assignments for each thermistor, defines variables for storing temperature readings and calculated values, and contains a loop function that repeatedly reads each thermistor, calculates the temperature, stores temperature averages and differentials over time, and prints output to characterize the temperature stability.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

New Text Document

This document defines variables and functions to read temperature values from 8 thermistors connected to analog pins, calculate the temperature in Celsius for each thermistor, print the temperatures to the serial monitor, and analyze the temperature data over time to determine stability. It initializes pin assignments for each thermistor, defines variables for storing temperature readings and calculated values, and contains a loop function that repeatedly reads each thermistor, calculates the temperature, stores temperature averages and differentials over time, and prints output to characterize the temperature stability.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

int Thermistor1Pin = 0;

int Thermistor2Pin = 1;
int Thermistor3Pin = 2;
int Thermistor4Pin = 3;
int Thermistor5Pin = 4;
int Thermistor6Pin = 5;
int Thermistor7Pin = 6;
int Thermistor8Pin = 7;
int Vo;
int t;
float TempsH[30] = {0};
float TempsC[30] = {0};
float DeltaTprom[30] = {0};
float deltaTprom = 0;
float R1 = 10000;
float logR2, R2, T, Tc1, Tc2, Tc3, Tc4, Tc5, Tc6, Tc7, Tc8, AvHot, AvCold, DeltaT,
StableConfirmTime, mStableH, mStableC;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;

void setup() {
Serial.begin(9600);
t=0;

void loop() {

Vo = analogRead(Thermistor1Pin);
R2 = R1 * (1023.0 / (float)Vo - 1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2 * logR2 + c3 * logR2 * logR2 * logR2));
Tc1 = T - 273.15+1;

Vo = analogRead(Thermistor2Pin);
R2 = R1 * (1023.0 / (float)Vo - 1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2 * logR2 + c3 * logR2 * logR2 * logR2));
Tc2 = T - 273.15-0.5;

Vo = analogRead(Thermistor3Pin);
R2 = R1 * (1023.0 / (float)Vo - 1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2 * logR2 + c3 * logR2 * logR2 * logR2));
Tc3 = T - 273.15-0.5;

Vo = analogRead(Thermistor4Pin);
R2 = R1 * (1023.0 / (float)Vo - 1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2 * logR2 + c3 * logR2 * logR2 * logR2));
Tc4 = T - 273.15;

Vo = analogRead(Thermistor5Pin);
R2 = R1 * (1023.0 / (float)Vo - 1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2 * logR2 + c3 * logR2 * logR2 * logR2));
Tc5 = T - 273.15+1.5;

Vo = analogRead(Thermistor6Pin);
R2 = R1 * (1023.0 / (float)Vo - 1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2 * logR2 + c3 * logR2 * logR2 * logR2));
Tc6 = T - 273.15+3;

Vo = analogRead(Thermistor7Pin);
R2 = R1 * (1023.0 / (float)Vo - 1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2 * logR2 + c3 * logR2 * logR2 * logR2));
Tc7 = T - 273.15+6.5;

Vo = analogRead(Thermistor8Pin);
R2 = R1 * (1023.0 / (float)Vo - 1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2 * logR2 + c3 * logR2 * logR2 * logR2));
Tc8 = T - 273.15-0.5;

t=t+1;

Serial.print("Temperature in sector 1: ");


Serial.print(Tc1);
Serial.print(" C");

Serial.print(" | 2: ");
Serial.print(Tc2);
Serial.print(" C");

Serial.print(" | 3: ");
Serial.print(Tc3);
Serial.print(" C");

Serial.print(" | 4: ");
Serial.print(Tc4);
Serial.print(" C");

Serial.print(" | 5: ");
Serial.print(Tc5);
Serial.print(" C");

Serial.print(" | 6: ");
Serial.print(Tc6);
Serial.print(" C");
Serial.print(" | 7: ");
Serial.print(Tc7);
Serial.print(" C");

Serial.print(" | 8: ");
Serial.print(Tc8);
Serial.println(" C");

AvHot = (Tc5+Tc6+Tc7+Tc8)/4;
AvCold = (Tc1+Tc2+Tc3+Tc4)/4;
DeltaT = AvHot-AvCold;

Serial.print("Promedio lado caliente: ");


Serial.print(AvHot);
Serial.print(" C");
Serial.print(" | Promedio lado frío: ");
Serial.print(AvCold);
Serial.print(" C");
Serial.print(" | Delta T: ");
Serial.print(DeltaT);
Serial.println(" C");

TempsH[0]=AvHot;
TempsC[0]=AvCold;
DeltaTprom[0]=DeltaT;

for (int i = 29; i > 0; i--) {


TempsH[i] = TempsH[i-1];
}

for (int j = 29; j > 0; j--) {


TempsC[j] = TempsC[j-1];
}

for (int k = 29; k > 0; k--) {


DeltaTprom[k] = DeltaTprom[k-1];
}

for (int l = 29; l > 0; l--) {


deltaTprom = deltaTprom + DeltaTprom[l];
}

deltaTprom = deltaTprom/30;

if (t<30)
{
Serial.println("Tiempo de confirmación de estado estable no cumplido");
}
else
{
mStableH = (TempsH[0]-TempsH[29])/30;
Serial.print("Tasa de cambio lado caliente: ");
Serial.print(abs(mStableH), 4);
Serial.println(" °C/min");
mStableC = (TempsC[0]-TempsC[29])/30;
Serial.print("Tasa de cambio lado frio: ");
Serial.print(abs(mStableC), 4);
Serial.println(" °C/min");

Serial.print("Promedio delta T: ");


Serial.print(abs(deltaTprom), 4);
Serial.println(" °C");

/*
Serial.print("Valores TempsC: ");
Serial.print(TempsC[0]);
Serial.print(" ; ");
Serial.print(TempsC[1]);
Serial.print(" ; ");
Serial.print(TempsC[2]);
Serial.print(" ; ");
Serial.print(TempsC[3]);
Serial.print(" ; ");
Serial.print(TempsC[4]);
Serial.print(" ; ");
Serial.print(TempsC[5]);
Serial.print(" ; ");
Serial.print(TempsC[24]);
Serial.print(" ; ");
Serial.print(TempsC[25]);
Serial.print(" ; ");
Serial.print(TempsC[26]);
Serial.print(" ; ");
Serial.print(TempsC[27]);
Serial.print(" ; ");
Serial.print(TempsC[28]);
Serial.print(" ; ");
Serial.println(TempsC[29]);

Serial.print("Valores TempsH: ");


Serial.print(TempsH[0]);
Serial.print(" ; ");
Serial.print(TempsH[1]);
Serial.print(" ; ");
Serial.print(TempsH[2]);
Serial.print(" ; ");
Serial.print(TempsH[3]);
Serial.print(" ; ");
Serial.print(TempsH[4]);
Serial.print(" ; ");
Serial.print(TempsH[5]);
Serial.print(" ; ");
Serial.print(TempsH[24]);
Serial.print(" ; ");
Serial.print(TempsH[25]);
Serial.print(" ; ");
Serial.print(TempsH[26]);
Serial.print(" ; ");
Serial.print(TempsH[27]);
Serial.print(" ; ");
Serial.print(TempsH[28]);
Serial.print(" ; ");
Serial.print(TempsH[29]);

*/

Serial.print('\n');
Serial.print('\n');

delay(2000);

You might also like