From 688b912539cdea9c385e62ec1ff18bb919924e15 Mon Sep 17 00:00:00 2001 From: anschrammh Date: Wed, 15 Jan 2020 19:05:15 +0100 Subject: [PATCH] =?UTF-8?q?Correction=20d'une=20erreur=20de=20calcul=20sur?= =?UTF-8?q?=20la=20temp=C3=A9rature=20et=20ajout=20de=20directives=20pr?= =?UTF-8?q?=C3=A9processeur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/MeasureUnit/MeasureUnit.cpp | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/lib/MeasureUnit/MeasureUnit.cpp b/lib/MeasureUnit/MeasureUnit.cpp index 38d8e9e..f50701a 100644 --- a/lib/MeasureUnit/MeasureUnit.cpp +++ b/lib/MeasureUnit/MeasureUnit.cpp @@ -15,6 +15,7 @@ _error(OK), _state(IDLING), _channel(0), _courant(0.0), +_tension(0.0), _triggerLevelOff(false) { //Allocation dynamique des différent tableaux @@ -33,9 +34,6 @@ _triggerLevelOff(false) _rOffsetMap = NULL; _resistanceMap = NULL; } - - //We start the comm with the adcs - _adc.begin(); } MeasureUnit::~MeasureUnit() @@ -91,6 +89,10 @@ double *MeasureUnit::getTemperatures() Serial.print("Debug voltage delta : ");Serial.println(_resistanceMap[i]); #endif } + + //Ne pas oublier de déduire la chute de tension de la resistance de precision pour la première thermistance + _resistanceMap[0] -= rPrecTension; + Serial.printf("Debug voltage delta : 0 -> ");Serial.println(_resistanceMap[0]); for(int i(0); i < _thermistorCount; i++) { @@ -165,14 +167,16 @@ void MeasureUnit::startTemperatureMeasurement() break; case MEASURING: _adc.startSample(_channel); - + if(_channel == 0) //Calcule du courant { if(_adc.isSampleReady()) { - double tension = _adc.getSampleVoltage(); - _courant = tension / (double) _precResistor; - //Serial.println(tension); + _tension = _adc.getSampleVoltage(); + _courant = _tension / (double) _precResistor; + #ifdef DEBUG + Serial.print("Tension prec : ");Serial.println(_tension); + #endif _channel++; } } @@ -181,8 +185,10 @@ void MeasureUnit::startTemperatureMeasurement() if(_adc.isSampleReady()) { _resistanceMap[_channel-1] = _adc.getSampleVoltage(); - //Serial.println(_resistanceMap[_channel-1]); - _channel++; + #ifdef DEBUG + Serial.print("Tension thermistances : ");Serial.println(_resistanceMap[_channel-1]); + #endif + _channel++; } } @@ -200,9 +206,15 @@ void MeasureUnit::startTemperatureMeasurement() //Calcule de delta : _resistanceMap[i] -= _resistanceMap[i-1]; #ifdef DEBUG - Serial.print("Debug voltage delta : ");Serial.println(_resistanceMap[i]); + Serial.printf("Debug voltage delta : %u -> ",i);Serial.println(_resistanceMap[i]); #endif } + + //Ne pas oublier de déduire la chute de tension de la resistance de precision pour la première thermistance + _resistanceMap[0] -= _tension; + #ifdef DEBUG + Serial.printf("Debug voltage delta : 0 -> ");Serial.println(_resistanceMap[0]); + #endif for(int i(0); i < _thermistorCount; i++) {