mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 09:49:32 +02:00
Add HVIL status to webserver
This commit is contained in:
parent
10a60abd1a
commit
d86a9bd364
4 changed files with 83 additions and 16 deletions
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
void VolvoSpaBattery::
|
void VolvoSpaBattery::
|
||||||
update_values() { //This function maps all the values fetched via CAN to the correct parameters used for the inverter
|
update_values() { //This function maps all the values fetched via CAN to the correct parameters used for the inverter
|
||||||
uint8_t cnt = 0;
|
|
||||||
|
|
||||||
// Update webserver datalayer
|
// Update webserver datalayer
|
||||||
datalayer_extended.VolvoPolestar.soc_bms = SOC_BMS;
|
datalayer_extended.VolvoPolestar.soc_bms = SOC_BMS;
|
||||||
|
@ -88,6 +87,7 @@ void VolvoSpaBattery::
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_LOG
|
#ifdef DEBUG_LOG
|
||||||
|
uint8_t cnt = 0;
|
||||||
logging.print("BMS reported SOC%: ");
|
logging.print("BMS reported SOC%: ");
|
||||||
logging.println(SOC_BMS);
|
logging.println(SOC_BMS);
|
||||||
logging.print("Calculated SOC%: ");
|
logging.print("Calculated SOC%: ");
|
||||||
|
@ -127,6 +127,7 @@ void VolvoSpaBattery::
|
||||||
logging.print(cell_voltages[cnt++]);
|
logging.print(cell_voltages[cnt++]);
|
||||||
logging.print(",");
|
logging.print(",");
|
||||||
}
|
}
|
||||||
|
cnt = 0;
|
||||||
logging.println(";");
|
logging.println(";");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -272,18 +273,33 @@ void VolvoSpaBattery::handle_incoming_can_frame(CAN_frame rx_frame) {
|
||||||
(rx_frame.data.u8[3] == 0x42)) // BECM module voltage supply
|
(rx_frame.data.u8[3] == 0x42)) // BECM module voltage supply
|
||||||
{
|
{
|
||||||
datalayer_extended.VolvoPolestar.BECMsupplyVoltage = ((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]);
|
datalayer_extended.VolvoPolestar.BECMsupplyVoltage = ((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]);
|
||||||
|
transmit_can_frame(&VOLVO_BECM_HVIL_Status_Req); //Send HVIL status readout command
|
||||||
|
} else if ((rx_frame.data.u8[0] == 0x04) && (rx_frame.data.u8[1] == 0x62) && (rx_frame.data.u8[2] == 0x49) &&
|
||||||
|
(rx_frame.data.u8[3] == 0x1A)) // BECM HVIL status
|
||||||
|
{
|
||||||
|
datalayer_extended.VolvoPolestar.HVILstatusBits = (rx_frame.data.u8[4]);
|
||||||
|
transmit_can_frame(&VOLVO_DTCreadout); //Send DTC readout command
|
||||||
} else if ((rx_frame.data.u8[0] == 0x10) && (rx_frame.data.u8[1] == 0x0B) && (rx_frame.data.u8[2] == 0x62) &&
|
} else if ((rx_frame.data.u8[0] == 0x10) && (rx_frame.data.u8[1] == 0x0B) && (rx_frame.data.u8[2] == 0x62) &&
|
||||||
(rx_frame.data.u8[3] == 0x4B)) // First response frame of cell voltages
|
(rx_frame.data.u8[3] == 0x4B)) // First response frame of cell voltages
|
||||||
{
|
{
|
||||||
cell_voltages[battery_request_idx++] = ((rx_frame.data.u8[5] << 8) | rx_frame.data.u8[6]);
|
cell_voltages[battery_request_idx++] = ((rx_frame.data.u8[5] << 8) | rx_frame.data.u8[6]);
|
||||||
cell_voltages[battery_request_idx] = (rx_frame.data.u8[7] << 8);
|
cell_voltages[battery_request_idx] = (rx_frame.data.u8[7] << 8);
|
||||||
transmit_can_frame(&VOLVO_FlowControl); // Send flow control
|
transmit_can_frame(&VOLVO_FlowControl); // Send flow control
|
||||||
rxConsecutiveFrames = 1;
|
rxConsecutiveFrames = true;
|
||||||
} else if ((rx_frame.data.u8[0] == 0x10) && (rx_frame.data.u8[2] == 0x59) &&
|
} else if ((rx_frame.data.u8[0] == 0x10) && (rx_frame.data.u8[2] == 0x59) &&
|
||||||
(rx_frame.data.u8[3] == 0x03)) // First response frame for DTC with more than one code
|
(rx_frame.data.u8[3] == 0x03)) // First response frame for DTC with more than one code
|
||||||
{
|
{
|
||||||
|
datalayer_extended.VolvoPolestar.DTCcount = ((rx_frame.data.u8[1] - 2) / 4);
|
||||||
transmit_can_frame(&VOLVO_FlowControl); // Send flow control
|
transmit_can_frame(&VOLVO_FlowControl); // Send flow control
|
||||||
} else if ((rx_frame.data.u8[0] == 0x21) && (rxConsecutiveFrames == 1)) {
|
} else if ((rx_frame.data.u8[1] == 0x59) &&
|
||||||
|
(rx_frame.data.u8[2] == 0x03)) // Response frame for DTC with 0 or 1 code
|
||||||
|
{
|
||||||
|
if (rx_frame.data.u8[0] != 0x02) {
|
||||||
|
datalayer_extended.VolvoPolestar.DTCcount = 1;
|
||||||
|
} else {
|
||||||
|
datalayer_extended.VolvoPolestar.DTCcount = 0;
|
||||||
|
}
|
||||||
|
} else if ((rx_frame.data.u8[0] == 0x21) && (rxConsecutiveFrames)) {
|
||||||
cell_voltages[battery_request_idx++] = cell_voltages[battery_request_idx] | rx_frame.data.u8[1];
|
cell_voltages[battery_request_idx++] = cell_voltages[battery_request_idx] | rx_frame.data.u8[1];
|
||||||
cell_voltages[battery_request_idx++] = (rx_frame.data.u8[2] << 8) | rx_frame.data.u8[3];
|
cell_voltages[battery_request_idx++] = (rx_frame.data.u8[2] << 8) | rx_frame.data.u8[3];
|
||||||
cell_voltages[battery_request_idx++] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5];
|
cell_voltages[battery_request_idx++] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5];
|
||||||
|
@ -303,7 +319,7 @@ void VolvoSpaBattery::handle_incoming_can_frame(CAN_frame rx_frame) {
|
||||||
}
|
}
|
||||||
transmit_can_frame(&VOLVO_SOH_Req); //Send SOH read request
|
transmit_can_frame(&VOLVO_SOH_Req); //Send SOH read request
|
||||||
}
|
}
|
||||||
rxConsecutiveFrames = 0;
|
rxConsecutiveFrames = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -314,7 +330,7 @@ void VolvoSpaBattery::handle_incoming_can_frame(CAN_frame rx_frame) {
|
||||||
void VolvoSpaBattery::readCellVoltages() {
|
void VolvoSpaBattery::readCellVoltages() {
|
||||||
battery_request_idx = 0;
|
battery_request_idx = 0;
|
||||||
batteryModuleNumber = 0x10;
|
batteryModuleNumber = 0x10;
|
||||||
rxConsecutiveFrames = 0;
|
rxConsecutiveFrames = false;
|
||||||
VOLVO_CELL_U_Req.data.u8[3] = batteryModuleNumber++;
|
VOLVO_CELL_U_Req.data.u8[3] = batteryModuleNumber++;
|
||||||
transmit_can_frame(&VOLVO_CELL_U_Req); //Send cell voltage read request for first module
|
transmit_can_frame(&VOLVO_CELL_U_Req); //Send cell voltage read request for first module
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ class VolvoSpaBattery : public CanBattery {
|
||||||
uint16_t HvBattPwrLimChrgSlowAgi = 0; //0x177
|
uint16_t HvBattPwrLimChrgSlowAgi = 0; //0x177
|
||||||
uint8_t batteryModuleNumber = 0x10; // First battery module
|
uint8_t batteryModuleNumber = 0x10; // First battery module
|
||||||
uint8_t battery_request_idx = 0;
|
uint8_t battery_request_idx = 0;
|
||||||
uint8_t rxConsecutiveFrames = 0;
|
bool rxConsecutiveFrames = false;
|
||||||
uint16_t min_max_voltage[2]; //contains cell min[0] and max[1] values in mV
|
uint16_t min_max_voltage[2]; //contains cell min[0] and max[1] values in mV
|
||||||
uint8_t cellcounter = 0;
|
uint8_t cellcounter = 0;
|
||||||
uint16_t cell_voltages[108]; //array with all the cellvoltages
|
uint16_t cell_voltages[108]; //array with all the cellvoltages
|
||||||
|
@ -75,21 +75,17 @@ class VolvoSpaBattery : public CanBattery {
|
||||||
.ext_ID = false,
|
.ext_ID = false,
|
||||||
.DLC = 8,
|
.DLC = 8,
|
||||||
.ID = 0x536,
|
.ID = 0x536,
|
||||||
//.data = {0x00, 0x40, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00}}; //Network manage frame
|
|
||||||
.data = {0x00, 0x40, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00}}; //Network manage frame
|
.data = {0x00, 0x40, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00}}; //Network manage frame
|
||||||
|
|
||||||
CAN_frame VOLVO_140_CLOSE = {.FD = false,
|
CAN_frame VOLVO_140_CLOSE = {.FD = false,
|
||||||
.ext_ID = false,
|
.ext_ID = false,
|
||||||
.DLC = 8,
|
.DLC = 8,
|
||||||
.ID = 0x140,
|
.ID = 0x140,
|
||||||
.data = {0x00, 0x02, 0x00, 0xB7, 0xFF, 0x03, 0xFF, 0x82}}; //Close contactors message
|
.data = {0x00, 0x02, 0x00, 0xB7, 0xFF, 0x03, 0xFF, 0x82}}; //Close contactors message
|
||||||
|
|
||||||
CAN_frame VOLVO_140_OPEN = {.FD = false,
|
CAN_frame VOLVO_140_OPEN = {.FD = false,
|
||||||
.ext_ID = false,
|
.ext_ID = false,
|
||||||
.DLC = 8,
|
.DLC = 8,
|
||||||
.ID = 0x140,
|
.ID = 0x140,
|
||||||
.data = {0x00, 0x02, 0x00, 0x9E, 0xFF, 0x03, 0xFF, 0x82}}; //Open contactor message
|
.data = {0x00, 0x02, 0x00, 0x9E, 0xFF, 0x03, 0xFF, 0x82}}; //Open contactor message
|
||||||
|
|
||||||
CAN_frame VOLVO_372 = {
|
CAN_frame VOLVO_372 = {
|
||||||
.FD = false,
|
.FD = false,
|
||||||
.ext_ID = false,
|
.ext_ID = false,
|
||||||
|
@ -117,6 +113,12 @@ class VolvoSpaBattery : public CanBattery {
|
||||||
.DLC = 8,
|
.DLC = 8,
|
||||||
.ID = 0x735,
|
.ID = 0x735,
|
||||||
.data = {0x03, 0x22, 0xF4, 0x42, 0x00, 0x00, 0x00, 0x00}}; //BECM supply voltage request frame
|
.data = {0x03, 0x22, 0xF4, 0x42, 0x00, 0x00, 0x00, 0x00}}; //BECM supply voltage request frame
|
||||||
|
CAN_frame VOLVO_BECM_HVIL_Status_Req = {
|
||||||
|
.FD = false,
|
||||||
|
.ext_ID = false,
|
||||||
|
.DLC = 8,
|
||||||
|
.ID = 0x735,
|
||||||
|
.data = {0x03, 0x22, 0x49, 0x1A, 0x00, 0x00, 0x00, 0x00}}; //BECM HVIL status request frame
|
||||||
CAN_frame VOLVO_DTC_Erase = {.FD = false,
|
CAN_frame VOLVO_DTC_Erase = {.FD = false,
|
||||||
.ext_ID = false,
|
.ext_ID = false,
|
||||||
.DLC = 8,
|
.DLC = 8,
|
||||||
|
|
|
@ -9,11 +9,11 @@ class VolvoSpaHtmlRenderer : public BatteryHtmlRenderer {
|
||||||
public:
|
public:
|
||||||
String get_status_html() {
|
String get_status_html() {
|
||||||
String content;
|
String content;
|
||||||
|
content += "</h4><h4>BECM reported number of DTCs: " + String(datalayer_extended.VolvoPolestar.DTCcount) + "</h4>";
|
||||||
content += "<h4>BECM reported SOC: " + String(datalayer_extended.VolvoPolestar.soc_bms) + "</h4>";
|
content += "<h4>BECM reported SOC: " + String(datalayer_extended.VolvoPolestar.soc_bms / 10.0) + " %</h4>";
|
||||||
content += "<h4>Calculated SOC: " + String(datalayer_extended.VolvoPolestar.soc_calc) + "</h4>";
|
content += "<h4>Calculated SOC: " + String(datalayer_extended.VolvoPolestar.soc_calc / 10.0) + " %</h4>";
|
||||||
content += "<h4>Rescaled SOC: " + String(datalayer_extended.VolvoPolestar.soc_rescaled / 10) + "</h4>";
|
content += "<h4>Rescaled SOC: " + String(datalayer_extended.VolvoPolestar.soc_rescaled / 10.0) + " %</h4>";
|
||||||
content += "<h4>BECM reported SOH: " + String(datalayer_extended.VolvoPolestar.soh_bms) + "</h4>";
|
content += "<h4>BECM reported SOH: " + String(datalayer_extended.VolvoPolestar.soh_bms / 100.0) + " %</h4>";
|
||||||
content += "<h4>BECM supply voltage: " + String(datalayer_extended.VolvoPolestar.BECMsupplyVoltage) + " mV</h4>";
|
content += "<h4>BECM supply voltage: " + String(datalayer_extended.VolvoPolestar.BECMsupplyVoltage) + " mV</h4>";
|
||||||
|
|
||||||
content += "<h4>HV voltage: " + String(datalayer_extended.VolvoPolestar.BECMBatteryVoltage) + " V</h4>";
|
content += "<h4>HV voltage: " + String(datalayer_extended.VolvoPolestar.BECMBatteryVoltage) + " V</h4>";
|
||||||
|
@ -31,7 +31,54 @@ class VolvoSpaHtmlRenderer : public BatteryHtmlRenderer {
|
||||||
content +=
|
content +=
|
||||||
"<h4>Charge power limit slow aging: " + String(datalayer_extended.VolvoPolestar.HvBattPwrLimChrgSlowAgi) +
|
"<h4>Charge power limit slow aging: " + String(datalayer_extended.VolvoPolestar.HvBattPwrLimChrgSlowAgi) +
|
||||||
" kW</h4>";
|
" kW</h4>";
|
||||||
|
content += "<h4>HVIL Circuit A status: ";
|
||||||
|
switch (datalayer_extended.VolvoPolestar.HVILstatusBits & 0x01) {
|
||||||
|
case 0x01:
|
||||||
|
content += String("Open");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
content += String("Not valid");
|
||||||
|
}
|
||||||
|
content += "<h4>HVIL Circuit B status: ";
|
||||||
|
switch (datalayer_extended.VolvoPolestar.HVILstatusBits & 0x02) {
|
||||||
|
case 0x02:
|
||||||
|
content += String("Open");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
content += String("Closed");
|
||||||
|
}
|
||||||
|
content += "<h4>HVIL Circuit C status: ";
|
||||||
|
switch (datalayer_extended.VolvoPolestar.HVILstatusBits & 0x04) {
|
||||||
|
case 0x04:
|
||||||
|
content += String("Open");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
content += String("Closed");
|
||||||
|
}
|
||||||
|
content += "<h4>Positive contactor status: ";
|
||||||
|
switch (datalayer_extended.VolvoPolestar.HVILstatusBits & 0x08) {
|
||||||
|
case 0x08:
|
||||||
|
content += String("Open");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
content += String("Closed");
|
||||||
|
}
|
||||||
|
content += "<h4>Precharge Contactor status: ";
|
||||||
|
switch (datalayer_extended.VolvoPolestar.HVILstatusBits & 0x10) {
|
||||||
|
case 0x10:
|
||||||
|
content += String("Open");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
content += String("Closed");
|
||||||
|
}
|
||||||
|
content += "<h4>Negative Contactor status: ";
|
||||||
|
switch (datalayer_extended.VolvoPolestar.HVILstatusBits & 0x20) {
|
||||||
|
case 0x20:
|
||||||
|
content += String("Open");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
content += String("Closed");
|
||||||
|
}
|
||||||
content += "<h4>HV system relay status: ";
|
content += "<h4>HV system relay status: ";
|
||||||
switch (datalayer_extended.VolvoPolestar.HVSysRlySts) {
|
switch (datalayer_extended.VolvoPolestar.HVSysRlySts) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
|
@ -783,6 +783,8 @@ struct DATALAYER_INFO_VOLVO_POLESTAR {
|
||||||
uint8_t HVSysDCRlySts1 = 0;
|
uint8_t HVSysDCRlySts1 = 0;
|
||||||
uint8_t HVSysDCRlySts2 = 0;
|
uint8_t HVSysDCRlySts2 = 0;
|
||||||
uint8_t HVSysIsoRMonrSts = 0;
|
uint8_t HVSysIsoRMonrSts = 0;
|
||||||
|
uint8_t DTCcount = 0;
|
||||||
|
uint8_t HVILstatusBits = 0;
|
||||||
/** User requesting DTC reset via WebUI*/
|
/** User requesting DTC reset via WebUI*/
|
||||||
bool UserRequestDTCreset = false;
|
bool UserRequestDTCreset = false;
|
||||||
/** User requesting DTC readout via WebUI*/
|
/** User requesting DTC readout via WebUI*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue