Skip to content

Commit

Permalink
Bumped version to 3.2.0 - Keep accumulated analytics data at reset.
Browse files Browse the repository at this point in the history
  • Loading branch information
Armin committed Jun 27, 2024
1 parent 63cc0e0 commit 27cb0b7
Show file tree
Hide file tree
Showing 11 changed files with 497 additions and 268 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/TestCompile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- arduino-boards-fqbn: MightyCore:avr:644
platform-url: https://mcudude.github.io/MightyCore/package_MCUdude_MightyCore_index.json
build-properties:
All: -DANDRES_644_BOARD
All: -DUSE_LAYOUT_FOR_644_BOARD

steps:
- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions JK-BMSToPylontechCAN/JK-BMS.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void computeUpTimeString();
void printJKStaticInfo();
void printJKDynamicInfo();
void detectAndPrintAlarmInfo();
#if !defined(DISABLE_MONITORING)
#if defined(ENABLE_MONITORING)
void printCSVLine(char aLeadingChar = '\0');
#endif

Expand Down Expand Up @@ -190,7 +190,7 @@ struct JKComputedDataStruct {
int16_t Battery10MilliAmpere; // Charging is positive discharging is negative
float BatteryLoadCurrentFloat; // Ampere
int16_t BatteryLoadPower; // Watt Computed value, Charging is positive discharging is negative
int32_t BatteryCapacityAccumulator10MilliAmpere; // 500 Ah = 180,000,000 10MilliAmpereSeconds
int32_t BatteryCapacityAsAccumulator10MilliAmpere; // 500 Ah = 180,000,000 10MilliAmpereSeconds. Pre-computed capacity to compare with accumulator value.
bool BMSIsStarting; // True if SOC and Cycles are both 0, for around 16 seconds during JK-BMS startup.
};
extern struct JKComputedDataStruct JKComputedData; // All derived converted and computed data useful for display
Expand Down
25 changes: 14 additions & 11 deletions JK-BMSToPylontechCAN/JK-BMS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ void printJKCellStatisticsInfo() {

void initializeComputedData() {
// Initialize capacity accumulator with sensible value
JKComputedData.BatteryCapacityAccumulator10MilliAmpere = (AMPERE_HOUR_AS_ACCUMULATOR_10_MILLIAMPERE / 100)
JKComputedData.BatteryCapacityAsAccumulator10MilliAmpere = (AMPERE_HOUR_AS_ACCUMULATOR_10_MILLIAMPERE / 100)
* sJKFAllReplyPointer->SOCPercent * JKComputedData.TotalCapacityAmpereHour;
}

Expand Down Expand Up @@ -592,12 +592,12 @@ void fillJKComputedData() {

JKComputedData.Battery10MilliAmpere = getCurrent(sJKFAllReplyPointer->Battery10MilliAmpere);
JKComputedData.BatteryLoadCurrentFloat = JKComputedData.Battery10MilliAmpere / 100.0;
JKComputedData.BatteryCapacityAccumulator10MilliAmpere += JKComputedData.Battery10MilliAmpere;
JKComputedData.BatteryCapacityAsAccumulator10MilliAmpere += JKComputedData.Battery10MilliAmpere;
if (lastJKReply.SOCPercent == 0 && sJKFAllReplyPointer->SOCPercent == 1) {
JK_INFO_PRINTLN(F("Reset capacity to 1%"));
// Reset capacity at transition from 0 to 1
JKComputedData.BatteryCapacityAccumulator10MilliAmpere = getOnePercentCapacityAsAccumulator10Milliampere();
JKLastPrintedData.BatteryCapacityAccumulator10MilliAmpere = JKComputedData.BatteryCapacityAccumulator10MilliAmpere;
JKComputedData.BatteryCapacityAsAccumulator10MilliAmpere = getOnePercentCapacityAsAccumulator10Milliampere();
JKLastPrintedData.BatteryCapacityAccumulator10MilliAmpere = JKComputedData.BatteryCapacityAsAccumulator10MilliAmpere;
}

// Serial.print("Battery10MilliAmpere=0x");
Expand Down Expand Up @@ -871,6 +871,9 @@ void printActiveState(bool aIsActive) {
Serial.print(F(" active"));
}

/*
* Called exclusively once by processJK_BMSStatusFrame()
*/
void printJKStaticInfo() {

Serial.println(F("*** BMS INFO ***"));
Expand Down Expand Up @@ -918,7 +921,7 @@ extern const char sCSVCaption[] PROGMEM;
void printJKDynamicInfo() {
JKReplyStruct *tJKFAllReplyPointer = sJKFAllReplyPointer;

#if !defined(DISABLE_MONITORING)
#if defined(ENABLE_MONITORING)
# if defined(MONOTORING_PERIOD_FAST)
// Print every dataset, every 2 seconds, and caption every minute
printCSVLine();
Expand All @@ -942,8 +945,8 @@ void printJKDynamicInfo() {
// Print +CSV line every percent of nominal battery capacity (TotalCapacityAmpereHour) for capacity to voltage graph
if (abs(
JKLastPrintedData.BatteryCapacityAccumulator10MilliAmpere
- JKComputedData.BatteryCapacityAccumulator10MilliAmpere) > getOnePercentCapacityAsAccumulator10Milliampere()) {
JKLastPrintedData.BatteryCapacityAccumulator10MilliAmpere = JKComputedData.BatteryCapacityAccumulator10MilliAmpere;
- JKComputedData.BatteryCapacityAsAccumulator10MilliAmpere) > getOnePercentCapacityAsAccumulator10Milliampere()) {
JKLastPrintedData.BatteryCapacityAccumulator10MilliAmpere = JKComputedData.BatteryCapacityAsAccumulator10MilliAmpere;
printCSVLine('+');
}

Expand Down Expand Up @@ -1003,7 +1006,7 @@ void printJKDynamicInfo() {
Serial.println(F("There is less than 10% capacity below 3.0V and 20% capacity below 3.2V."));
}
#endif
#if !defined(DISABLE_MONITORING) && !defined(MONOTORING_PERIOD_FAST)
#if defined(ENABLE_MONITORING) && !defined(MONOTORING_PERIOD_FAST)
/*
* Print CSV caption every 10 minute
*/
Expand Down Expand Up @@ -1097,7 +1100,7 @@ void printJKDynamicInfo() {
}
}

#if !defined(DISABLE_MONITORING)
#if defined(ENABLE_MONITORING)
const char sCSVCaption[] PROGMEM
= "Uptime[min];Cell_1;Cell_2;Cell_3;Cell_4;Cell_5;Cell_6;Cell_7;Cell_8;Cell_9;Cell_10;Cell_11;Cell_12;Cell_13;Cell_14;Cell_15;Cell_16;Voltage[mV];Current[A];Capacity[100mAh];SOC[%]";

Expand Down Expand Up @@ -1140,7 +1143,7 @@ void setCSVString() {
dtostrf(JKComputedData.BatteryLoadCurrentFloat, 4, 2, &tCurrentAsFloatString[0]);
sprintf_P(&sStringBuffer[tBufferIndex], PSTR("%u;%s;%ld;%d"), JKComputedData.BatteryVoltage10Millivolt * 10,
tCurrentAsFloatString,
JKComputedData.BatteryCapacityAccumulator10MilliAmpere / (AMPERE_HOUR_AS_ACCUMULATOR_10_MILLIAMPERE / 10), /* 100mAh units*/
JKComputedData.BatteryCapacityAsAccumulator10MilliAmpere / (AMPERE_HOUR_AS_ACCUMULATOR_10_MILLIAMPERE / 10), /* 100mAh units*/
sJKFAllReplyPointer->SOCPercent);
}
}
Expand All @@ -1153,7 +1156,7 @@ void printCSVLine(char aLeadingChar) {
setCSVString();
Serial.println(sStringBuffer);
}
#endif // !defined(DISABLE_MONITORING)
#endif // defined(ENABLE_MONITORING)

#include "LocalDebugLevelEnd.h"
#endif // _JK_BMS_HPP
Loading

0 comments on commit 27cb0b7

Please sign in to comment.