Skip to content

Commit

Permalink
Fix: Calculate the AC current for 3 phase inverters correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
tbnobody committed Jan 30, 2024
1 parent abb3724 commit e81a280
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/inverters/HMT_6CH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static const byteAssign_t byteAssignment[] = {
{ TYPE_AC, CH0, FLD_F, UNIT_HZ, 80, 2, 100, false, 2 },
{ TYPE_AC, CH0, FLD_PAC, UNIT_W, 82, 2, 10, false, 1 },
{ TYPE_AC, CH0, FLD_Q, UNIT_VAR, 84, 2, 10, true, 1 },
{ TYPE_AC, CH0, FLD_IAC, UNIT_A, 86, 2, 100, false, 2 }, // dummy
{ TYPE_AC, CH0, FLD_IAC, UNIT_A, CALC_TOTAL_IAC, 0, CMD_CALC, false, 2 },
{ TYPE_AC, CH0, FLD_IAC_1, UNIT_A, 86, 2, 100, false, 2 },
{ TYPE_AC, CH0, FLD_IAC_2, UNIT_A, 88, 2, 100, false, 2 },
{ TYPE_AC, CH0, FLD_IAC_3, UNIT_A, 90, 2, 100, false, 2 },
Expand Down
13 changes: 12 additions & 1 deletion lib/Hoymiles/src/parser/StatisticsParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ static float calcChUdc(StatisticsParser* iv, uint8_t arg0);
static float calcTotalPowerDc(StatisticsParser* iv, uint8_t arg0);
static float calcTotalEffiency(StatisticsParser* iv, uint8_t arg0);
static float calcChIrradiation(StatisticsParser* iv, uint8_t arg0);
static float calcTotalCurrentAc(StatisticsParser* iv, uint8_t arg0);

using func_t = float(StatisticsParser*, uint8_t);

Expand All @@ -25,7 +26,8 @@ const calcFunc_t calcFunctions[] = {
{ CALC_CH_UDC, &calcChUdc },
{ CALC_TOTAL_PDC, &calcTotalPowerDc },
{ CALC_TOTAL_EFF, &calcTotalEffiency },
{ CALC_CH_IRR, &calcChIrradiation }
{ CALC_CH_IRR, &calcChIrradiation },
{ CALC_TOTAL_IAC, &calcTotalCurrentAc }
};

const FieldId_t runtimeFields[] = {
Expand Down Expand Up @@ -446,3 +448,12 @@ static float calcChIrradiation(StatisticsParser* iv, uint8_t arg0)
}
return 0.0;
}

static float calcTotalCurrentAc(StatisticsParser* iv, uint8_t arg0)
{
float acCurrent = 0;
acCurrent += iv->getChannelFieldValue(TYPE_AC, CH0, FLD_IAC_1);
acCurrent += iv->getChannelFieldValue(TYPE_AC, CH0, FLD_IAC_2);
acCurrent += iv->getChannelFieldValue(TYPE_AC, CH0, FLD_IAC_3);
return acCurrent;
}
3 changes: 2 additions & 1 deletion lib/Hoymiles/src/parser/StatisticsParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ enum {
CALC_CH_UDC,
CALC_TOTAL_PDC,
CALC_TOTAL_EFF,
CALC_CH_IRR
CALC_CH_IRR,
CALC_TOTAL_IAC
};
enum { CMD_CALC = 0xffff };

Expand Down

0 comments on commit e81a280

Please sign in to comment.