mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 10:19:29 +02:00
Merge pull request #190 from dalathegreat/bugfix/voltage-limits-as-variables
All batteries: Voltage limits as variables
This commit is contained in:
commit
e60eca78e1
23 changed files with 177 additions and 145 deletions
|
@ -21,7 +21,6 @@
|
|||
|
||||
#ifdef NISSAN_LEAF_BATTERY
|
||||
#include "NISSAN-LEAF-BATTERY.h" //See this file for more LEAF battery settings
|
||||
#define BATTERY_HAS_INIT
|
||||
#endif
|
||||
|
||||
#ifdef RENAULT_KANGOO_BATTERY
|
||||
|
@ -52,7 +51,7 @@
|
|||
void update_values_battery();
|
||||
void receive_can_battery(CAN_frame_t rx_frame);
|
||||
void send_can_battery();
|
||||
void announce_battery(void);
|
||||
void setup_battery(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -193,8 +193,11 @@ void send_can_battery() {
|
|||
}
|
||||
}
|
||||
|
||||
void announce_battery(void) {
|
||||
void setup_battery(void) { // Performs one time setup at startup
|
||||
Serial.println("BMW i3 battery selected");
|
||||
|
||||
max_voltage = 4040; // 404.4V, over this, charging is not possible (goes into forced discharge)
|
||||
min_voltage = 3100; // 310.0V under this, discharging further is disabled
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,25 +7,27 @@
|
|||
|
||||
#define BATTERY_SELECTED
|
||||
|
||||
#define ABSOLUTE_MAX_VOLTAGE \
|
||||
4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge)
|
||||
#define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled
|
||||
|
||||
// These parameters need to be mapped for the inverter
|
||||
extern uint16_t SOC;
|
||||
extern uint16_t StateOfHealth;
|
||||
extern uint16_t battery_voltage;
|
||||
extern uint16_t battery_current;
|
||||
extern uint16_t capacity_Wh;
|
||||
extern uint16_t remaining_capacity_Wh;
|
||||
extern uint16_t max_target_discharge_power;
|
||||
extern uint16_t max_target_charge_power;
|
||||
extern uint8_t bms_char_dis_status;
|
||||
extern uint16_t stat_batt_power;
|
||||
extern uint16_t temperature_min;
|
||||
extern uint16_t temperature_max;
|
||||
extern uint16_t CANerror;
|
||||
extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false
|
||||
extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false
|
||||
extern uint16_t max_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t min_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t SOC; //SOC%, 0-100.00 (0-10000)
|
||||
extern uint16_t StateOfHealth; //SOH%, 0-100.00 (0-10000)
|
||||
extern uint16_t battery_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t battery_current; //A+1, Goes thru convert2unsignedint16 function (5.0A = 50, -5.0A = 65485)
|
||||
extern uint16_t capacity_Wh; //Wh, 0-60000
|
||||
extern uint16_t remaining_capacity_Wh; //Wh, 0-60000
|
||||
extern uint16_t max_target_discharge_power; //W, 0-60000
|
||||
extern uint16_t max_target_charge_power; //W, 0-60000
|
||||
extern uint8_t bms_char_dis_status; //Enum, 0-2
|
||||
extern uint16_t stat_batt_power; //W, Goes thru convert2unsignedint16 function (5W = 5, -5W = 65530)
|
||||
extern uint16_t temperature_min; //C+1, Goes thru convert2unsignedint16 function (15.0C = 150, -15.0C = 65385)
|
||||
extern uint16_t temperature_max; //C+1, Goes thru convert2unsignedint16 function (15.0C = 150, -15.0C = 65385)
|
||||
extern uint16_t cell_max_voltage; //mV, 0-4350
|
||||
extern uint16_t cell_min_voltage; //mV, 0-4350
|
||||
extern uint16_t cellvoltages[120]; //mV 0-4350 per cell
|
||||
extern uint8_t nof_cellvoltages; // Total number of cell voltages, set by each battery.
|
||||
extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false
|
||||
|
||||
void setup_battery(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -221,8 +221,10 @@ void send_can_battery() {
|
|||
}
|
||||
}
|
||||
|
||||
void announce_battery(void) {
|
||||
void setup_battery(void) { // Performs one time setup at startup
|
||||
Serial.println("Chademo battery selected");
|
||||
}
|
||||
|
||||
max_voltage = 4040; // 404.4V, over this, charging is not possible (goes into forced discharge)
|
||||
min_voltage = 2000; // 200.0V under this, discharging further is disabled
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -7,26 +7,27 @@
|
|||
|
||||
#define BATTERY_SELECTED
|
||||
|
||||
#define ABSOLUTE_MAX_VOLTAGE \
|
||||
4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge)
|
||||
#define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled
|
||||
// These parameters need to be mapped for the inverter
|
||||
extern uint16_t max_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t min_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t SOC; //SOC%, 0-100.00 (0-10000)
|
||||
extern uint16_t StateOfHealth; //SOH%, 0-100.00 (0-10000)
|
||||
extern uint16_t battery_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t battery_current; //A+1, Goes thru convert2unsignedint16 function (5.0A = 50, -5.0A = 65485)
|
||||
extern uint16_t capacity_Wh; //Wh, 0-60000
|
||||
extern uint16_t remaining_capacity_Wh; //Wh, 0-60000
|
||||
extern uint16_t max_target_discharge_power; //W, 0-60000
|
||||
extern uint16_t max_target_charge_power; //W, 0-60000
|
||||
extern uint8_t bms_char_dis_status; //Enum, 0-2
|
||||
extern uint16_t stat_batt_power; //W, Goes thru convert2unsignedint16 function (5W = 5, -5W = 65530)
|
||||
extern uint16_t temperature_min; //C+1, Goes thru convert2unsignedint16 function (15.0C = 150, -15.0C = 65385)
|
||||
extern uint16_t temperature_max; //C+1, Goes thru convert2unsignedint16 function (15.0C = 150, -15.0C = 65385)
|
||||
extern uint16_t cell_max_voltage; //mV, 0-4350
|
||||
extern uint16_t cell_min_voltage; //mV, 0-4350
|
||||
extern uint16_t cellvoltages[120]; //mV 0-4350 per cell
|
||||
extern uint8_t nof_cellvoltages; // Total number of cell voltages, set by each battery.
|
||||
extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false
|
||||
|
||||
// These parameters need to be mapped
|
||||
extern uint16_t SOC;
|
||||
extern uint16_t StateOfHealth;
|
||||
extern uint16_t battery_voltage;
|
||||
extern uint16_t battery_current;
|
||||
extern uint16_t capacity_Wh;
|
||||
extern uint16_t remaining_capacity_Wh;
|
||||
extern uint16_t max_target_discharge_power;
|
||||
extern uint16_t max_target_charge_power;
|
||||
extern uint8_t bms_status;
|
||||
extern uint8_t bms_char_dis_status;
|
||||
extern uint16_t stat_batt_power;
|
||||
extern uint16_t temperature_min;
|
||||
extern uint16_t temperature_max;
|
||||
extern uint16_t CANerror;
|
||||
extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false
|
||||
extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false
|
||||
void setup_battery(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -227,8 +227,11 @@ void send_can_battery() {
|
|||
}
|
||||
}
|
||||
|
||||
void announce_battery(void) {
|
||||
void setup_battery(void) { // Performs one time setup at startup
|
||||
Serial.println("Mitsubishi i-MiEV / Citroen C-Zero / Peugeot Ion battery selected");
|
||||
|
||||
max_voltage = 4040; // 404.4V, over this, charging is not possible (goes into forced discharge)
|
||||
min_voltage = 3100; // 310.0V under this, discharging further is disabled
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,27 +7,28 @@
|
|||
|
||||
#define BATTERY_SELECTED
|
||||
|
||||
#define ABSOLUTE_MAX_VOLTAGE \
|
||||
4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge)
|
||||
#define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled
|
||||
|
||||
// These parameters need to be mapped for the Gen24
|
||||
extern uint16_t SOC;
|
||||
extern uint16_t StateOfHealth;
|
||||
extern uint16_t battery_voltage;
|
||||
extern uint16_t battery_current;
|
||||
extern uint16_t capacity_Wh;
|
||||
extern uint16_t remaining_capacity_Wh;
|
||||
extern uint16_t max_target_discharge_power;
|
||||
extern uint16_t max_target_charge_power;
|
||||
extern uint8_t bms_char_dis_status;
|
||||
extern uint16_t stat_batt_power;
|
||||
extern uint16_t temperature_min;
|
||||
extern uint16_t temperature_max;
|
||||
extern uint16_t CANerror;
|
||||
extern uint16_t cell_max_voltage;
|
||||
extern uint16_t cell_min_voltage;
|
||||
// These parameters need to be mapped for the Inverter
|
||||
extern uint16_t max_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t min_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t SOC; //SOC%, 0-100.00 (0-10000)
|
||||
extern uint16_t StateOfHealth; //SOH%, 0-100.00 (0-10000)
|
||||
extern uint16_t battery_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t battery_current; //A+1, Goes thru convert2unsignedint16 function (5.0A = 50, -5.0A = 65485)
|
||||
extern uint16_t capacity_Wh; //Wh, 0-60000
|
||||
extern uint16_t remaining_capacity_Wh; //Wh, 0-60000
|
||||
extern uint16_t max_target_discharge_power; //W, 0-60000
|
||||
extern uint16_t max_target_charge_power; //W, 0-60000
|
||||
extern uint8_t bms_char_dis_status; //Enum, 0-2
|
||||
extern uint16_t stat_batt_power; //W, Goes thru convert2unsignedint16 function (5W = 5, -5W = 65530)
|
||||
extern uint16_t temperature_min; //C+1, Goes thru convert2unsignedint16 function (15.0C = 150, -15.0C = 65385)
|
||||
extern uint16_t temperature_max; //C+1, Goes thru convert2unsignedint16 function (15.0C = 150, -15.0C = 65385)
|
||||
extern uint16_t cell_max_voltage; //mV, 0-4350
|
||||
extern uint16_t cell_min_voltage; //mV, 0-4350
|
||||
extern uint16_t cellvoltages[120]; //mV 0-4350 per cell
|
||||
extern uint8_t nof_cellvoltages; // Total number of cell voltages, set by each battery.
|
||||
extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false
|
||||
extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false
|
||||
|
||||
void setup_battery(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -599,8 +599,11 @@ uint16_t convertToUnsignedInt16(int16_t signed_value) {
|
|||
}
|
||||
}
|
||||
|
||||
void announce_battery(void) {
|
||||
void setup_battery(void) { // Performs one time setup at startup
|
||||
Serial.println("Kia Niro / Hyundai Kona 64kWh battery selected");
|
||||
|
||||
max_voltage = 4040; // 404.0V, over this, charging is not possible (goes into forced discharge)
|
||||
min_voltage = 3100; // 310.0V under this, discharging further is disabled
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,13 +7,12 @@
|
|||
|
||||
#define BATTERY_SELECTED
|
||||
|
||||
#define ABSOLUTE_MAX_VOLTAGE \
|
||||
4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge)
|
||||
#define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled
|
||||
#define MAXCHARGEPOWERALLOWED 10000
|
||||
#define MAXDISCHARGEPOWERALLOWED 10000
|
||||
|
||||
// These parameters need to be mapped for the Gen24
|
||||
// These parameters need to be mapped for the inverter
|
||||
extern uint16_t max_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t min_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t SOC; //SOC%, 0-100.00 (0-10000)
|
||||
extern uint16_t StateOfHealth; //SOH%, 0-100.00 (0-10000)
|
||||
extern uint16_t battery_voltage; //V+1, 0-500.0 (0-5000)
|
||||
|
@ -34,5 +33,6 @@ extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false
|
|||
extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false
|
||||
|
||||
uint16_t convertToUnsignedInt16(int16_t signed_value);
|
||||
void setup_battery(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -257,8 +257,7 @@ void update_values_battery() { /* This function maps all the values fetched via
|
|||
}
|
||||
|
||||
//Check if SOC% is plausible
|
||||
if (battery_voltage >
|
||||
(ABSOLUTE_MAX_VOLTAGE - 100)) { // When pack voltage is close to max, and SOC% is still low, raise FAULT
|
||||
if (battery_voltage > (max_voltage - 100)) { // When pack voltage is close to max, and SOC% is still low, raise FAULT
|
||||
if (LB_SOC < 650) {
|
||||
set_event(EVENT_SOC_PLAUSIBILITY_ERROR, LB_SOC / 10); // Set event with the SOC as data
|
||||
} else {
|
||||
|
@ -922,12 +921,12 @@ uint16_t Temp_fromRAW_to_F(uint16_t temperature) { //This function feels horrib
|
|||
return static_cast<uint16_t>(1094 + (309 - temperature) * 2.5714285714285715);
|
||||
}
|
||||
|
||||
void init_battery(void) {
|
||||
nof_cellvoltages = 96;
|
||||
}
|
||||
|
||||
void announce_battery(void) {
|
||||
void setup_battery(void) { // Performs one time setup at startup
|
||||
Serial.println("Nissan LEAF battery selected");
|
||||
|
||||
nof_cellvoltages = 96;
|
||||
max_voltage = 4040; // 404.4V, over this, charging is not possible (goes into forced discharge)
|
||||
min_voltage = 2450; // 245.0V under this, discharging further is disabled
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,11 +7,9 @@
|
|||
|
||||
#define BATTERY_SELECTED
|
||||
|
||||
#define ABSOLUTE_MAX_VOLTAGE \
|
||||
4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge)
|
||||
#define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled
|
||||
|
||||
// These parameters need to be mapped for the inverter
|
||||
extern uint16_t max_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t min_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t SOC; //SOC%, 0-100.00 (0-10000)
|
||||
extern uint16_t StateOfHealth; //SOH%, 0-100.00 (0-10000)
|
||||
extern uint16_t battery_voltage; //V+1, 0-500.0 (0-5000)
|
||||
|
@ -33,7 +31,6 @@ extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false
|
|||
uint16_t convert2unsignedint16(int16_t signed_value);
|
||||
uint16_t Temp_fromRAW_to_F(uint16_t temperature);
|
||||
bool is_message_corrupt(CAN_frame_t rx_frame);
|
||||
|
||||
void init_battery(void);
|
||||
void setup_battery(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -270,8 +270,11 @@ uint16_t convert2uint16(int16_t signed_value) {
|
|||
}
|
||||
}
|
||||
|
||||
void announce_battery(void) {
|
||||
void setup_battery(void) { // Performs one time setup at startup
|
||||
Serial.println("Renault Kangoo battery selected");
|
||||
|
||||
max_voltage = 4040; // 404.0V, over this, charging is not possible (goes into forced discharge)
|
||||
min_voltage = 3100; // 310.0V under this, discharging further is disabled
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,16 +7,15 @@
|
|||
|
||||
#define BATTERY_SELECTED
|
||||
|
||||
#define ABSOLUTE_MAX_VOLTAGE \
|
||||
4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge)
|
||||
#define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled
|
||||
#define ABSOLUTE_CELL_MAX_VOLTAGE \
|
||||
4100 // Max Cell Voltage mV! if voltage goes over this, charging is not possible (goes into forced discharge)
|
||||
#define ABSOLUTE_CELL_MIN_VOLTAGE \
|
||||
3000 // Min Cell Voltage mV! if voltage goes under this, discharging further is disabled
|
||||
#define MAX_CELL_DEVIATION_MV 500 //LED turns yellow on the board if mv delta exceeds this value
|
||||
|
||||
// These parameters need to be mapped for the Gen24
|
||||
// These parameters need to be mapped for the inverter
|
||||
extern uint16_t max_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t min_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t SOC; //SOC%, 0-100.00 (0-10000)
|
||||
extern uint16_t StateOfHealth; //SOH%, 0-100.00 (0-10000)
|
||||
extern uint16_t battery_voltage; //V+1, 0-500.0 (0-5000)
|
||||
|
@ -36,5 +35,6 @@ extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false
|
|||
extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false
|
||||
|
||||
uint16_t convert2uint16(int16_t signed_value);
|
||||
void setup_battery(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -166,8 +166,11 @@ void send_can_battery() {
|
|||
}
|
||||
}
|
||||
|
||||
void announce_battery(void) {
|
||||
void setup_battery(void) { // Performs one time setup at startup
|
||||
Serial.println("Renault Zoe battery selected");
|
||||
|
||||
max_voltage = 4040; // 404.0V, over this, charging is not possible (goes into forced discharge)
|
||||
min_voltage = 3100; // 310.0V under this, discharging further is disabled
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,16 +7,15 @@
|
|||
|
||||
#define BATTERY_SELECTED
|
||||
|
||||
#define ABSOLUTE_MAX_VOLTAGE \
|
||||
4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge)
|
||||
#define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled
|
||||
#define ABSOLUTE_CELL_MAX_VOLTAGE \
|
||||
4100 // Max Cell Voltage mV! if voltage goes over this, charging is not possible (goes into forced discharge)
|
||||
#define ABSOLUTE_CELL_MIN_VOLTAGE \
|
||||
3000 // Min Cell Voltage mV! if voltage goes under this, discharging further is disabled
|
||||
#define MAX_CELL_DEVIATION_MV 500 //LED turns yellow on the board if mv delta exceeds this value
|
||||
|
||||
// These parameters need to be mapped for the Gen24
|
||||
// These parameters need to be mapped for the inverter
|
||||
extern uint16_t max_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t min_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t SOC; //SOC%, 0-100.00 (0-10000)
|
||||
extern uint16_t StateOfHealth; //SOH%, 0-100.00 (0-10000)
|
||||
extern uint16_t battery_voltage; //V+1, 0-500.0 (0-5000)
|
||||
|
@ -35,4 +34,6 @@ extern uint16_t CANerror;
|
|||
extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false
|
||||
extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false
|
||||
|
||||
void setup_battery(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -177,8 +177,11 @@ uint8_t CalculateCRC8(CAN_frame_t rx_frame) {
|
|||
return (uint8_t)crc;
|
||||
}
|
||||
|
||||
void announce_battery(void) {
|
||||
void setup_battery(void) { // Performs one time setup at startup
|
||||
Serial.println("Hyundai Santa Fe PHEV battery selected");
|
||||
|
||||
max_voltage = 4040; // 404.0V, over this, charging is not possible (goes into forced discharge)
|
||||
min_voltage = 3100; // 310.0V under this, discharging further is disabled
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,27 +7,28 @@
|
|||
|
||||
#define BATTERY_SELECTED
|
||||
|
||||
#define ABSOLUTE_MAX_VOLTAGE \
|
||||
4030 // 403.0V,if battery voltage goes over this, charging is not possible (goes into forced discharge)
|
||||
#define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled
|
||||
|
||||
// These parameters need to be mapped for the Gen24
|
||||
extern uint16_t SOC;
|
||||
extern uint16_t StateOfHealth;
|
||||
extern uint16_t battery_voltage;
|
||||
extern uint16_t battery_current;
|
||||
extern uint16_t capacity_Wh;
|
||||
extern uint16_t remaining_capacity_Wh;
|
||||
extern uint16_t max_target_discharge_power;
|
||||
extern uint16_t max_target_charge_power;
|
||||
extern uint8_t bms_char_dis_status;
|
||||
extern uint16_t stat_batt_power;
|
||||
extern uint16_t temperature_min;
|
||||
extern uint16_t temperature_max;
|
||||
extern uint16_t CANerror;
|
||||
extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false
|
||||
extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false
|
||||
// These parameters need to be mapped for the inverter
|
||||
extern uint16_t max_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t min_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t SOC; //SOC%, 0-100.00 (0-10000)
|
||||
extern uint16_t StateOfHealth; //SOH%, 0-100.00 (0-10000)
|
||||
extern uint16_t battery_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t battery_current; //A+1, Goes thru convert2unsignedint16 function (5.0A = 50, -5.0A = 65485)
|
||||
extern uint16_t capacity_Wh; //Wh, 0-60000
|
||||
extern uint16_t remaining_capacity_Wh; //Wh, 0-60000
|
||||
extern uint16_t max_target_discharge_power; //W, 0-60000
|
||||
extern uint16_t max_target_charge_power; //W, 0-60000
|
||||
extern uint8_t bms_char_dis_status; //Enum, 0-2
|
||||
extern uint16_t stat_batt_power; //W, Goes thru convert2unsignedint16 function (5W = 5, -5W = 65530)
|
||||
extern uint16_t temperature_min; //C+1, Goes thru convert2unsignedint16 function (15.0C = 150, -15.0C = 65385)
|
||||
extern uint16_t temperature_max; //C+1, Goes thru convert2unsignedint16 function (15.0C = 150, -15.0C = 65385)
|
||||
extern uint16_t cell_max_voltage; //mV, 0-4350
|
||||
extern uint16_t cell_min_voltage; //mV, 0-4350
|
||||
extern uint16_t cellvoltages[120]; //mV 0-4350 per cell
|
||||
extern uint8_t nof_cellvoltages; // Total number of cell voltages, set by each battery.
|
||||
extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false
|
||||
|
||||
uint8_t CalculateCRC8(CAN_frame_t rx_frame);
|
||||
void setup_battery(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,11 +10,9 @@
|
|||
|
||||
// https://github.com/mackelec/SerialDataLink
|
||||
|
||||
#define ABSOLUTE_MAX_VOLTAGE \
|
||||
4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge)
|
||||
#define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled
|
||||
|
||||
// These parameters need to be mapped for the inverter
|
||||
extern uint16_t max_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t min_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t SOC; //SOC%, 0-100.00 (0-10000)
|
||||
extern uint16_t StateOfHealth; //SOH%, 0-100.00 (0-10000)
|
||||
extern uint16_t battery_voltage; //V+1, 0-500.0 (0-5000)
|
||||
|
|
|
@ -50,10 +50,10 @@ static uint16_t regenerative_limit = 0;
|
|||
static uint16_t discharge_limit = 0;
|
||||
static uint16_t max_heat_park = 0;
|
||||
static uint16_t hvac_max_power = 0;
|
||||
static uint16_t min_voltage = 0;
|
||||
static uint16_t max_discharge_current = 0;
|
||||
static uint16_t max_charge_current = 0;
|
||||
static uint16_t max_voltage = 0;
|
||||
static uint16_t bms_max_voltage = 0;
|
||||
static uint16_t bms_min_voltage = 0;
|
||||
static uint16_t high_voltage = 0;
|
||||
static uint16_t low_voltage = 0;
|
||||
static uint16_t output_current = 0;
|
||||
|
@ -258,10 +258,18 @@ void update_values_battery() { //This function maps all the values fetched via
|
|||
LFP_Chemistry = true;
|
||||
}
|
||||
|
||||
//Once cell chemistry is determined, set maximum and minimum total pack voltage safety limits
|
||||
if (LFP_Chemistry) {
|
||||
max_voltage = 3640;
|
||||
min_voltage = 2450;
|
||||
} else { // NCM/A chemistry
|
||||
max_voltage = 4030;
|
||||
min_voltage = 3100;
|
||||
}
|
||||
|
||||
//Check if SOC% is plausible
|
||||
if (battery_voltage >
|
||||
(ABSOLUTE_MAX_VOLTAGE - 100)) { // When pack voltage is close to max, and SOC% is still low, raise FAULT
|
||||
if (SOC < 6500) { //When SOC is less than 65.00% when approaching max voltage
|
||||
if (battery_voltage > (max_voltage - 100)) { // When pack voltage is close to max, and SOC% is still low, raise FAULT
|
||||
if (SOC < 6500) { //When SOC is less than 65.00% when approaching max voltage
|
||||
set_event(EVENT_SOC_PLAUSIBILITY_ERROR, SOC / 100);
|
||||
}
|
||||
}
|
||||
|
@ -341,6 +349,7 @@ void update_values_battery() { //This function maps all the values fetched via
|
|||
if (LFP_Chemistry) {
|
||||
Serial.print("LFP chemistry detected!");
|
||||
}
|
||||
Serial.print(nof_cellvoltages);
|
||||
Serial.println("");
|
||||
Serial.print("Cellstats, Max: ");
|
||||
Serial.print(cell_max_v);
|
||||
|
@ -487,8 +496,10 @@ void receive_can_battery(CAN_frame_t rx_frame) {
|
|||
break;
|
||||
case 0x2d2:
|
||||
//Min / max limits
|
||||
min_voltage = ((rx_frame.data.u8[1] << 8) | rx_frame.data.u8[0]) * 0.01 * 2; //Example 24148mv * 0.01 = 241.48 V
|
||||
max_voltage = ((rx_frame.data.u8[3] << 8) | rx_frame.data.u8[2]) * 0.01 * 2; //Example 40282mv * 0.01 = 402.82 V
|
||||
bms_min_voltage =
|
||||
((rx_frame.data.u8[1] << 8) | rx_frame.data.u8[0]) * 0.01 * 2; //Example 24148mv * 0.01 = 241.48 V
|
||||
bms_max_voltage =
|
||||
((rx_frame.data.u8[3] << 8) | rx_frame.data.u8[2]) * 0.01 * 2; //Example 40282mv * 0.01 = 402.82 V
|
||||
max_charge_current =
|
||||
(((rx_frame.data.u8[5] & 0x3F) << 8) | rx_frame.data.u8[4]) * 0.1; //Example 1301? * 0.1 = 130.1?
|
||||
max_discharge_current =
|
||||
|
@ -690,8 +701,11 @@ void printDebugIfActive(uint8_t symbol, const char* message) {
|
|||
}
|
||||
}
|
||||
|
||||
void announce_battery(void) {
|
||||
void setup_battery(void) { // Performs one time setup at startup
|
||||
Serial.println("Tesla Model 3 battery selected");
|
||||
|
||||
max_voltage = 4030; // 403.0V, over this, charging is not possible (goes into forced discharge)
|
||||
min_voltage = 3100; // 310.0V under this, discharging further is disabled
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,14 +7,13 @@
|
|||
|
||||
#define BATTERY_SELECTED
|
||||
|
||||
#define ABSOLUTE_MAX_VOLTAGE \
|
||||
4030 // 403.0V,if battery voltage goes over this, charging is not possible (goes into forced discharge)
|
||||
#define ABSOLUTE_MIN_VOLTAGE 2450 // 245.0V if battery voltage goes under this, discharging further is disabled
|
||||
#define MAXCHARGEPOWERALLOWED 15000 // 15000W we use a define since the value supplied by Tesla is always 0
|
||||
#define MAXDISCHARGEPOWERALLOWED \
|
||||
60000 // 60000W we need to cap this value to max 60kW, most inverters overflow otherwise
|
||||
|
||||
// These parameters need to be mapped for the Inverter
|
||||
// These parameters need to be mapped for the inverter
|
||||
extern uint16_t max_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t min_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t SOC; //SOC%, 0-100.00 (0-10000)
|
||||
extern uint16_t StateOfHealth; //SOH%, 0-100.00 (0-10000)
|
||||
extern uint16_t battery_voltage; //V+1, 0-500.0 (0-5000)
|
||||
|
@ -40,5 +39,6 @@ void printDebugIfActive(uint8_t symbol, const char* message);
|
|||
void print_int_with_units(char* header, int value, char* units);
|
||||
void print_SOC(char* header, int SOC);
|
||||
uint16_t convert2unsignedInt16(int16_t signed_value);
|
||||
void setup_battery(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -82,8 +82,11 @@ void send_can_battery() {
|
|||
}
|
||||
}
|
||||
|
||||
void announce_battery(void) {
|
||||
void setup_battery(void) { // Performs one time setup at startup
|
||||
Serial.println("Test mode with fake battery selected");
|
||||
|
||||
max_voltage = 4040; // 404.4V, over this, charging is not possible (goes into forced discharge)
|
||||
min_voltage = 2450; // 245.0V under this, discharging further is disabled
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,11 +7,9 @@
|
|||
|
||||
#define BATTERY_SELECTED
|
||||
|
||||
#define ABSOLUTE_MAX_VOLTAGE \
|
||||
4040 // 404.4V,if battery voltage goes over this, charging is not possible (goes into forced discharge)
|
||||
#define ABSOLUTE_MIN_VOLTAGE 3100 // 310.0V if battery voltage goes under this, discharging further is disabled
|
||||
|
||||
// These parameters need to be mapped for the inverter
|
||||
extern uint16_t max_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t min_voltage; //V+1, 0-500.0 (0-5000)
|
||||
extern uint16_t SOC; //SOC%, 0-100.00 (0-10000)
|
||||
extern uint16_t StateOfHealth; //SOH%, 0-100.00 (0-10000)
|
||||
extern uint16_t battery_voltage; //V+1, 0-500.0 (0-5000)
|
||||
|
@ -31,4 +29,6 @@ extern uint16_t cellvoltages[120]; //mV 0-5000 per cell
|
|||
extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false
|
||||
extern bool inverterAllowsContactorClosing; //Bool, 1=true, 0=false
|
||||
|
||||
void setup_battery(void);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue