_temperatureMeasurements[_temperatureMeasurementsMarker] = measuredTemperatureNow; // Write the average temp + one third of the measured temperature deviation
}
else {
_temperatureMeasurements[_temperatureMeasurementsMarker] = _temperatureAverage + (temperatureDiff / 3.0); // Write the average temp + one third of the measured temperature deviation
_temperatureMeasurements[_temperatureMeasurementsMarker]=_temperatureAverage+(temperatureDiff/3.0);// Write the average temp + one third of the measured temperature deviation
_temperatureAverage=0.0;// Zero out the average, it is time to calculate the new one
for(intmarkerCounter=0;markerCounter<TEMPERATURE_AVERAGE_VALUE_I;markerCounter++){// Iterate over the temperature values in the buffer
_temperatureAverage+=_temperatureMeasurements[markerCounter];// Sum all the temperature values
}
_temperatureAverage=_temperatureAverage/TEMPERATURE_AVERAGE_VALUE_F;// Divide the sum by the number of values summed.
_measuredTemperature=_temperatureAverage;// Set the measured temperature to the calculated average value
xFilterNoise(_temperatureMeasurementsMarker);
/*
Serial.print("PT100 : [");
Serial.print(_name);
Serial.print("]\tVoutSample: [");
Serial.print(_VoutAnalogSample);
// Serial.print("]\tVout[");
// Serial.print(Vout,6);
// Serial.print("]\tRx[");
// Serial.print(Rx,6);
Serial.print("]\tTNow[");
Serial.print(measuredTemperatureNow,6);
Serial.print("]\tTCalc[");
Serial.print(_measuredTemperature,6);
Serial.println("] ");
*/
//Serial.print("PT100 : [");
#ifdef DEBUG
Serial.print(_name);
Serial.print(",");
Serial.print(_VoutAnalogSample);
Serial.print(",");
/*Serial.print(test);
Serial.print(",");
Serial.print(Rtest);
Serial.print(",");*/
/*Serial.print(Vout,6);
Serial.print(",");
Serial.print(Rx,6);
Serial.print(",");
Serial.print(measuredTemperatureNow,6);
Serial.print(",");
Serial.print(_measuredTemperature,6);
Serial.print(",");*/
if(ln)Serial.println("");
#endif
}
}
voidPT100::measure1(booleanln,booleanrline){
if(millis()-_lastTemperatureRead>=_TimeBetweenReadings){//time to measure temperature
if(millis()-_lastTemperatureRead>=_TimeBetweenReadings){//time to measure temperature
/** measure Vout analog sample */
/** measure Vout analog sample */
digitalWrite(_OutputPin_SensorPower,HIGH);// initialize sensor on
digitalWrite(_OutputPin_SensorPower,HIGH);// initialize sensor on
digitalWrite(_OutputPin_ThirdLinePower,HIGH);// initialize sensor on
delay(10);
delay(10);
_VoutAnalogSample=analogRead(_InputPin_TemperatureReading)+_sampleDeviation;// Get a reading
_VoutAnalogSample=analogRead(_InputPin_TemperatureReading)+_sampleDeviation;// Get a reading
_VoutRAnalogSample=analogRead(_InputPin_ThirdLineReading)+_sampleDeviation;// Get a reading
digitalWrite(_OutputPin_SensorPower,LOW);// initialize sensor on
digitalWrite(_OutputPin_SensorPower,LOW);// initialize sensor on
digitalWrite(_OutputPin_ThirdLinePower,LOW);// initialize sensor on
_lastTemperatureRead=millis();// Mark time of temperature reading
_lastTemperatureRead=millis();// Mark time of temperature reading