diff --git a/Software/src/battery/NISSAN-LEAF-BATTERY.cpp b/Software/src/battery/NISSAN-LEAF-BATTERY.cpp index bc505676..bb76bd56 100644 --- a/Software/src/battery/NISSAN-LEAF-BATTERY.cpp +++ b/Software/src/battery/NISSAN-LEAF-BATTERY.cpp @@ -93,12 +93,10 @@ static uint8_t crctable[256] = { #define AZE0_BATTERY 1 #define ZE1_BATTERY 2 static uint8_t LEAF_Battery_Type = ZE0_BATTERY; -#define MAX_CELL_VOLTAGE 4250 //Battery is put into emergency stop if one cell goes over this value -#define MIN_CELL_VOLTAGE 2700 //Battery is put into emergency stop if one cell goes below this value -#define MAX_CELL_DEVIATION 500 //LED turns yellow on the board if mv delta exceeds this value -#define WH_PER_GID 77 //One GID is this amount of Watt hours -#define LB_MAX_SOC 1000 //LEAF BMS never goes over this value. We use this info to rescale SOC% sent to Fronius -#define LB_MIN_SOC 0 //LEAF BMS never goes below this value. We use this info to rescale SOC% sent to Fronius +#define MAX_CELL_VOLTAGE 4250 //Battery is put into emergency stop if one cell goes over this value +#define MIN_CELL_VOLTAGE 2700 //Battery is put into emergency stop if one cell goes below this value +#define MAX_CELL_DEVIATION 500 //LED turns yellow on the board if mv delta exceeds this value +#define WH_PER_GID 77 //One GID is this amount of Watt hours static uint16_t LB_Discharge_Power_Limit = 0; //Limit in kW static uint16_t LB_Charge_Power_Limit = 0; //Limit in kW static int16_t LB_MAX_POWER_FOR_CHARGER = 0; //Limit in kW @@ -211,8 +209,8 @@ void update_values_battery() { /* This function maps all the values fetched via } // Define power able to be discharged from battery - if (LB_Discharge_Power_Limit > 30) { //if >30kW can be pulled from battery - system_max_discharge_power_W = 30000; //cap value so we don't go over the Fronius limits + if (LB_Discharge_Power_Limit > 60) { //if >60kW can be pulled from battery + system_max_discharge_power_W = 60000; //cap value so we don't go over uint16 value } else { system_max_discharge_power_W = (LB_Discharge_Power_Limit * 1000); //kW to W } @@ -221,8 +219,8 @@ void update_values_battery() { /* This function maps all the values fetched via } // Define power able to be put into the battery - if (LB_Charge_Power_Limit > 30) { //if >30kW can be put into the battery - system_max_charge_power_W = 30000; //cap value so we don't go over the Fronius limits + if (LB_Charge_Power_Limit > 60) { //if >60kW can be put into the battery + system_max_charge_power_W = 60000; //cap value so we don't go over uint16 value } else { system_max_charge_power_W = (LB_Charge_Power_Limit * 1000); //kW to W } diff --git a/Software/src/inverter/BYD-MODBUS.cpp b/Software/src/inverter/BYD-MODBUS.cpp index 7f722f13..c18084ce 100644 --- a/Software/src/inverter/BYD-MODBUS.cpp +++ b/Software/src/inverter/BYD-MODBUS.cpp @@ -93,10 +93,19 @@ void handle_update_data_modbusp301_byd() { battery_data[5] = system_remaining_capacity_Wh; // Id.: p306 Value.: 13260 Scaled value.: 13,26kWh Comment.: remaining cap: 7.68kWh } - battery_data[6] = - system_max_discharge_power_W; // Id.: p307 Value.: 25604 Scaled value.: 25,604kW Comment.: max/target discharge power: 0W (0W > restricts to no discharge) - battery_data[7] = - system_max_charge_power_W; // Id.: p308 Value.: 25604 Scaled value.: 25,604kW Comment.: max/target charge power: 4.3kW (during charge), both 307&308 can be set (>0) at the same time + if (system_max_discharge_power_W > 30000) { + battery_data[6] = 30000; + } else { + battery_data[6] = + system_max_discharge_power_W; // Id.: p307 Value.: 25604 Scaled value.: 25,604kW Comment.: max/target discharge power: 0W (0W > restricts to no discharge) + } + + if (system_max_charge_power_W > 30000) { + battery_data[7] = 30000; + } else { + battery_data[7] = + system_max_charge_power_W; // Id.: p308 Value.: 25604 Scaled value.: 25,604kW Comment.: max/target charge power: 4.3kW (during charge), both 307&308 can be set (>0) at the same time + } //Battery_data[8] set previously in function // Id.: p309 Value.: 3161 Scaled value.: 316,1VDC Comment.: Batt Voltage outer (0 if status !=3, maybe a contactor closes when active): 173.4V battery_data[9] = 2000; // Id.: p310 Value.: 64121 Scaled value.: 6412,1W Comment.: Current Power to API: if>32768... -(65535-61760)=3775W