Skip to content

Commit

Permalink
Version 2.1.1 - Fixed SOH == 0 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ArminJo committed Oct 13, 2023
1 parent a5ee36d commit db32e27
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 168 deletions.
11 changes: 9 additions & 2 deletions JK-BMSToPylontechCAN/EasyButtonAtInt01.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ class EasyButton {
void handleINT01Interrupts(); // internal use only

bool LastBounceWasChangeToInactive; // Internal state, reflects actual reading with spikes and bouncing. Negative logic: true / active means button pin is LOW
volatile bool ButtonStateIsActive; // State at last change. Negative logic: true / active means button pin is LOW. If last press duration < BUTTON_DEBOUNCING_MILLIS it holds wrong value (true instead of false) :-(
volatile bool ButtonToggleState; // Toggle is on press, not on release - initial value is false

/*
Expand Down Expand Up @@ -351,6 +350,13 @@ class EasyButton {
#if defined(USE_BUTTON_1)
static EasyButton *sPointerToButton1ForISR;
#endif

private:
/*
* If last press duration < BUTTON_DEBOUNCING_MILLIS it holds wrong value (true instead of false), therefore it is private.
* To get current state, use readButtonState().
*/
volatile bool ButtonStateIsActive; // State at last change. Negative logic: true / active means button pin is LOW.
};
// end of class definition

Expand All @@ -371,8 +377,9 @@ void __attribute__ ((weak)) handleINT1Interrupt();
#endif // defined(__AVR__)

/*
* Version 3.3.2 - 9/2022
* Version 3.3.2 - 10/2023
* - Added NO_INITIALIZE_IN_CONSTRUCTOR macro to enable late initializing.
* - ButtonStateIsActive is now private, since it is not reliable after bouncing. Use readButtonState() instead.
*
* Version 3.3.1 - 2/2022
* - Avoid mistakenly double press detection after boot.
Expand Down
2 changes: 1 addition & 1 deletion JK-BMSToPylontechCAN/JK-BMS.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,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
bool BMSIsStarting; // True if SOC and Capacity are both 0
bool BMSIsStarting; // True if SOC and Capacity are both 0, for around 16 seconds during JK-BMS startup.
};

/*
Expand Down
7 changes: 5 additions & 2 deletions JK-BMSToPylontechCAN/JK-BMS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,8 @@ void fillJKConvertedCellInfo() {
Serial.print(tNumberOfCellInfo);
Serial.println(F(" cell voltages processed"));
#endif
if (tNumberOfNonNullCellInfo < tNumberOfCellInfo) {
// During JK-BMS startup all cell voltages are sent as zero for around 6 seconds
if (tNumberOfNonNullCellInfo < tNumberOfCellInfo && !JKComputedData.BMSIsStarting) {
Serial.print(F("Problem: "));
Serial.print(tNumberOfCellInfo);
Serial.print(F(" cells configured in BMS, but only "));
Expand Down Expand Up @@ -477,7 +478,9 @@ void fillJKComputedData() {
// 16 bit multiplication gives overflow at 640 Ah
JKComputedData.RemainingCapacityAmpereHour = ((uint32_t) JKComputedData.TotalCapacityAmpereHour
* sJKFAllReplyPointer->SOCPercent) / 100;
JKComputedData.BMSIsStarting = (sJKFAllReplyPointer->SOCPercent == 0);

// Two values which are zero during JK-BMS startup for around 16 seconds
JKComputedData.BMSIsStarting = (sJKFAllReplyPointer->SOCPercent == 0 && sJKFAllReplyPointer->Cycles == 0);

JKComputedData.BatteryFullVoltage10Millivolt = swap(sJKFAllReplyPointer->BatteryOvervoltageProtection10Millivolt);
JKComputedData.BatteryVoltage10Millivolt = swap(sJKFAllReplyPointer->Battery10Millivolt);
Expand Down
Loading

0 comments on commit db32e27

Please sign in to comment.