From 276334055f6ad1a430ab2a3797a0d326778b68b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20=C3=96ster?= Date: Mon, 17 Mar 2025 18:02:07 +0200 Subject: [PATCH 1/2] Separate Deye offgrid BYD CAN fixes --- Software/USER_SETTINGS.h | 5 +++-- Software/src/inverter/BYD-CAN.cpp | 3 +++ Software/src/inverter/INVERTERS.h | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Software/USER_SETTINGS.h b/Software/USER_SETTINGS.h index a7167890..f6edf737 100644 --- a/Software/USER_SETTINGS.h +++ b/Software/USER_SETTINGS.h @@ -45,9 +45,10 @@ //#define TEST_FAKE_BATTERY //#define DOUBLE_BATTERY //Enable this line if you use two identical batteries at the same time (requires CAN_ADDON setup) -/* Select inverter communication protocol. See Wiki for which to use with your inverter: https://github.com/dalathegreat/BYD-Battery-Emulator-For-Gen24/wiki */ +/* Select inverter communication protocol. See Wiki for which to use with your inverter: https://github.com/dalathegreat/Battery-Emulator/wiki */ //#define AFORE_CAN //Enable this line to emulate an "Afore battery" over CAN bus -//#define BYD_CAN //Enable this line to emulate a "BYD Battery-Box Premium HVS" over CAN Bus +//#define BYD_CAN //Enable this line to emulate a "BYD Battery-Box Premium HVS" over CAN Bus +//#define BYD_CAN_DEYE //Enable this line to emulate a "BYD Battery-Box Premium HVS" over CAN Bus, with Deye specific fixes //#define BYD_KOSTAL_RS485 //Enable this line to emulate a "BYD 11kWh HVM battery" over Kostal RS485 //#define BYD_MODBUS //Enable this line to emulate a "BYD 11kWh HVM battery" over Modbus RTU //#define FERROAMP_CAN //Enable this line to emulate a "Pylon 4x96V Force H2" over CAN Bus diff --git a/Software/src/inverter/BYD-CAN.cpp b/Software/src/inverter/BYD-CAN.cpp index ee051c68..66cc7678 100644 --- a/Software/src/inverter/BYD-CAN.cpp +++ b/Software/src/inverter/BYD-CAN.cpp @@ -126,6 +126,8 @@ void update_values_can_inverter() { //This function maps all the values fetched //SOC (100.00%) BYD_150.data.u8[0] = (datalayer.battery.status.reported_soc >> 8); BYD_150.data.u8[1] = (datalayer.battery.status.reported_soc & 0x00FF); +#ifdef BYD_CAN_DEYE + // Fix for avoiding offgrid Deye inverters to underdischarge batteries if (datalayer.battery.status.max_charge_current_dA == 0) { //Force to 100.00% incase battery no longer wants to charge BYD_150.data.u8[0] = (10000 >> 8); @@ -136,6 +138,7 @@ void update_values_can_inverter() { //This function maps all the values fetched BYD_150.data.u8[0] = 0; BYD_150.data.u8[1] = 0; } +#endif //BYD_CAN_DEYE //StateOfHealth (100.00%) BYD_150.data.u8[2] = (datalayer.battery.status.soh_pptt >> 8); BYD_150.data.u8[3] = (datalayer.battery.status.soh_pptt & 0x00FF); diff --git a/Software/src/inverter/INVERTERS.h b/Software/src/inverter/INVERTERS.h index 8b222874..bf3f9868 100644 --- a/Software/src/inverter/INVERTERS.h +++ b/Software/src/inverter/INVERTERS.h @@ -11,6 +11,11 @@ #include "BYD-CAN.h" #endif +#ifdef BYD_CAN_DEYE +#define BYD_CAN +#include "BYD-CAN.h" +#endif + #ifdef BYD_MODBUS #include "BYD-MODBUS.h" #endif From ff842af0c32540fac05ae8583dbf7e4e28829753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20=C3=96ster?= Date: Mon, 17 Mar 2025 20:07:10 +0200 Subject: [PATCH 2/2] Simplify ifdef for BYD_CAN_DEYE --- Software/src/inverter/INVERTERS.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Software/src/inverter/INVERTERS.h b/Software/src/inverter/INVERTERS.h index bf3f9868..903a9b8e 100644 --- a/Software/src/inverter/INVERTERS.h +++ b/Software/src/inverter/INVERTERS.h @@ -7,12 +7,11 @@ #include "AFORE-CAN.h" #endif -#ifdef BYD_CAN -#include "BYD-CAN.h" -#endif - #ifdef BYD_CAN_DEYE #define BYD_CAN +#endif + +#ifdef BYD_CAN #include "BYD-CAN.h" #endif