Compare commits
2 Commits
0927059d4e
...
688b912539
Author | SHA1 | Date | |
---|---|---|---|
|
688b912539 | ||
|
e186bf16d1 |
@ -15,6 +15,7 @@ _error(OK),
|
|||||||
_state(IDLING),
|
_state(IDLING),
|
||||||
_channel(0),
|
_channel(0),
|
||||||
_courant(0.0),
|
_courant(0.0),
|
||||||
|
_tension(0.0),
|
||||||
_triggerLevelOff(false)
|
_triggerLevelOff(false)
|
||||||
{
|
{
|
||||||
//Allocation dynamique des différent tableaux
|
//Allocation dynamique des différent tableaux
|
||||||
@ -33,9 +34,6 @@ _triggerLevelOff(false)
|
|||||||
_rOffsetMap = NULL;
|
_rOffsetMap = NULL;
|
||||||
_resistanceMap = NULL;
|
_resistanceMap = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//We start the comm with the adcs
|
|
||||||
_adc.begin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MeasureUnit::~MeasureUnit()
|
MeasureUnit::~MeasureUnit()
|
||||||
@ -91,6 +89,10 @@ double *MeasureUnit::getTemperatures()
|
|||||||
Serial.print("Debug voltage delta : ");Serial.println(_resistanceMap[i]);
|
Serial.print("Debug voltage delta : ");Serial.println(_resistanceMap[i]);
|
||||||
#endif
|
#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++)
|
for(int i(0); i < _thermistorCount; i++)
|
||||||
{
|
{
|
||||||
@ -165,14 +167,16 @@ void MeasureUnit::startTemperatureMeasurement()
|
|||||||
break;
|
break;
|
||||||
case MEASURING:
|
case MEASURING:
|
||||||
_adc.startSample(_channel);
|
_adc.startSample(_channel);
|
||||||
|
|
||||||
if(_channel == 0) //Calcule du courant
|
if(_channel == 0) //Calcule du courant
|
||||||
{
|
{
|
||||||
if(_adc.isSampleReady())
|
if(_adc.isSampleReady())
|
||||||
{
|
{
|
||||||
double tension = _adc.getSampleVoltage();
|
_tension = _adc.getSampleVoltage();
|
||||||
_courant = tension / (double) _precResistor;
|
_courant = _tension / (double) _precResistor;
|
||||||
//Serial.println(tension);
|
#ifdef DEBUG
|
||||||
|
Serial.print("Tension prec : ");Serial.println(_tension);
|
||||||
|
#endif
|
||||||
_channel++;
|
_channel++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,8 +185,10 @@ void MeasureUnit::startTemperatureMeasurement()
|
|||||||
if(_adc.isSampleReady())
|
if(_adc.isSampleReady())
|
||||||
{
|
{
|
||||||
_resistanceMap[_channel-1] = _adc.getSampleVoltage();
|
_resistanceMap[_channel-1] = _adc.getSampleVoltage();
|
||||||
//Serial.println(_resistanceMap[_channel-1]);
|
#ifdef DEBUG
|
||||||
_channel++;
|
Serial.print("Tension thermistances : ");Serial.println(_resistanceMap[_channel-1]);
|
||||||
|
#endif
|
||||||
|
_channel++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,9 +206,15 @@ void MeasureUnit::startTemperatureMeasurement()
|
|||||||
//Calcule de delta :
|
//Calcule de delta :
|
||||||
_resistanceMap[i] -= _resistanceMap[i-1];
|
_resistanceMap[i] -= _resistanceMap[i-1];
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.print("Debug voltage delta : ");Serial.println(_resistanceMap[i]);
|
Serial.printf("Debug voltage delta : %u -> ",i);Serial.println(_resistanceMap[i]);
|
||||||
#endif
|
#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++)
|
for(int i(0); i < _thermistorCount; i++)
|
||||||
{
|
{
|
||||||
|
@ -11,6 +11,7 @@ class MeasureUnit
|
|||||||
enum ERROR {OK = 0, MALLOC_ERR = 1};
|
enum ERROR {OK = 0, MALLOC_ERR = 1};
|
||||||
MeasureUnit(uint8_t *analogInput, uint16_t thermistorCount, uint64_t precResistor, ThermistorSetting thermistorSetting, Adc &adc);
|
MeasureUnit(uint8_t *analogInput, uint16_t thermistorCount, uint64_t precResistor, ThermistorSetting thermistorSetting, Adc &adc);
|
||||||
~MeasureUnit();
|
~MeasureUnit();
|
||||||
|
void init(){_adc.begin();}
|
||||||
void setGlobalTempOffset(double offset);
|
void setGlobalTempOffset(double offset);
|
||||||
void levelTemperaturesOff();
|
void levelTemperaturesOff();
|
||||||
double getGlobalTempOffset();
|
double getGlobalTempOffset();
|
||||||
@ -46,7 +47,7 @@ class MeasureUnit
|
|||||||
//Async part
|
//Async part
|
||||||
STATE _state;
|
STATE _state;
|
||||||
uint8_t _channel;
|
uint8_t _channel;
|
||||||
double _courant;
|
double _courant, _tension;
|
||||||
boolean _triggerLevelOff; //Attribut permettant de savoir si un étalonnage a été demandé
|
boolean _triggerLevelOff; //Attribut permettant de savoir si un étalonnage a été demandé
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ PayloadFormatter::PayloadFormatter(uint8_t numOfRow, uint8_t numOfColumn) : _tot
|
|||||||
_length = numOfRow * numOfColumn * 2 + 7 + 1;
|
_length = numOfRow * numOfColumn * 2 + 7 + 1;
|
||||||
_payload = (uint8_t *) calloc(_length, sizeof(uint8_t));
|
_payload = (uint8_t *) calloc(_length, sizeof(uint8_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
PayloadFormatter::~PayloadFormatter()
|
PayloadFormatter::~PayloadFormatter()
|
||||||
{
|
{
|
||||||
free(_payload);
|
free(_payload);
|
||||||
@ -24,7 +25,7 @@ boolean PayloadFormatter::endSession()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t PayloadFormatter::buildPayload(uint8_t **buffer, DateTime *dateTime, double *tempArray)
|
int16_t PayloadFormatter::buildPayload(uint8_t **buffer, DateTime *dateTime, double *tempArray, uint8_t numOfRow, uint8_t numOfColumn)
|
||||||
{
|
{
|
||||||
*buffer = _payload;
|
*buffer = _payload;
|
||||||
if(_currentPayload == _totalPayloads || !_totalPayloads)
|
if(_currentPayload == _totalPayloads || !_totalPayloads)
|
||||||
|
@ -9,7 +9,7 @@ class PayloadFormatter
|
|||||||
PayloadFormatter(uint8_t numOfRow, uint8_t numOfColumn);
|
PayloadFormatter(uint8_t numOfRow, uint8_t numOfColumn);
|
||||||
~PayloadFormatter();
|
~PayloadFormatter();
|
||||||
|
|
||||||
int16_t buildPayload(uint8_t **buffer, DateTime *dateTime, double *tempArray);
|
int16_t buildPayload(uint8_t **buffer, DateTime *dateTime, double *tempArray, uint8_t numOfRow = -1, uint8_t numOfColumn = -1);
|
||||||
void startSession(uint8_t totalPackets);
|
void startSession(uint8_t totalPackets);
|
||||||
boolean endSession();
|
boolean endSession();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user