Skip to content

Commit

Permalink
Merge pull request #4 from bluesensor/Re-calibration-sensor
Browse files Browse the repository at this point in the history
Re calibration sensor
  • Loading branch information
jhon-p16 authored Nov 2, 2022
2 parents 1c97465 + 868675c commit ad83507
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/BslibEnergyMeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ int currentADC;
int currentRefADC;
float currentDAC;
float current;
float offsetWithoutLoad;

int voltageADC;
float voltageDAC;
Expand Down Expand Up @@ -69,6 +70,15 @@ void BslibEnergyMeter::SetCurrentReference(int _currentReference) {
currentReference = _currentReference;
}

/**
* @brief Se usa para estabblecer la corriente de offset tiempo antes de la activacion de la carga
*
* @param _currentReference
*/
void BslibEnergyMeter::SetOffsetNoLoad(float _offsetWithoutLoad) {
offsetWithoutLoad = _offsetWithoutLoad;
}

/**
* @brief Configura el valor de referencia analógica para el MCU
*
Expand Down Expand Up @@ -155,11 +165,22 @@ int BslibEnergyMeter::GetCurrentADC() {
float BslibEnergyMeter::GetCurrentDAC() {
return currentDAC;
}

float BslibEnergyMeter::GetCurrent() {
CalCurrent();
return current;
}

float BslibEnergyMeter::GetCurrentWithoutOffset() {
CalCurrent();
float currentWithoutOffset;
if ((current - offsetWithoutLoad) <= 0) {
currentWithoutOffset = 0;
} else {
currentWithoutOffset = current - offsetWithoutLoad;
}
return currentWithoutOffset;
}
// -----------------------------------------------------------

void BslibEnergyMeter::CalVoltage() {
Expand Down
3 changes: 3 additions & 0 deletions src/BslibEnergyMeter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class BslibEnergyMeter {

void SetCurrentReference(int _currentReference);
void SetAnalogReference(float _analogReference);
void SetOffsetNoLoad(float _offsetWithoutLoad);
void SetFilterSamples(unsigned int _numberOfSamples);

int FilterValueADC(unsigned int pinADC);
Expand All @@ -41,6 +42,7 @@ class BslibEnergyMeter {
int GetCurrentADC();
float GetCurrentDAC();
float GetCurrent();
float GetCurrentWithoutOffset();

void CalVoltage();
int GetVoltageADC();
Expand All @@ -63,6 +65,7 @@ class BslibEnergyMeter {
float factorCurrent;
float factorVoltage;
float offsetVoltage;
float offsetWithoutLoad;
};

#endif

0 comments on commit ad83507

Please sign in to comment.